From: Juergen Gross <jgross@suse.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: andrew.cooper3@citrix.com, wei.liu2@citrix.com,
xen-devel@lists.xenproject.org,
Dario Faggioli <dfaggioli@suse.com>
Subject: Re: [PATCH v2 3/6] xen/x86: support per-domain flag for xpti
Date: Thu, 8 Mar 2018 12:30:50 +0100 [thread overview]
Message-ID: <a0e3b93a-0111-bfb0-fb9e-ff736769fe7e@suse.com> (raw)
In-Reply-To: <5AA11BDE02000078001AFB92@suse.com>
On 08/03/18 11:17, Jan Beulich wrote:
>>>> On 02.03.18 at 09:14, <jgross@suse.com> wrote:
>> --- a/xen/arch/x86/mm.c
>> +++ b/xen/arch/x86/mm.c
>> @@ -510,15 +510,19 @@ void make_cr3(struct vcpu *v, mfn_t mfn)
>>
>> void write_ptbase(struct vcpu *v)
>> {
>> - if ( this_cpu(root_pgt) && is_pv_vcpu(v) && !is_pv_32bit_vcpu(v) )
>> + if ( is_pv_vcpu(v) && v->domain->arch.pv_domain.xpti )
>> {
>> get_cpu_info()->root_pgt_changed = true;
>> + get_cpu_info()->pv_cr3 = __pa(this_cpu(root_pgt));
>> asm volatile ( "mov %0, %%cr3" : : "r" (v->arch.cr3) : "memory" );
>> }
>> else
>> {
>> get_cpu_info()->root_pgt_changed = false;
>> + /* Make sure to clear xen_cr3 before pv_cr3; write_cr3() serializes. */
>> + get_cpu_info()->xen_cr3 = 0;
>> write_cr3(v->arch.cr3);
>> + get_cpu_info()->pv_cr3 = 0;
>> }
>> }
>
> I think you want to latch the return value of get_cpu_info() into a
> local variable now.
Yes.
>
>> @@ -707,6 +708,9 @@ int __init dom0_construct_pv(struct domain *d,
>> cpu = p->processor;
>> }
>>
>> + if ( !is_pv_32bit_domain(d) )
>> + xpti_domain_init(d);
>
> Perhaps better to omit the conditional here? Or otherwise use the
> "compat32" local variable?
I'll drop the conditional.
>
>> +static int parse_xpti(const char *s)
>
> __init
Aah, of course.
>
>> +{
>> + int rc = 0;
>> +
>> + switch ( parse_bool(s, NULL) )
>> + {
>> + case 0:
>> + opt_xpti = XPTI_OFF;
>> + break;
>> + case 1:
>> + opt_xpti = XPTI_ON;
>> + break;
>> + default:
>> + if ( !strcmp(s, "default") )
>
> This wants to also be mentioned in the command line doc.
Uuh, this was a copy-and-paste result from my alternative XPTI approach.
I'll just drop that value.
>
>> + opt_xpti = XPTI_DEFAULT;
>> + else if ( !strcmp(s, "nodom0") )
>> + opt_xpti = XPTI_NODOM0;
>> + else
>> + rc = -EINVAL;
>> + break;
>> + }
>> +
>> + return rc;
>> +}
>> +
>> +custom_param("xpti", parse_xpti);
>
> Please omit the blank line above here.
Okay.
>
>> +void xpti_init(void)
>
> __init
Yes.
>
>> +void xpti_domain_init(struct domain *d)
>> +{
>> + if ( !is_pv_domain(d) || is_pv_32bit_domain(d) )
>> + return;
>> +
>> + switch ( opt_xpti )
>> + {
>> + case XPTI_OFF:
>> + d->arch.pv_domain.xpti = false;
>> + break;
>> + case XPTI_ON:
>> + d->arch.pv_domain.xpti = true;
>> + break;
>> + case XPTI_NODOM0:
>> + d->arch.pv_domain.xpti = d->domain_id != 0 &&
>> + d->domain_id != hardware_domid;
>> + break;
>> + default:
>> + ASSERT_UNREACHABLE();
>> + break;
>> + }
>> +
>> + if ( d->arch.pv_domain.xpti )
>> + printk("Enabling Xen Pagetable protection (XPTI) for Domain %d\n",
>> + d->domain_id);
>
> Please don't, even less so without XENLOG_G_*. And if you really,
> really want this at, say, XENLOG_G_DEBUG, then Dom%d please.
Okay, I'll drop that message.
>
>> --- a/xen/include/asm-x86/domain.h
>> +++ b/xen/include/asm-x86/domain.h
>> @@ -257,6 +257,9 @@ struct pv_domain
>> struct mapcache_domain mapcache;
>>
>> struct cpuidmasks *cpuidmasks;
>> +
>> + /* XPTI active? */
>> + bool xpti;
>> };
>
> Is there really no 1 byte slot available elsewhere in the structure?
> Like between nr_l4_pages and mapcache?
I'll have a look.
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-03-08 11:30 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-02 8:13 [PATCH v2 0/6] xen/x86: various XPTI speedups Juergen Gross
2018-03-02 8:13 ` [PATCH v2 1/6] x86/xpti: avoid copying L4 page table contents when possible Juergen Gross
2018-03-05 16:43 ` Jan Beulich
2018-03-08 11:59 ` Juergen Gross
2018-03-08 12:47 ` Jan Beulich
[not found] ` <5AA13EEA02000078001AFCAF@suse.com>
2018-03-08 13:03 ` Juergen Gross
[not found] ` <5A9D81DC02000078001AEB68@suse.com>
2018-03-06 7:01 ` Juergen Gross
2018-03-06 7:58 ` Jan Beulich
[not found] ` <5A9E583002000078001AED3A@suse.com>
2018-03-06 8:06 ` Juergen Gross
2018-03-06 8:17 ` Jan Beulich
2018-03-02 8:13 ` [PATCH v2 2/6] x86/xpti: don't flush TLB twice when switching to 64-bit pv context Juergen Gross
2018-03-05 16:49 ` Jan Beulich
[not found] ` <5A9D831F02000078001AEB7E@suse.com>
2018-03-06 7:02 ` Juergen Gross
2018-03-02 8:14 ` [PATCH v2 3/6] xen/x86: support per-domain flag for xpti Juergen Gross
2018-03-08 10:17 ` Jan Beulich
[not found] ` <5AA11BDE02000078001AFB92@suse.com>
2018-03-08 11:30 ` Juergen Gross [this message]
2018-03-08 12:49 ` Jan Beulich
[not found] ` <5AA13F7D02000078001AFCB3@suse.com>
2018-03-08 13:13 ` Juergen Gross
2018-03-02 8:14 ` [PATCH v2 4/6] xen/x86: disable global pages for domains with XPTI active Juergen Gross
2018-03-02 11:03 ` Wei Liu
2018-03-02 11:30 ` Juergen Gross
2018-03-08 13:38 ` Jan Beulich
2018-03-09 3:01 ` Tian, Kevin
2018-03-09 5:23 ` Tian, Kevin
2018-03-09 8:34 ` Jan Beulich
[not found] ` <5AA2551002000078001B0116@suse.com>
2018-03-09 8:42 ` Juergen Gross
[not found] ` <5AA14AF302000078001AFD30@suse.com>
2018-03-08 14:05 ` Juergen Gross
2018-03-08 14:33 ` Jan Beulich
[not found] ` <5AA157E002000078001AFDA4@suse.com>
2018-03-08 14:39 ` Juergen Gross
2018-03-08 15:06 ` Jan Beulich
2018-03-09 14:40 ` Juergen Gross
2018-03-09 15:30 ` Jan Beulich
2018-03-02 8:14 ` [PATCH v2 5/6] xen/x86: use flag byte for decision whether xen_cr3 is valid Juergen Gross
2018-03-08 14:24 ` Jan Beulich
[not found] ` <5AA155BE02000078001AFD89@suse.com>
2018-03-08 14:28 ` Juergen Gross
2018-03-02 8:14 ` [PATCH v2 6/6] xen/x86: use PCID feature for XPTI Juergen Gross
2018-03-08 15:27 ` Jan Beulich
2018-03-05 16:20 ` [PATCH v2 0/6] xen/x86: various XPTI speedups Dario Faggioli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a0e3b93a-0111-bfb0-fb9e-ff736769fe7e@suse.com \
--to=jgross@suse.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dfaggioli@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).