]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: VMX: Pull GUEST_CR3 from the VMCS iff CR3 load exiting is disabled
authorSean Christopherson <seanjc@google.com>
Tue, 13 Jul 2021 16:33:03 +0000 (09:33 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 2 Aug 2021 15:01:54 +0000 (11:01 -0400)
commit5b733a3c02c03bfc661bb8ea5c83da6143e5656e
tree2a7218f93581316af784420a526241b55ee1a40b
parent6377b579ddbf4966f0f28a17581ab7b86d3f57b9
KVM: VMX: Pull GUEST_CR3 from the VMCS iff CR3 load exiting is disabled

Tweak the logic for grabbing vmcs.GUEST_CR3 in vmx_cache_reg() to look
directly at the execution controls, as opposed to effectively inferring
the controls based on vCPUs.  Inferring the controls isn't wrong, but it
creates a very subtle dependency between the caching logic, the state of
vcpu->arch.cr0 (via is_paging()), and the behavior of vmx_set_cr0().

Using the execution controls doesn't completely eliminate the dependency
in vmx_set_cr0(), e.g. neglecting to cache CR3 before enabling
interception would still break the guest, but it does reduce the
code dependency and mostly eliminate the logical dependency (that CR3
loads are intercepted in certain scenarios).  Eliminating the subtle
read of vcpu->arch.cr0 will also allow for additional cleanup in
vmx_set_cr0().

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210713163324.627647-26-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmx.c