It can be used as-is for VMX. For SVM the special treatment of %rax needs
accounting for.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
This is the minimum required as a prereq to the next patch (to avoid the
need for custom adjustments in the two places). We could go further and
switch to using PUSH_AND_CLEAR_GPRS at the same time.
---
v3: New.
--- 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 */
--- 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. */
--- 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
On 02/07/2026 11:55 am, Jan Beulich wrote: > It can be used as-is for VMX. For SVM the special treatment of %rax needs > accounting for. > > Signed-off-by: Jan Beulich <jbeulich@suse.com> > --- > This is the minimum required as a prereq to the next patch (to avoid the > need for custom adjustments in the two places). We could go further and > switch to using PUSH_AND_CLEAR_GPRS at the same time. I've got several part-series that result in purging SAVE_ALL/RESTORE_ALL. If you want to put this patch in, then Acked-by: Andrew Cooper <andrew.cooper3@citrix.com> but I firmly want to finish my series before patch 2 adds yet-more complexity to macros which I'm wanting to remove for being too complicated already.
On 02.07.2026 13:31, Andrew Cooper wrote: > On 02/07/2026 11:55 am, Jan Beulich wrote: >> It can be used as-is for VMX. For SVM the special treatment of %rax needs >> accounting for. >> >> Signed-off-by: Jan Beulich <jbeulich@suse.com> >> --- >> This is the minimum required as a prereq to the next patch (to avoid the >> need for custom adjustments in the two places). We could go further and >> switch to using PUSH_AND_CLEAR_GPRS at the same time. > > I've got several part-series that result in purging SAVE_ALL/RESTORE_ALL. > > If you want to put this patch in, then Acked-by: Andrew Cooper > <andrew.cooper3@citrix.com> Thanks. Yes, I think I'll put it in as one small piece in the move. > but I firmly want to finish my series before > patch 2 adds yet-more complexity to macros which I'm wanting to remove > for being too complicated already. Well, if you make this a strict prereq, then I might as well make one or more patches myself to replace at least the SAVE_ALL the next patch needs to fiddle with. Or else I'd like to understand when you expect your work to arrive, as this series imo is one of those which have already been blocked for far too long. Jan
On 02/07/2026 2:18 pm, Jan Beulich wrote: > On 02.07.2026 13:31, Andrew Cooper wrote: >> On 02/07/2026 11:55 am, Jan Beulich wrote: >>> It can be used as-is for VMX. For SVM the special treatment of %rax needs >>> accounting for. >>> >>> Signed-off-by: Jan Beulich <jbeulich@suse.com> >>> --- >>> This is the minimum required as a prereq to the next patch (to avoid the >>> need for custom adjustments in the two places). We could go further and >>> switch to using PUSH_AND_CLEAR_GPRS at the same time. >> I've got several part-series that result in purging SAVE_ALL/RESTORE_ALL. >> >> If you want to put this patch in, then Acked-by: Andrew Cooper >> <andrew.cooper3@citrix.com> > Thanks. Yes, I think I'll put it in as one small piece in the move. > >> but I firmly want to finish my series before >> patch 2 adds yet-more complexity to macros which I'm wanting to remove >> for being too complicated already. > Well, if you make this a strict prereq, then I might as well make one or > more patches myself to replace at least the SAVE_ALL the next patch needs > to fiddle with. Or else I'd like to understand when you expect your work > to arrive, as this series imo is one of those which have already been > blocked for far too long. Get this patch committed, which will resolve the skip_rax issue holding up my last attempt to make progress here. I'll then rebase and try to collect everything together. ~Andrew
© 2016 - 2026 Red Hat, Inc.