Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: PPC: Book3S HV: Fix bug causing loss of page dirty state

This fixes a bug where adding a new guest HPT entry via the H_ENTER
hcall would lose the "changed" bit in the reverse map information
for the guest physical page being mapped. The result was that the
KVM_GET_DIRTY_LOG could return a zero bit for the page even though
the page had been modified by the guest.

This fixes it by only modifying the index and present bits in the
reverse map entry, thus preserving the reference and change bits.
We were also unnecessarily setting the reference bit, and this
fixes that too.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

authored by

Paul Mackerras and committed by
Alexander Graf
4879f241 7ed661bf

+3 -3
+3 -3
arch/powerpc/kvm/book3s_hv_rm_mmu.c
··· 59 59 head->back = pte_index; 60 60 } else { 61 61 rev->forw = rev->back = pte_index; 62 - i = pte_index; 62 + *rmap = (*rmap & ~KVMPPC_RMAP_INDEX) | 63 + pte_index | KVMPPC_RMAP_PRESENT; 63 64 } 64 - smp_wmb(); 65 - *rmap = i | KVMPPC_RMAP_REFERENCED | KVMPPC_RMAP_PRESENT; /* unlock */ 65 + unlock_rmap(rmap); 66 66 } 67 67 EXPORT_SYMBOL_GPL(kvmppc_add_revmap_chain); 68 68