x86/vmx: Properly flush the TLB when an altp2m is modified
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 11 Feb 2019 13:31:02 +0000 (13:31 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 28 Feb 2019 11:16:27 +0000 (11:16 +0000)
commit69f7643df68ef8e994221a996e336a47cbb7bbc8
treea2ab0903da9945a119ac4dcb56bd2bdab003932c
parent0ec9b4ef3148e052bd8adf83800d7d681571f49e
x86/vmx: Properly flush the TLB when an altp2m is modified

Modifications to an altp2m mark the p2m as needing flushing, but this was
never wired up in the return-to-guest path.  As a result, stale TLB entries
can remain after resuming the guest.

In practice, this manifests as a missing EPT_VIOLATION or #VE exception when
the guest subsequently accesses a page which has had its permissions reduced.

vmx_vmenter_helper() now has 11 p2ms to potentially invalidate, but issuing 11
INVEPT instructions isn't clever.  Instead, count how many contexts need
invalidating, and use INVEPT_ALL_CONTEXT if two or more are in need of
flushing.

This doesn't have an XSA because altp2m is not yet a security-supported
feature.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/hvm/vmx/vmx.c