From: Jan Kiszka <jan.kis...@siemens.com>

If nested EPT is enabled, the L2 guest may change CR3 without any exits.
We therefore have to read the current value from the VMCS when switching
to L1. However, if paging wasn't enabled, L0 tracks L2's CR3, and
GUEST_CR3 rather contains the real-mode identity map. So we need to
retrieve CR3 from the architectural state after conditionally updating
it - and this is what kvm_read_cr3 does.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>
---
 arch/x86/kvm/vmx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 22f396f..d0e1d5f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -8097,7 +8097,7 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct 
vmcs12 *vmcs12)
         * Additionally, restore L2's PDPTR to vmcs12.
         */
        if (enable_ept) {
-               vmcs12->guest_cr3 = vmcs_read64(GUEST_CR3);
+               vmcs12->guest_cr3 = kvm_read_cr3(vcpu);
                vmcs12->guest_pdptr0 = vmcs_read64(GUEST_PDPTR0);
                vmcs12->guest_pdptr1 = vmcs_read64(GUEST_PDPTR1);
                vmcs12->guest_pdptr2 = vmcs_read64(GUEST_PDPTR2);
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to