On 08/07/20 11:36, Vitaly Kuznetsov wrote: > @@ -4973,7 +4969,28 @@ void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, u32 cr0, u32 cr4, u32 efer) > context->mmu_role.as_u64 = new_role.as_u64; > reset_shadow_zero_bits_mask(vcpu, context); > } > -EXPORT_SYMBOL_GPL(kvm_init_shadow_mmu); > + > +static void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, u32 cr0, u32 cr4, u32 efer) > +{ > + struct kvm_mmu *context = vcpu->arch.mmu; > + union kvm_mmu_role new_role = > + kvm_calc_shadow_mmu_root_page_role(vcpu, false); > + > + if (new_role.as_u64 != context->mmu_role.as_u64) > + shadow_mmu_init_context(vcpu, cr0, cr4, efer, new_role); > +} > + > +void kvm_init_shadow_npt_mmu(struct kvm_vcpu *vcpu, u32 cr0, u32 cr4, u32 efer, > + gpa_t nested_cr3) > +{ > + struct kvm_mmu *context = vcpu->arch.mmu; > + union kvm_mmu_role new_role = > + kvm_calc_shadow_mmu_root_page_role(vcpu, false); > + > + if (new_role.as_u64 != context->mmu_role.as_u64) > + shadow_mmu_init_context(vcpu, cr0, cr4, efer, new_role); > +} > +EXPORT_SYMBOL_GPL(kvm_init_shadow_npt_mmu); > > static union kvm_mmu_role As a follow up, the assignments to context should stop using vcpu->arch.mmu in favor of root_mmu/guest_mmu. Paolo