diff mbox series

mips: mm: fix compiler error when CONFIG_XPA=n

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

Commit Message

Yun Lu May 12, 2022, 8: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)
...
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;