|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86: record SSP at entry points
commit 8558ddc90e35d251ec2cadf458bcfe33e4499a19
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Nov 10 09:47:22 2026 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Nov 10 09:47:22 2026 +0100
x86: record SSP at entry points
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(). While for those purposes guest-only entry points
wouldn't need to record that value, do so uniformly at all entry points
for simplicity.
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.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
xen/arch/x86/include/asm/asm_defns.h | 7 +++++++
xen/arch/x86/include/asm/cpu-user-regs.h | 9 +++++++++
xen/arch/x86/x86_64/asm-offsets.c | 3 +++
3 files changed, 19 insertions(+)
diff --git a/xen/arch/x86/include/asm/asm_defns.h
b/xen/arch/x86/include/asm/asm_defns.h
index 6c65acd083..000d74dc4f 100644
--- 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 /* Zero (from above) if CET-SS is not enabled */
+#endif
.endm
/*
* POP GPRs from a UREGS_* frame on the stack. Does not modify flags.
*/
.macro POP_GPRS skip_rax=0
+#ifdef CONFIG_XEN_SHSTK
+ pop %rcx
+#endif
pop %r15
pop %r14
pop %r13
diff --git a/xen/arch/x86/include/asm/cpu-user-regs.h
b/xen/arch/x86/include/asm/cpu-user-regs.h
index 92aeca0aaa..c82b783f9a 100644
--- a/xen/arch/x86/include/asm/cpu-user-regs.h
+++ b/xen/arch/x86/include/asm/cpu-user-regs.h
@@ -11,6 +11,15 @@
*/
struct cpu_user_regs
{
+#ifdef CONFIG_XEN_SHSTK
+ /*
+ * This points _at_ the corresponding shadow stack frame; it is _not_ the
+ * outer context's SSP. That, if the outer context has CET-SS enabled,
+ * is stored in the top slot of the pointed to shadow stack.
+ */
+ uint64_t entry_ssp;
+#endif
+
union { uint64_t r15; uint32_t r15d; uint16_t r15w; uint8_t r15b; };
union { uint64_t r14; uint32_t r14d; uint16_t r14w; uint8_t r14b; };
union { uint64_t r13; uint32_t r13d; uint16_t r13w; uint8_t r13b; };
diff --git a/xen/arch/x86/x86_64/asm-offsets.c
b/xen/arch/x86/x86_64/asm-offsets.c
index ce5e7aae16..613d65d1db 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -57,6 +57,9 @@ void __dummy__(void)
OFFSET(UREGS_eflags, struct cpu_user_regs, rflags);
OFFSET(UREGS_rsp, struct cpu_user_regs, rsp);
OFFSET(UREGS_ss, struct cpu_user_regs, ss);
+#ifdef CONFIG_XEN_SHSTK
+ OFFSET(UREGS_entry_ssp, struct cpu_user_regs, entry_ssp);
+#endif
DEFINE(UREGS_kernel_sizeof, sizeof(struct cpu_user_regs));
BLANK();
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |