Skip to content

Commit

Permalink
KVM: X86: Update mmu->pdptrs only when it is changed
Browse files Browse the repository at this point in the history
It is unchanged in most cases.

Signed-off-by: Lai Jiangshan <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Lai Jiangshan authored and bonzini committed Dec 8, 2021
1 parent 2e9ebd5 commit 24cd19a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,12 @@ int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3)
}
}

memcpy(mmu->pdptrs, pdpte, sizeof(mmu->pdptrs));
kvm_register_mark_dirty(vcpu, VCPU_EXREG_PDPTR);
kvm_make_request(KVM_REQ_LOAD_MMU_PGD, vcpu);
kvm_register_mark_available(vcpu, VCPU_EXREG_PDPTR);
if (memcmp(mmu->pdptrs, pdpte, sizeof(mmu->pdptrs))) {
memcpy(mmu->pdptrs, pdpte, sizeof(mmu->pdptrs));
kvm_register_mark_dirty(vcpu, VCPU_EXREG_PDPTR);
kvm_make_request(KVM_REQ_LOAD_MMU_PGD, vcpu);
}
vcpu->arch.pdptrs_from_userspace = false;

return 1;
Expand Down

0 comments on commit 24cd19a

Please sign in to comment.