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

powerpc: Make vmalloc_to_phys() public

This makes vmalloc_to_phys() public as there will be another user
(KVM in-kernel VFIO acceleration) for it soon. As this new user
can be compiled as a module, this exports the symbol.

As a little optimization, this changes the helper to call
vmalloc_to_pfn() instead of vmalloc_to_page() as the size of the
struct page may not be power-of-two aligned which will make gcc use
multiply instructions instead of shifts.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Alexey Kardashevskiy and committed by
Paul Mackerras
e9ab1a1c 178a7875

+11 -8
+3
arch/powerpc/include/asm/pgtable.h
··· 78 78 } 79 79 return __find_linux_pte_or_hugepte(pgdir, ea, is_thp, shift); 80 80 } 81 + 82 + unsigned long vmalloc_to_phys(void *vmalloc_addr); 83 + 81 84 #endif /* __ASSEMBLY__ */ 82 85 83 86 #endif /* _ASM_POWERPC_PGTABLE_H */
+8
arch/powerpc/mm/pgtable.c
··· 243 243 } 244 244 #endif /* CONFIG_DEBUG_VM */ 245 245 246 + unsigned long vmalloc_to_phys(void *va) 247 + { 248 + unsigned long pfn = vmalloc_to_pfn(va); 249 + 250 + BUG_ON(!pfn); 251 + return __pa(pfn_to_kaddr(pfn)) + offset_in_page(va); 252 + } 253 + EXPORT_SYMBOL_GPL(vmalloc_to_phys);
-8
arch/powerpc/perf/hv-24x7.c
··· 493 493 } 494 494 } 495 495 496 - static unsigned long vmalloc_to_phys(void *v) 497 - { 498 - struct page *p = vmalloc_to_page(v); 499 - 500 - BUG_ON(!p); 501 - return page_to_phys(p) + offset_in_page(v); 502 - } 503 - 504 496 /* */ 505 497 struct event_uniq { 506 498 struct rb_node node;