Merge tag 'kvm-x86-mmu-6.4' of https://github.com/kvm-x86/linux into HEAD
[platform/kernel/linux-rpi.git] / arch / x86 / kvm / mmu / mmu.c
index a7adbac..e3d02f0 100644 (file)
@@ -5182,6 +5182,21 @@ static union kvm_cpu_role kvm_calc_cpu_role(struct kvm_vcpu *vcpu,
        return role;
 }
 
+void __kvm_mmu_refresh_passthrough_bits(struct kvm_vcpu *vcpu,
+                                       struct kvm_mmu *mmu)
+{
+       const bool cr0_wp = kvm_is_cr0_bit_set(vcpu, X86_CR0_WP);
+
+       BUILD_BUG_ON((KVM_MMU_CR0_ROLE_BITS & KVM_POSSIBLE_CR0_GUEST_BITS) != X86_CR0_WP);
+       BUILD_BUG_ON((KVM_MMU_CR4_ROLE_BITS & KVM_POSSIBLE_CR4_GUEST_BITS));
+
+       if (is_cr0_wp(mmu) == cr0_wp)
+               return;
+
+       mmu->cpu_role.base.cr0_wp = cr0_wp;
+       reset_guest_paging_metadata(vcpu, mmu);
+}
+
 static inline int kvm_mmu_get_tdp_level(struct kvm_vcpu *vcpu)
 {
        /* tdp_root_level is architecture forced level, use it if nonzero */