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>
Fri, 25 Mar 2022 17:06:38 +0000 (17:06 +0000)
commitcd48561b55d091205aa32996689c72e3057bbd42
tree86cf2d0c1be2dc7bea0e0623d54f907c53034c32
parent89262602e2d0deab5be5efddd27caa2a813c49ff
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>
(cherry picked from commit e421ed0f68488863599532bda575c03c33cde0e0)
xen/arch/x86/cpu/common.c
xen/arch/x86/traps.c
xen/include/asm-x86/shstk.h [new file with mode: 0644]