diff options
-rw-r--r-- | arch/x86/kvm/paging_tmpl.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index d9dea288e51..5910557b3f3 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h | |||
@@ -572,12 +572,15 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) | |||
572 | { | 572 | { |
573 | int i, offset, nr_present; | 573 | int i, offset, nr_present; |
574 | bool reset_host_protection; | 574 | bool reset_host_protection; |
575 | gpa_t first_pte_gpa; | ||
575 | 576 | ||
576 | offset = nr_present = 0; | 577 | offset = nr_present = 0; |
577 | 578 | ||
578 | if (PTTYPE == 32) | 579 | if (PTTYPE == 32) |
579 | offset = sp->role.quadrant << PT64_LEVEL_BITS; | 580 | offset = sp->role.quadrant << PT64_LEVEL_BITS; |
580 | 581 | ||
582 | first_pte_gpa = gfn_to_gpa(sp->gfn) + offset * sizeof(pt_element_t); | ||
583 | |||
581 | for (i = 0; i < PT64_ENT_PER_PAGE; i++) { | 584 | for (i = 0; i < PT64_ENT_PER_PAGE; i++) { |
582 | unsigned pte_access; | 585 | unsigned pte_access; |
583 | pt_element_t gpte; | 586 | pt_element_t gpte; |
@@ -587,8 +590,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) | |||
587 | if (!is_shadow_present_pte(sp->spt[i])) | 590 | if (!is_shadow_present_pte(sp->spt[i])) |
588 | continue; | 591 | continue; |
589 | 592 | ||
590 | pte_gpa = gfn_to_gpa(sp->gfn); | 593 | pte_gpa = first_pte_gpa + i * sizeof(pt_element_t); |
591 | pte_gpa += (i+offset) * sizeof(pt_element_t); | ||
592 | 594 | ||
593 | if (kvm_read_guest_atomic(vcpu->kvm, pte_gpa, &gpte, | 595 | if (kvm_read_guest_atomic(vcpu->kvm, pte_gpa, &gpte, |
594 | sizeof(pt_element_t))) | 596 | sizeof(pt_element_t))) |