[PATCH 1/3] x86/hvm: Use PUSH_AND_CLEAR_GPRS in preference to SAVE_ALL

Andrew Cooper posted 3 patches 1 month, 2 weeks ago
[PATCH 1/3] x86/hvm: Use PUSH_AND_CLEAR_GPRS in preference to SAVE_ALL
Posted by Andrew Cooper 1 month, 2 weeks ago
SAVE_ALL hides a CLD instruction which is not needed anywhere here.

 * VMX VMExit always clears flags.  VMX VMentry failure never switched away
   from the host flags, so they're still good.
 * SVM VMRUN always saves and restores the host flags.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <jbeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Teddy Astie <teddy.astie@vates.tech>

Bloat-o-meter reports:
  add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-168 (-168)
  Function                                     old     new   delta
  svm_asm_do_resume                            416     360     -56
  vmx_asm_vmexit_handler                       576     464    -112
---
 xen/arch/x86/hvm/svm/entry.S | 2 +-
 xen/arch/x86/hvm/vmx/entry.S | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/entry.S b/xen/arch/x86/hvm/svm/entry.S
index b6ea699bb9c0..d9613a2a8fed 100644
--- a/xen/arch/x86/hvm/svm/entry.S
+++ b/xen/arch/x86/hvm/svm/entry.S
@@ -89,7 +89,7 @@ __UNLIKELY_END(nsvm_hap)
 
         vmrun
 
-        SAVE_ALL
+        PUSH_AND_CLEAR_GPRS
 
         GET_CURRENT(bx)
 
diff --git a/xen/arch/x86/hvm/vmx/entry.S b/xen/arch/x86/hvm/vmx/entry.S
index c34f5a1ee0af..cebc70064048 100644
--- a/xen/arch/x86/hvm/vmx/entry.S
+++ b/xen/arch/x86/hvm/vmx/entry.S
@@ -22,7 +22,7 @@
 #include <asm/page.h>
 
 FUNC(vmx_asm_vmexit_handler)
-        SAVE_ALL
+        PUSH_AND_CLEAR_GPRS
 
         mov  %cr2,%rax
         GET_CURRENT(bx)
@@ -157,7 +157,7 @@ UNLIKELY_END(realmode)
 
 .Lvmx_vmentry_fail:
         sti
-        SAVE_ALL
+        PUSH_AND_CLEAR_GPRS
 
         /*
          * SPEC_CTRL_ENTRY notes
-- 
2.39.5


Re: [PATCH 1/3] x86/hvm: Use PUSH_AND_CLEAR_GPRS in preference to SAVE_ALL
Posted by Jan Beulich 1 month, 1 week ago
On 06.07.2026 17:34, Andrew Cooper wrote:
> SAVE_ALL hides a CLD instruction which is not needed anywhere here.
> 
>  * VMX VMExit always clears flags.  VMX VMentry failure never switched away
>    from the host flags, so they're still good.
>  * SVM VMRUN always saves and restores the host flags.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>