Commit 51fb60d8 authored by Gui Jianfeng's avatar Gui Jianfeng Committed by Avi Kivity

KVM: MMU: Move sync_page() first pte address calculation out of loop

Move first pte address calculation out of loop to save some cycles.
Signed-off-by: default avatarGui Jianfeng <guijianfeng@cn.fujitsu.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 66cbff59
...@@ -572,12 +572,15 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) ...@@ -572,12 +572,15 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
{ {
int i, offset, nr_present; int i, offset, nr_present;
bool reset_host_protection; bool reset_host_protection;
gpa_t first_pte_gpa;
offset = nr_present = 0; offset = nr_present = 0;
if (PTTYPE == 32) if (PTTYPE == 32)
offset = sp->role.quadrant << PT64_LEVEL_BITS; offset = sp->role.quadrant << PT64_LEVEL_BITS;
first_pte_gpa = gfn_to_gpa(sp->gfn) + offset * sizeof(pt_element_t);
for (i = 0; i < PT64_ENT_PER_PAGE; i++) { for (i = 0; i < PT64_ENT_PER_PAGE; i++) {
unsigned pte_access; unsigned pte_access;
pt_element_t gpte; pt_element_t gpte;
...@@ -587,8 +590,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) ...@@ -587,8 +590,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
if (!is_shadow_present_pte(sp->spt[i])) if (!is_shadow_present_pte(sp->spt[i]))
continue; continue;
pte_gpa = gfn_to_gpa(sp->gfn); pte_gpa = first_pte_gpa + i * sizeof(pt_element_t);
pte_gpa += (i+offset) * sizeof(pt_element_t);
if (kvm_read_guest_atomic(vcpu->kvm, pte_gpa, &gpte, if (kvm_read_guest_atomic(vcpu->kvm, pte_gpa, &gpte,
sizeof(pt_element_t))) sizeof(pt_element_t)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment