x86: Fix check_ist_exit() assertions
PATCH 1/1 x86: Fix check_ist_exit() assertions
The patch adding check_ist_exit() neglected to consider reset_stack_and_jump() leaving C and entering one of the Xen exit paths. The value in %r12 is stale, and depending on compiler decisions may not be 0.
This shows up in Gitlab CI for the Clang build:
https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/5112783827
and in OSSTest for GCC 8:
The justification for ensuring ist_exit is accurate in the exit paths still stands, so zero %r12 in reset_stack_and_jump() to indicate a non-IST exit.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/include/asm/current.h | 1 + 1 file changed, 1 insertion(+)
xen/arch/x86/include/asm/current.h +1 -0
@@ -178,6 +178,7 @@ unsigned long get_stack_dump_bottom (unsigned long sp);SHADOW_STACK_WORK \"mov %[stk], %%rsp;" \CHECK_FOR_LIVEPATCH_WORK \ +"xor %%r12d, %%r12d;" /* non-IST exit */ \ instr"[fun]" \ : [val] "=&r" (tmp), \[ssp] " =&r" (tmp) \
base-commit: ea36ac0de27c2a7c847a2a52c3e0f97a45864d81
Signature · 1 line
2.30.2
Quoted 6 lines · Andrew Cooper
The patch adding
check_ist_exit()neglected to considerreset_stack_and_jump()leaving C and entering one of the Xen exit paths. The value in %r12 is stale, and depending on compiler decisions may not be 0.This shows up in Gitlab CI for the Clang build:
Quoted 8 lines
https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/5112783827
and in OSSTest for GCC 8:
The justification for ensuring
ist_exitis accurate in the exit paths still stands, so zero %r12 inreset_stack_and_jump()to indicate a non-IST exit.
I did think of this as an option, but I don't think this covers all cases. If we take #DB while in a PV guest, that'll be an IST entry. Assume further that we re-schedule before re-entering the guest. Upon the vCPU being scheduled back in we'll have %r12 clear with an on-stack indication of having taken an IST guest exit.
Jan
Quoted 13 lines · Jan Beulich
Quoted 12 lines · Andrew Cooper
The patch adding
check_ist_exit()neglected to considerreset_stack_and_jump()leaving C and entering one of the Xen exit paths. The value in %r12 is stale, and depending on compiler decisions may not be 0.This shows up in Gitlab CI for the Clang build:
https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/5112783827
and in OSSTest for GCC 8:
Quoted 7 lines
Quoted 2 lines
The justification for ensuring
ist_exitis accurate in the exit paths still stands, so zero %r12 inreset_stack_and_jump()to indicate a non-IST exit.I did think of this as an option, but I don't think this covers all cases. If we take #DB while in a PV guest, that'll be an IST entry. Assume further that we re-schedule before re-entering the guest. Upon the vCPU being scheduled back in we'll have %r12 clear with an on-stack indication of having taken an IST guest exit.
This is nasty, and we would easily have that behaviour if e.g. GDBSX was attached to the vCPU in question.
In that case, technically it's the other scheduled vCPU which is undergoing the ist_exit, but regs->entry_vector will be different and invalidate the check.
I guess for now I'll have to relent on checking on the exit-to-guest paths. I don't see any other feasible option.
~Andrew