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

powerpc/64s: Fix get_hugepd_cache_index() build failure

With CONFIG_BUG=n, the 64-bit Book3S build fails with:

arch/powerpc/include/asm/book3s/64/pgtable-64k.h: In function 'get_hugepd_cache_index':
arch/powerpc/include/asm/book3s/64/pgtable-64k.h:51:1: error: no return statement in function returning non-void

Currently the body of the function is just BUG(), so when CONFIG_BUG=n
it is an empty function, leading to the error.

get_hugepd_cache_index() should never be called, the only call is behind
an is_hugepd() check, which is always false for this configuration.

Instead mark it as always inline, and change the BUG() to BUILD_BUG().
That should allow the compiler to see that the function is never called,
and therefore that it never returns, fixing the build error.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240306125853.3714578-1-mpe@ellerman.id.au

+2 -2
+2 -2
arch/powerpc/include/asm/book3s/64/pgtable-64k.h
··· 45 45 /* 46 46 * This should never get called 47 47 */ 48 - static inline int get_hugepd_cache_index(int index) 48 + static __always_inline int get_hugepd_cache_index(int index) 49 49 { 50 - BUG(); 50 + BUILD_BUG(); 51 51 } 52 52 53 53 #endif /* CONFIG_HUGETLB_PAGE */