[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/HVM: don't (almost) open-code POP_GPRS



commit e58a8e0889b872723ca6720cffb1e15e8e17fc85
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Jul 6 09:42:46 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jul 6 09:42:46 2026 +0200

    x86/HVM: don't (almost) open-code POP_GPRS
    
    It can be used as-is for VMX. For SVM the special treatment of %rax needs
    accounting for.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/hvm/svm/entry.S         | 16 +---------------
 xen/arch/x86/hvm/vmx/entry.S         | 16 +---------------
 xen/arch/x86/include/asm/asm_defns.h |  6 +++++-
 3 files changed, 7 insertions(+), 31 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/entry.S b/xen/arch/x86/hvm/svm/entry.S
index af8db23b03..b6ea699bb9 100644
--- a/xen/arch/x86/hvm/svm/entry.S
+++ b/xen/arch/x86/hvm/svm/entry.S
@@ -82,22 +82,8 @@ __UNLIKELY_END(nsvm_hap)
          */
         sti
 
-        pop  %r15
-        pop  %r14
-        pop  %r13
-        pop  %r12
-        pop  %rbp
         mov  VCPU_svm_vmcb_pa(%rbx),%rax
-        pop  %rbx
-        pop  %r11
-        pop  %r10
-        pop  %r9
-        pop  %r8
-        pop  %rcx /* Skip %rax: restored by VMRUN. */
-        pop  %rcx
-        pop  %rdx
-        pop  %rsi
-        pop  %rdi
+        POP_GPRS skip_rax=1 /* %rax restored by VMRUN. */
 
         SPEC_CTRL_COND_VERW     /* Req: %rsp=eframe                    Clob: 
efl */
 
diff --git a/xen/arch/x86/hvm/vmx/entry.S b/xen/arch/x86/hvm/vmx/entry.S
index 2bfee715b3..c34f5a1ee0 100644
--- a/xen/arch/x86/hvm/vmx/entry.S
+++ b/xen/arch/x86/hvm/vmx/entry.S
@@ -139,21 +139,7 @@ UNLIKELY_END(realmode)
         and  $SCF_verw, %eax
         or   %eax, %ecx
 
-        pop  %r15
-        pop  %r14
-        pop  %r13
-        pop  %r12
-        pop  %rbp
-        pop  %rbx
-        pop  %r11
-        pop  %r10
-        pop  %r9
-        pop  %r8
-        pop  %rax
-        pop  %rcx
-        pop  %rdx
-        pop  %rsi
-        pop  %rdi
+        POP_GPRS /* Preserves flags. */
 
         jpe  .L_skip_verw
         /* VERW clobbers ZF, but preserves all others, including SF. */
diff --git a/xen/arch/x86/include/asm/asm_defns.h 
b/xen/arch/x86/include/asm/asm_defns.h
index 0dd63270fc..87bd6b1193 100644
--- a/xen/arch/x86/include/asm/asm_defns.h
+++ b/xen/arch/x86/include/asm/asm_defns.h
@@ -357,7 +357,7 @@ static always_inline void stac(void)
 /*
  * POP GPRs from a UREGS_* frame on the stack.  Does not modify flags.
  */
-.macro POP_GPRS
+.macro POP_GPRS skip_rax=0
         pop   %r15
         pop   %r14
         pop   %r13
@@ -368,7 +368,11 @@ static always_inline void stac(void)
         pop   %r10
         pop   %r9
         pop   %r8
+ .if \skip_rax
+        pop   %rcx
+ .else
         pop   %rax
+ .endif
         pop   %rcx
         pop   %rdx
         pop   %rsi
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.