Skip to content

Commit 5092adb

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm fix from Paolo Bonzini: "A simple patch for a pretty bad bug: Unbreak AMD nested virtualization." * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: x86: nSVM: fix switch to guest mmu
2 parents e572fa0 + 3cf85f9 commit 5092adb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/x86/kvm/svm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2937,6 +2937,8 @@ static void nested_svm_inject_npf_exit(struct kvm_vcpu *vcpu,
29372937
static void nested_svm_init_mmu_context(struct kvm_vcpu *vcpu)
29382938
{
29392939
WARN_ON(mmu_is_nested(vcpu));
2940+
2941+
vcpu->arch.mmu = &vcpu->arch.guest_mmu;
29402942
kvm_init_shadow_mmu(vcpu);
29412943
vcpu->arch.mmu->set_cr3 = nested_svm_set_tdp_cr3;
29422944
vcpu->arch.mmu->get_cr3 = nested_svm_get_tdp_cr3;
@@ -2949,6 +2951,7 @@ static void nested_svm_init_mmu_context(struct kvm_vcpu *vcpu)
29492951

29502952
static void nested_svm_uninit_mmu_context(struct kvm_vcpu *vcpu)
29512953
{
2954+
vcpu->arch.mmu = &vcpu->arch.root_mmu;
29522955
vcpu->arch.walk_mmu = &vcpu->arch.root_mmu;
29532956
}
29542957

@@ -3458,7 +3461,6 @@ static void enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb_gpa,
34583461
svm->vcpu.arch.hflags &= ~HF_HIF_MASK;
34593462

34603463
if (nested_vmcb->control.nested_ctl & SVM_NESTED_CTL_NP_ENABLE) {
3461-
kvm_mmu_unload(&svm->vcpu);
34623464
svm->nested.nested_cr3 = nested_vmcb->control.nested_cr3;
34633465
nested_svm_init_mmu_context(&svm->vcpu);
34643466
}

0 commit comments

Comments
 (0)