OSDN Git Service

KVM: PPC: Book3S HV: Fix handling of large pages in radix page fault handler
authorPaul Mackerras <paulus@ozlabs.org>
Fri, 23 Feb 2018 10:21:12 +0000 (21:21 +1100)
committerPaul Mackerras <paulus@ozlabs.org>
Fri, 2 Mar 2018 03:05:32 +0000 (14:05 +1100)
commitc3856aeb29402e94ad9b3879030165cc6a4fdc56
tree93fa8259e3448dc34203530d13c7b89d857bfed3
parent6df3877fc962c2bb3d0438633dfd24a185af6838
KVM: PPC: Book3S HV: Fix handling of large pages in radix page fault handler

This fixes several bugs in the radix page fault handler relating to
the way large pages in the memory backing the guest were handled.
First, the check for large pages only checked for explicit huge pages
and missed transparent huge pages.  Then the check that the addresses
(host virtual vs. guest physical) had appropriate alignment was
wrong, meaning that the code never put a large page in the partition
scoped radix tree; it was always demoted to a small page.

Fixing this exposed bugs in kvmppc_create_pte().  We were never
invalidating a 2MB PTE, which meant that if a page was initially
faulted in without write permission and the guest then attempted
to store to it, we would never update the PTE to have write permission.
If we find a valid 2MB PTE in the PMD, we need to clear it and
do a TLB invalidation before installing either the new 2MB PTE or
a pointer to a page table page.

This also corrects an assumption that get_user_pages_fast would set
the _PAGE_DIRTY bit if we are writing, which is not true.  Instead we
mark the page dirty explicitly with set_page_dirty_lock().  This
also means we don't need the dirty bit set on the host PTE when
providing write access on a read fault.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/kvm/book3s_64_mmu_radix.c