On 09/11/2026 1:08 pm, Jan Beulich wrote: > We will want to use that value for call trace generation, and likely > also to eliminate the somewhat fragile shadow stack searching done in > fixup_exception_return(). For those purposes, guest-only entry points do > not need to record that value. > > To keep the saving code simple, record our own SSP that corresponds to > an exception frame, pointing to the top of the shadow stack counterpart > of what the CPU has saved on the regular stack. Consuming code can then > work its way from there. > > In SAVE_ALL / RESTORE_ALL simply drop the use of UREGS_r15. We want the > full size in all cases, so what exactly the top-of-stack field is going > to be (whose UREGS_* is 0 anyway) doesn't matter this much there. This > way we don't need to distinguish between XEN_SHSTK=y and XEN_SHSTK=n. > > Signed-off-by: Jan Beulich <[email protected]>
The code is now fine, but the commit message is quite stale. You need to drop "non-guest" in at least two places, and change SAVE_ALL/RESTORE_ALL. In fact that whole final paragraph can go. With the commit message suitably adjusted, Reviewed-by: Andrew Cooper <[email protected]> > --- > v5: Drop ssp parameter of PUSH_AND_CLEAR_GPRS again. > v4: Re-base. > v3: Put new field at the front of struct cpu_user_regs. > v2: Add comment ahead of SAVE_ALL. Add comma between its parameters. > Re-base. > > --- a/xen/arch/x86/include/asm/asm_defns.h > +++ b/xen/arch/x86/include/asm/asm_defns.h > @@ -259,12 +259,19 @@ static always_inline void stac(void) > xor %r14d, %r14d > push %r15 > xor %r15d, %r15d > +#ifdef CONFIG_XEN_SHSTK > + rdsspq %rcx > + push %rcx > +#endif It might be worth having /* Zero (from above) if CET-SS is not enabled */ on the push here to make it clear what value is stored. ~Andrew
