x86/shstk: Fix use of shadow stacks with XPTI active
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 1 Nov 2021 20:45:26 +0000 (20:45 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 3 Nov 2021 13:08:42 +0000 (13:08 +0000)
commitb2851580b1f2ff121737a37cb25a370d7692ae3b
tree858bbf61b6a3b4e166f9df2b0e8bf48c85dec020
parentce309942c791628ff42082d1b74bfaeaa5267ae0
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>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
xen/arch/x86/setup.c
xen/arch/x86/smpboot.c
xen/include/xen/smp.h