x86/shstk: Fix use of shadow stacks with XPTI active
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 19 Nov 2021 08:39:46 +0000 (09:39 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 19 Nov 2021 08:39:46 +0000 (09:39 +0100)
commit2b8381087593c3df274baa94fadbe2b89cd28158
tree39a88e289c02a672423315eb4f4b4bd05fcfe386
parentc3f25903696412b8847619ccd5e51886106b70ad
x86/shstk: Fix use of shadow stacks with XPTI active

The call to setup_cpu_root_pgt(0) in smp_prepare_cpus() is too early.  It
clones the BSP's stack while the .data mapping is still in use, causing all
mappings to be fully read read/write (and with no guard pages either).  This
ultimately causes #DF when trying to enter the dom0 kernel for the first time.

Defer setting up BSPs XPTI pagetable until reinit_bsp_stack() after we've set
up proper shadow stack permissions.

Fixes: 60016604739b ("x86/shstk: Rework the stack layout to support shadow stacks")
Fixes: b60ab42db2f0 ("x86/shstk: Activate Supervisor Shadow Stacks")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: b2851580b1f2ff121737a37cb25a370d7692ae3b
master date: 2021-11-03 13:08:42 +0000
xen/arch/x86/setup.c
xen/arch/x86/smpboot.c
xen/include/xen/smp.h