KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
Subsystems (2)
Nicholas Piggin
reviewerPATCH 1/1 KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
real_vmalloc_addr() does not currently work for huge vmalloc, which is what the reverse map can be allocated with for radix host, hash guest.
Add huge page awareness to the function.
--- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
arch/powerpc/kvm/book3s_hv_rm_mmu.c +12 -5
@@ -26,16 +26,23 @@static void *real_vmalloc_addr (void *x) {unsigned long addr = (unsigned long ) x; +unsigned long mask; +int shift;pte_t *p; +/* -* assume we don't have huge pages in vmalloc space... -* So don't worry about THP collapse/split. Called -* Only in realmode with MSR_EE = 0, hence won't need irq_save/restore. +* This is called only in realmode with MSR_EE = 0, hence won't need +* irq_save/restore around find_init_mm_pte. */ - p =find_init_mm_pte (addr,NULL ); + p =find_init_mm_pte (addr, &shift);if (!p || !pte_present (*p))return NULL ; - addr = (pte_pfn (*p) <<PAGE_SHIFT ) | (addr & ~PAGE_MASK ); +if (!shift) + shift =PAGE_SHIFT ; + + mask = (1UL << shift) -1 ; + addr = (pte_pfn (*p) <<PAGE_SHIFT ) | (addr & mask); +return __va (addr); }
Signature · 1 line
2.23.0
Nicholas Piggin <[email protected]> a écrit :
Quoted 30 lines
real_vmalloc_addr()does not currently work for huge vmalloc, which is what the reverse map can be allocated with for radix host, hash guest.Add huge page awareness to the function.
Fixes 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings")Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)arch/powerpc/kvm/book3s_hv_rm_mmu.c +5
-3@@ -26,16 +26,23 @@static void *real_vmalloc_addr (void *x) {unsigned long addr = (unsigned long ) x; +unsigned long mask; +int shift;pte_t *p; +/* -* assume we don't have huge pages in vmalloc space... -* So don't worry about THP collapse/split. Called -* Only in realmode with MSR_EE = 0, hence won't need irq_save/restore. +* This is called only in realmode with MSR_EE = 0, hence won't need +* irq_save/restore around find_init_mm_pte. */
arch/powerpc/kvm/book3s_hv_rm_mmu.c line 44
Quoted 10 lines
arch/powerpc/kvm/book3s_hv_rm_mmu.c +6
-2- p =find_init_mm_pte (addr,NULL ); + p =find_init_mm_pte (addr, &shift);if (!p || !pte_present (*p))return NULL ; - addr = (pte_pfn (*p) <<PAGE_SHIFT ) | (addr & ~PAGE_MASK ); +if (!shift) + shift =PAGE_SHIFT ; + + mask = (1UL << shift) -1 ; + addr = (pte_pfn (*p) <<PAGE_SHIFT ) | (addr & mask);
Looks strange, before we have ~MASK now we have mask without the ~
Also use PFN_PHYS() instead of open coding ?
Quoted 6 lines
arch/powerpc/kvm/book3s_hv_rm_mmu.c +1
-1+return __va (addr); } --2.23.0
Quoted 37 lines · Christophe Leroy
Nicholas Piggin <[email protected]> a écrit :
Quoted 35 lines
real_vmalloc_addr()does not currently work for huge vmalloc, which is what the reverse map can be allocated with for radix host, hash guest.Add huge page awareness to the function.
Fixes 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings")Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)arch/powerpc/kvm/book3s_hv_rm_mmu.c +6
-4@@ -26,16 +26,23 @@static void *real_vmalloc_addr (void *x) {unsigned long addr = (unsigned long ) x; +unsigned long mask; +int shift;pte_t *p; +/* -* assume we don't have huge pages in vmalloc space... -* So don't worry about THP collapse/split. Called -* Only in realmode with MSR_EE = 0, hence won't need irq_save/restore. +* This is called only in realmode with MSR_EE = 0, hence won't need +* irq_save/restore around find_init_mm_pte. */ - p =find_init_mm_pte (addr,NULL ); + p =find_init_mm_pte (addr, &shift);if (!p || !pte_present (*p))return NULL ;
Quoted 8 lines
arch/powerpc/kvm/book3s_hv_rm_mmu.c line 44
Quoted 6 lines
arch/powerpc/kvm/book3s_hv_rm_mmu.c +5
-1- addr = (pte_pfn (*p) <<PAGE_SHIFT ) | (addr & ~PAGE_MASK ); +if (!shift) + shift =PAGE_SHIFT ; + + mask = (1UL << shift) -1 ; + addr = (pte_pfn (*p) <<PAGE_SHIFT ) | (addr & mask);Looks strange, before we have ~MASK now we have mask without the ~
#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
-aneesh