x86/livepatch: Prevent patching with active waitqueues
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 5 Nov 2019 19:08:14 +0000 (19:08 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 22 Nov 2019 17:05:43 +0000 (17:05 +0000)
commitca4cd3668237d50a0b33b48e7de7f93d9475120d
tree3890c3f856f8b3dc79943ac8f5c92943418f6155
parentd7cd999faa1edf745a7597db811956cb882a5436
x86/livepatch: Prevent patching with active waitqueues

The safety of livepatching depends on every stack having been unwound, but
there is one corner case where this is not true.  The Sharing/Paging/Monitor
infrastructure may use waitqueues, which copy the stack frame sideways and
longjmp() to a different vcpu.

This case is rare, and can be worked around by pausing the offending
domain(s), waiting for their rings to drain, then performing a livepatch.

In the case that there is an active waitqueue, fail the livepatch attempt with
-EBUSY, which is preforable to the fireworks which occur from trying to unwind
the old stack frame at a later point.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/arch/arm/livepatch.c
xen/arch/x86/livepatch.c
xen/common/livepatch.c
xen/include/xen/livepatch.h