diff mbox

[v3,5/9] x86/vvmx: make updating shadow EPTP value more efficient

Message ID 1507191537.3314.3.camel@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sergey Dyasli Oct. 5, 2017, 8:18 a.m. UTC
On Wed, 2017-10-04 at 15:55 +0100, Andrew Cooper wrote:
> > >  
> > > -void vmx_vmenter_helper(const struct cpu_user_regs *regs)
> > > +int vmx_vmenter_helper(const struct cpu_user_regs *regs)
> > 
> > ...Andy, did you want a comment here explaining what the return value is
> > supposed to mean? (And/or changing this to a bool?)
> 
> Definitely a comment please (especially as it is logically inverted from
> what I would have expected originally).
> 
> Bool depending on whether it actually has boolean properties or not
> (which will depend on how the comment ends up looking).
> 
> ~Andrew

Andrew,

Are you happy with the following fixup?


-- 
Thanks,
Sergey

Comments

Jan Beulich Oct. 5, 2017, 9:27 a.m. UTC | #1
>>> On 05.10.17 at 10:18, <sergey.dyasli@citrix.com> wrote:
> --- a/xen/arch/x86/hvm/vmx/entry.S
> +++ b/xen/arch/x86/hvm/vmx/entry.S
> @@ -80,7 +80,7 @@ UNLIKELY_END(realmode)
>          mov  %rsp,%rdi
>          call vmx_vmenter_helper
>          cmp  $0,%eax
> -        jne .Lvmx_vmentry_restart
> +        je .Lvmx_vmentry_restart

If you make the function return bool, the cmp above also needs
changing (and then preferably to "test %al, %al", in which case
it would then also better be "jz" instead of "je").

Jan
diff mbox

Patch

diff --git a/xen/arch/x86/hvm/vmx/entry.S b/xen/arch/x86/hvm/vmx/entry.S
index 9fb8f89220..24265ebc08 100644
--- a/xen/arch/x86/hvm/vmx/entry.S
+++ b/xen/arch/x86/hvm/vmx/entry.S
@@ -80,7 +80,7 @@  UNLIKELY_END(realmode)
         mov  %rsp,%rdi
         call vmx_vmenter_helper
         cmp  $0,%eax
-        jne .Lvmx_vmentry_restart
+        je .Lvmx_vmentry_restart
         mov  VCPU_hvm_guest_cr2(%rbx),%rax
 
         pop  %r15
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index c9a4111267..d9b35202f9 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -4197,7 +4197,8 @@  static void lbr_fixup(void)
         bdw_erratum_bdf14_fixup();
 }
 
-int vmx_vmenter_helper(const struct cpu_user_regs *regs)
+/* Return false if the vmentry has to be restarted */
+bool vmx_vmenter_helper(const struct cpu_user_regs *regs)
 {
     struct vcpu *curr = current;
     u32 new_asid, old_asid;
@@ -4206,7 +4207,7 @@  int vmx_vmenter_helper(const struct cpu_user_regs *regs)
 
     /* Shadow EPTP can't be updated here because irqs are disabled */
      if ( nestedhvm_vcpu_in_guestmode(curr) && vcpu_nestedhvm(curr).stale_np2m )
-         return 1;
+         return false;
 
     if ( curr->domain->arch.hvm_domain.pi_ops.do_resume )
         curr->domain->arch.hvm_domain.pi_ops.do_resume(curr);
@@ -4269,7 +4270,7 @@  int vmx_vmenter_helper(const struct cpu_user_regs *regs)
     __vmwrite(GUEST_RSP,    regs->rsp);
     __vmwrite(GUEST_RFLAGS, regs->rflags | X86_EFLAGS_MBS);
 
-    return 0;
+    return true;
 }
 
 /*