From b7572954da0e09d5289609db0b126c0944593dbd Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Mon, 26 May 2025 18:48:26 +0100 Subject: [PATCH] x86/traps: Alter switch_stack_and_jump() for FRED mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FRED and IDT differ by a Supervisor Token on the base of the shadow stack. This means that switch_stack_and_jump() needs to discard one extra word when FRED is active. Fix a typo in the parameter name, which should be shstk_base. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Reviewed-by: Roger Pau Monné (cherry picked from commit 40fbf971771a5c7c973818edbd0be7b50f0eb364) --- xen/arch/x86/include/asm/current.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/include/asm/current.h b/xen/arch/x86/include/asm/current.h index c1eb27b1c4..62817e8476 100644 --- a/xen/arch/x86/include/asm/current.h +++ b/xen/arch/x86/include/asm/current.h @@ -154,7 +154,9 @@ unsigned long get_stack_dump_bottom (unsigned long sp); "rdsspd %[ssp];" \ "cmp $1, %[ssp];" \ "je .L_shstk_done.%=;" /* CET not active? Skip. */ \ - "mov $%c[skstk_base], %[val];" \ + ALTERNATIVE("mov $%c[shstk_base], %[val];", \ + "mov $%c[shstk_base] + 8, %[val];", \ + X86_FEATURE_XEN_FRED) \ "and $%c[stack_mask], %[ssp];" \ "sub %[ssp], %[val];" \ "shr $3, %[val];" \ @@ -188,7 +190,7 @@ unsigned long get_stack_dump_bottom (unsigned long sp); [ssp] "=&r" (tmp) \ : [stk] "r" (guest_cpu_user_regs()), \ [fun] constr (fn), \ - [skstk_base] "i" \ + [shstk_base] "i" \ ((PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8), \ [stack_mask] "i" (STACK_SIZE - 1), \ _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, \