x86/boot: Fix load_system_tables() to be NMI/#MC-safe
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 27 May 2020 12:48:45 +0000 (13:48 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 27 May 2020 15:44:04 +0000 (16:44 +0100)
commit9f3e9139fa6c3d620eb08dff927518fc88200b8d
tree505e5acbd019ef428475b91ea8be2a7fffd8f530
parentb66e28226dd9df8a28101438f44c0a26d63b76fa
x86/boot: Fix load_system_tables() to be NMI/#MC-safe

During boot, load_system_tables() is used in reinit_bsp_stack() to switch the
virtual addresses used from their .data/.bss alias, to their directmap alias.

The structure assignment is implemented as a memset() to zero first, then a
copy-in of the new data.  This causes the NMI/#MC stack pointers to
transiently become 0, at a point where we may have an NMI watchdog running.

Rewrite the logic using a volatile tss pointer (equivalent to, but more
readable than, using ACCESS_ONCE() for all writes).

This does drop the zeroing side effect for holes in the structure, but the
backing memory for the TSS is fully zeroed anyway, and architecturally, they
are all reserved.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpu/common.c