powerpc/mm: Speed up computation of base and actual page size for a HPTE
authorPaul Mackerras <paulus@ozlabs.org>
Fri, 2 Sep 2016 07:20:43 +0000 (17:20 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Fri, 9 Sep 2016 06:14:48 +0000 (16:14 +1000)
commit0eeede0c63305a33de31bd90b53b023c1d452c17
tree32ae6883786e58c5e9b6fc9886cf8cea9590da79
parent694d0d0bb2030d2e36df73e2d23d5770511dbc8d
powerpc/mm: Speed up computation of base and actual page size for a HPTE

This replaces a 2-D search through an array with a simple 8-bit table
lookup for determining the actual and/or base page size for a HPT entry.

The encoding in the second doubleword of the HPTE is designed to encode
the actual and base page sizes without using any more bits than would be
needed for a 4k page number, by using between 1 and 8 low-order bits of
the RPN (real page number) field to encode the page sizes.  A single
"large page" bit in the first doubleword indicates that these low-order
bits are to be interpreted like this.

We can determine the page sizes by using the low-order 8 bits of the RPN
to look up a 256-entry table.  For actual page sizes less than 1MB, some
of the upper bits of these 8 bits are going to be real address bits, but
we can cope with that by replicating the entries for those smaller page
sizes.

While we're at it, let's move the hpte_page_size() and hpte_base_page_size()
functions from a KVM-specific header to a header for 64-bit HPT systems,
since this computation doesn't have anything specifically to do with KVM.

Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/include/asm/book3s/64/mmu-hash.h
arch/powerpc/include/asm/kvm_book3s_64.h
arch/powerpc/include/asm/mmu.h
arch/powerpc/mm/hash_native_64.c
arch/powerpc/mm/hash_utils_64.c