Skip to content

Commit bf627a9

Browse files
vittyvkbonzini
authored andcommitted
x86/kvm/mmu: check if MMU reconfiguration is needed in init_kvm_nested_mmu()
We don't use root page role for nested_mmu, however, optimizing out re-initialization in case nothing changed is still valuable as this is done for every nested vmentry. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 7dcd575 commit bf627a9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/x86/kvm/mmu.c

+6
Original file line numberDiff line numberDiff line change
@@ -4936,8 +4936,14 @@ static void init_kvm_softmmu(struct kvm_vcpu *vcpu)
49364936

49374937
static void init_kvm_nested_mmu(struct kvm_vcpu *vcpu)
49384938
{
4939+
union kvm_mmu_role new_role = kvm_calc_mmu_role_common(vcpu, false);
49394940
struct kvm_mmu *g_context = &vcpu->arch.nested_mmu;
49404941

4942+
new_role.base.word &= mmu_base_role_mask.word;
4943+
if (new_role.as_u64 == g_context->mmu_role.as_u64)
4944+
return;
4945+
4946+
g_context->mmu_role.as_u64 = new_role.as_u64;
49414947
g_context->get_cr3 = get_cr3;
49424948
g_context->get_pdptr = kvm_pdptr_read;
49434949
g_context->inject_page_fault = kvm_inject_page_fault;

0 commit comments

Comments
 (0)