Re: [PATCH 06/43] KVM: x86: Properly reset MMU context at vCPU RESET/INIT
From: Reiji Watanabe
Date: Mon May 17 2021 - 12:58:18 EST
> void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
> {
> + unsigned long old_cr0 = kvm_read_cr0(vcpu);
> + unsigned long old_cr4 = kvm_read_cr4(vcpu);
> +
> kvm_lapic_reset(vcpu, init_event);
>
> vcpu->arch.hflags = 0;
> @@ -10483,6 +10485,10 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
> vcpu->arch.ia32_xss = 0;
>
> static_call(kvm_x86_vcpu_reset)(vcpu, init_event);
> +
> + if (kvm_cr0_mmu_role_changed(old_cr0, kvm_read_cr0(vcpu)) ||
> + kvm_cr4_mmu_role_changed(old_cr4, kvm_read_cr4(vcpu)))
> + kvm_mmu_reset_context(vcpu);
> }
I'm wondering if kvm_vcpu_reset() should call kvm_mmu_reset_context()
for a change in EFER.NX as well.
Thanks,
Reiji