|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v5 1/4] x86: record SSP at non-guest 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(). 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 <jbeulich@xxxxxxxx>
---
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
.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
--- 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; };
--- 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();
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |