From: Sergey Dyasli <sergey.dyasli@citrix.com>
To: Andrew Cooper <Andrew.Cooper3@citrix.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "jun.nakajima@intel.com" <jun.nakajima@intel.com>,
Sergey Dyasli <sergey.dyasli@citrix.com>,
Kevin Tian <kevin.tian@intel.com>,
George Dunlap <George.Dunlap@citrix.com>,
"jbeulich@suse.com" <jbeulich@suse.com>
Subject: Re: [PATCH 5/9] x86/vvmx: Make updating shadow EPTP value more efficient
Date: Mon, 2 Oct 2017 09:41:56 +0000 [thread overview]
Message-ID: <1506937316.3729.5.camel@citrix.com> (raw)
In-Reply-To: <7f697e11-47f5-9d4b-7a0a-8c508f94a781@citrix.com>
On Fri, 2017-09-29 at 16:56 +0100, Andrew Cooper wrote:
> On 29/09/17 16:01, George Dunlap wrote:
> > @@ -4203,13 +4197,17 @@ static void lbr_fixup(void)
> > bdw_erratum_bdf14_fixup();
> > }
> >
> > -void vmx_vmenter_helper(const struct cpu_user_regs *regs)
> > +int vmx_vmenter_helper(const struct cpu_user_regs *regs)
>
> What are the semantics of this call? The result looks boolean, and
> indicates that the vmentry should be aborted?
Currently vmx_vmenter_helper() returns !0 if the vmentry must be
restarted.
>
> > {
> > struct vcpu *curr = current;
> > u32 new_asid, old_asid;
> > struct hvm_vcpu_asid *p_asid;
> > bool_t need_flush;
> >
> > + /* Shadow EPTP can't be updated here because irqs are disabled */
> > + if ( nestedhvm_vcpu_in_guestmode(curr) && vcpu_nestedhvm(curr).stale_np2m )
> > + return 1;
> > +
> > if ( curr->domain->arch.hvm_domain.pi_ops.do_resume )
> > curr->domain->arch.hvm_domain.pi_ops.do_resume(curr);
> >
> > @@ -4270,6 +4268,8 @@ void vmx_vmenter_helper(const struct cpu_user_regs *regs)
> > __vmwrite(GUEST_RIP, regs->rip);
> > __vmwrite(GUEST_RSP, regs->rsp);
> > __vmwrite(GUEST_RFLAGS, regs->rflags | X86_EFLAGS_MBS);
> > +
> > + return 0;
> > }
> >
> > /*
> > diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
> > index 2f468e6ced..48e37158af 100644
> > --- a/xen/arch/x86/hvm/vmx/vvmx.c
> > +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> > @@ -1405,12 +1405,32 @@ static void virtual_vmexit(struct cpu_user_regs *regs)
> > vmsucceed(regs);
> > }
> >
> > +static void nvmx_eptp_update(void)
> > +{
>
> struct vcpu *curr = current; will most likely half the compiled size of
> this function.
Yes, passing a struct vcpu *v to nvmx_eptp_update() removes all
the additional:
mov %rsp,%rax
or $0x7fff,%rax
I wasn't aware of such behavior and will correct the usage of current
for all patches in v3.
>
> > + if ( !nestedhvm_vcpu_in_guestmode(current) ||
> > + vcpu_nestedhvm(current).nv_vmexit_pending ||
> > + !vcpu_nestedhvm(current).stale_np2m ||
> > + !nestedhvm_paging_mode_hap(current) )
> > + return;
> > +
> > + /*
> > + * Interrupts are enabled here, so we need to clear stale_np2m
> > + * before we do the vmwrite. If we do it in the other order, an
> > + * and IPI comes in changing the shadow eptp after the vmwrite,
> > + * we'll complete the vmenter with a stale eptp value.
> > + */
> > + vcpu_nestedhvm(current).stale_np2m = false;
> > + __vmwrite(EPT_POINTER, get_shadow_eptp(current));
> > +}
> > +
> > void nvmx_switch_guest(void)
> > {
> > struct vcpu *v = current;
> > struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
> > struct cpu_user_regs *regs = guest_cpu_user_regs();
> >
> > + nvmx_eptp_update();
> > +
> > /*
> > * A pending IO emulation may still be not finished. In this case, no
> > * virtual vmswitch is allowed. Or else, the following IO emulation will
> > diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h
> > index 6c54773f1c..5cfa4b4aa4 100644
> > --- a/xen/include/asm-x86/hvm/vcpu.h
> > +++ b/xen/include/asm-x86/hvm/vcpu.h
> > @@ -115,6 +115,7 @@ struct nestedvcpu {
> >
> > bool_t nv_flushp2m; /* True, when p2m table must be flushed */
> > struct p2m_domain *nv_p2m; /* used p2m table for this vcpu */
> > + bool stale_np2m; /* True when p2m_base in VMCX02 is no longer valid */
>
> VMCx02 ? which helps distinguish the two parts of semantic information
> encoded there, and to avoid looking like we've gained a third acronym.
I like this suggestion. Will update comments and commit messages for all
patches in v3.
--
Thanks,
Sergey
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-10-02 9:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-29 15:01 [PATCH 1/9] x86/np2m: refactor p2m_get_nestedp2m() George Dunlap
2017-09-29 15:01 ` [PATCH 2/9] x86/np2m: Have invept flush all np2m entries with the same base pointer George Dunlap
2017-10-02 9:37 ` Sergey Dyasli
2017-10-02 9:40 ` George Dunlap
2017-10-02 10:07 ` George Dunlap
2017-10-02 10:24 ` Sergey Dyasli
2017-09-29 15:01 ` [PATCH 3/9] x86/np2m: remove np2m_base from p2m_get_nestedp2m() George Dunlap
2017-09-29 15:01 ` [PATCH 4/9] x86/np2m: Simplify nestedhvm_hap_nested_page_fault George Dunlap
2017-10-02 9:39 ` Sergey Dyasli
2017-09-29 15:01 ` [PATCH 5/9] x86/vvmx: Make updating shadow EPTP value more efficient George Dunlap
2017-09-29 15:56 ` Andrew Cooper
2017-10-02 9:41 ` Sergey Dyasli [this message]
2017-09-29 15:01 ` [PATCH 6/9] x86/np2m: Send flush IPIs only when a vcpu is actively using a shadow p2m George Dunlap
2017-09-29 15:01 ` [PATCH 7/9] x86/np2m: implement sharing of np2m between vCPUs George Dunlap
2017-09-29 15:01 ` [PATCH 8/9] x86/np2m: refactor p2m_get_nestedp2m_locked() George Dunlap
2017-09-29 15:01 ` [PATCH 9/9] x86/np2m: add break to np2m_flush_eptp() George Dunlap
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=1506937316.3729.5.camel@citrix.com \
--to=sergey.dyasli@citrix.com \
--cc=Andrew.Cooper3@citrix.com \
--cc=George.Dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.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).