diff mbox series

mips: mm: fix compiler error when CONFIG_XPA=n

Message ID 20220429061731.36291-1-luyun_611@163.com (mailing list archive)
State Superseded
Headers show
Series mips: mm: fix compiler error when CONFIG_XPA=n | expand

Commit Message

Yun Lu April 29, 2022, 6:17 a.m. UTC
From: luyun <luyun@kylinos.cn>

The below error is reported when CONFIG_XPA=n:

arch/mips/mm/init.c: In function ‘mem_init’:
././include/linux/compiler_types.h:352:38: error: call to ‘__compiletime_assert_289’ declared with attribute error: BUILD_BUG_ON failed: IS_ENABLED(CONFIG_32BIT) && (_PFN_SHIFT > PAGE_SHIFT)
  352 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |                                      ^
././include/linux/compiler_types.h:333:4: note: in definition of macro ‘__compiletime_assert’
  333 |    prefix ## suffix();    \
      |    ^~~~~~
././include/linux/compiler_types.h:352:2: note: in expansion of macro ‘_compiletime_assert’
  352 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |  ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
   39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
      |                                     ^~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
   50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
      |  ^~~~~~~~~~~~~~~~
arch/mips/mm/init.c:454:2: note: in expansion of macro ‘BUILD_BUG_ON’
  454 |  BUILD_BUG_ON(IS_ENABLED(CONFIG_32BIT) && (_PFN_SHIFT > PAGE_SHIFT));
      |  ^~~~~~~~~~~~

The macro _PFN_SHIFT is defined as (PAGE_SHIFT - 12 + _CACHE_SHIFT + 3)
when CONFIG_CPU_R3K_TLB=n, and _CACHE_SHIFT is conditionally defined with
CONFIG_XPA=y. Also _PFN_SHIFT is just equal to PAGE_SHIFT when
CONFIG_CPU_R3K_TLB=y, there is no need to judge on this condition.

So fix it by adding IS_ENABLED(CONFIG_XPA).

Fixes: 05d013a0366d ("MIPS: Detect bad _PFN_SHIFT values")
Reported-by: k2ci <kernel-bot@kylinos.cn>
Signed-off-by: Yun Lu <luyun@kylinos.cn>
---
 arch/mips/mm/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 5a8002839550..f13cd2844fed 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -451,7 +451,8 @@  void __init mem_init(void)
 	 * When _PFN_SHIFT is greater than PAGE_SHIFT we won't have enough PTE
 	 * bits to hold a full 32b physical address on MIPS32 systems.
 	 */
-	BUILD_BUG_ON(IS_ENABLED(CONFIG_32BIT) && (_PFN_SHIFT > PAGE_SHIFT));
+	BUILD_BUG_ON(IS_ENABLED(CONFIG_32BIT) && IS_ENABLED(CONFIG_XPA) &&
+		     (_PFN_SHIFT > PAGE_SHIFT));
 
 #ifdef CONFIG_HIGHMEM
 	max_mapnr = highend_pfn ? highend_pfn : max_low_pfn;