x86/cet: Clear IST supervisor token busy bits on S3 resume
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 14 Mar 2022 10:30:46 +0000 (10:30 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 17 Mar 2022 20:34:06 +0000 (20:34 +0000)
commite421ed0f68488863599532bda575c03c33cde0e0
treee2e44299a127ee1db8fe12fb85812380a1ec705f
parent7b41b91fd2ecbf87b91120b468689e10296b656c
x86/cet: Clear IST supervisor token busy bits on S3 resume

Stacks are not freed across S3.  Execution just stops, leaving supervisor
token busy bits active.  Fixing this for the primary shadow stack was done
previously, but there is a (rare) risk that an IST token is left busy too, if
the platform power-off happens to intersect with an NMI/#MC arriving.  This
will manifest as #DF next time the IST vector gets used.

Introduce rdssp() and wrss() helpers in a new shstk.h, cleaning up
fixup_exception_return() and explaining the trick with the literal 1.

Then this infrastructure to rewrite the IST tokens in load_system_tables()
when all the other IST details are being set up.  In the case that an IST
token were left busy across S3, this will clear the busy bit before the stack
gets used.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpu/common.c
xen/arch/x86/include/asm/shstk.h [new file with mode: 0644]
xen/arch/x86/traps.c