x86/livepatch: Make livepatching compatible with CET Shadow Stacks
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 8 Jun 2020 17:47:58 +0000 (18:47 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 26 Jun 2020 15:34:02 +0000 (16:34 +0100)
commit92167e9430c010df410336f2b68cc4e30b7872d9
tree718e3ca14de66428c7671adc804a95b7d8edc25b
parentbcdfbb70fca579baa04f212c0936b77919bdae11
x86/livepatch: Make livepatching compatible with CET Shadow Stacks

Just like the alternatives infrastructure, the livepatch infrastructure
disables CR0.WP to perform patching, which is not permitted with CET active.

Modify arch_livepatch_{quiesce,revive}() to disable CET before disabling WP,
and reset the dirty bits on all virtual regions before re-enabling CET.

One complication is that arch_livepatch_revive() has to fix up the top of the
shadow stack.  This depends on the functions not being inlined, even under
LTO.  Another limitation is that reset_virtual_region_perms() may shatter the
final superpage of .text depending on alignment.

This logic, and its downsides, are temporary until the patching infrastructure
can be adjusted to not use CR0.WP.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Release-acked-by: Paul Durrant <paul@xen.org>
xen/arch/x86/livepatch.c
xen/common/virtual_region.c
xen/include/xen/virtual_region.h