kvm: Fix page ageing bugs
authorAndres Lagar-Cavilla <andreslc@google.com>
Mon, 22 Sep 2014 21:54:42 +0000 (14:54 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 24 Sep 2014 12:07:58 +0000 (14:07 +0200)
commit57128468080a8b6ea452223036d3e417f748af55
treee89cfc349a9c39710cfab4e387119365a0d64958
parent8a9522d2fe6a1b643d3aef5ab7f097f73c601e7a
kvm: Fix page ageing bugs

1. We were calling clear_flush_young_notify in unmap_one, but we are
within an mmu notifier invalidate range scope. The spte exists no more
(due to range_start) and the accessed bit info has already been
propagated (due to kvm_pfn_set_accessed). Simply call
clear_flush_young.

2. We clear_flush_young on a primary MMU PMD, but this may be mapped
as a collection of PTEs by the secondary MMU (e.g. during log-dirty).
This required expanding the interface of the clear_flush_young mmu
notifier, so a lot of code has been trivially touched.

3. In the absence of shadow_accessed_mask (e.g. EPT A bit), we emulate
the access bit by blowing the spte. This requires proper synchronizing
with MMU notifier consumers, like every other removal of spte's does.

Signed-off-by: Andres Lagar-Cavilla <andreslc@google.com>
Acked-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
16 files changed:
arch/arm/include/asm/kvm_host.h
arch/arm64/include/asm/kvm_host.h
arch/powerpc/include/asm/kvm_host.h
arch/powerpc/include/asm/kvm_ppc.h
arch/powerpc/kvm/book3s.c
arch/powerpc/kvm/book3s.h
arch/powerpc/kvm/book3s_64_mmu_hv.c
arch/powerpc/kvm/book3s_pr.c
arch/powerpc/kvm/e500_mmu_host.c
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu.c
drivers/iommu/amd_iommu_v2.c
include/linux/mmu_notifier.h
mm/mmu_notifier.c
mm/rmap.c
virt/kvm/kvm_main.c