]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: nVMX: fix CR3 load if L2 uses PAE paging and EPT
authorLadi Prosek <lprosek@redhat.com>
Wed, 30 Nov 2016 15:03:08 +0000 (16:03 +0100)
committerKrish Sadhukhan <krish.sadhukhan@oracle.com>
Tue, 22 Aug 2017 22:30:27 +0000 (18:30 -0400)
commit0bc76315c6ad8c5e0a87d0c29cbc95b36c1ac932
tree7d377534a8de8d7a66221bafcfa1a4fe6feecb3e
parentaa6a6227435cb06cfba29166b25140a4d46207c6
KVM: nVMX: fix CR3 load if L2 uses PAE paging and EPT

KVM does not correctly handle L1 hypervisors that emulate L2 real mode with
PAE and EPT, such as Hyper-V. In this mode, the L1 hypervisor populates guest
PDPTE VMCS fields and leaves guest CR3 uninitialized because it is not used
(see 26.3.2.4 Loading Page-Directory-Pointer-Table Entries). KVM always
dereferences CR3 and tries to load PDPTEs if PAE is on. This leads to two
related issues:

1) On the first nested vmentry, the guest PDPTEs, as populated by L1, are
overwritten in ept_load_pdptrs because the registers are believed to have
been loaded in load_pdptrs as part of kvm_set_cr3. This is incorrect. L2 is
running with PAE enabled but PDPTRs have been set up by L1.

2) When L2 is about to enable paging and loads its CR3, we, again, attempt
to load PDPTEs in load_pdptrs called from kvm_set_cr3. There are no guarantees
that this will succeed (it's just a CR3 load, paging is not enabled yet) and
if it doesn't, kvm_set_cr3 returns early without persisting the CR3 which is
then lost and L2 crashes right after it enables paging.

This patch replaces the kvm_set_cr3 call with a simple register write if PAE
and EPT are both on. CR3 is not to be interpreted in this case.

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
(cherry picked from commit 7ca29de21362de242025fbc1c22436e19e39dddc)
OraBug: 26628813 KVM: nVMX: fix CR3 load if L2 uses PAE paging and EPT - backport+regression fix
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
Tested-by: Eyal Moscovici <eyal.moscovici@oracle.com>
Tested-by: Chris Kenna <chris.kenna@oracle.com>
Acked-by: Konrad Wilk <konrad.wilk@oracle.com>
arch/x86/kvm/vmx.c