Skip to contentSkip to conversation

linux-next: Tree for Dec 1 (riscv, crash_core)

PATCH In review Baoquan He 3 participants 9 messages Dec 4, 2023 – Jan 20, 2024

Subsystems (4)
lore
Share & tools
lore

Baoquan He

author
#0 lore raw

[email protected], [email protected],
Linux Next Mailing List <[email protected]>, Linux Kernel Mailing List <[email protected]>, linux-riscv <[email protected]>, kexec <[email protected]>
Bcc: [email protected]
Subject: Re: linux-next: Tree for Dec 1 (riscv, crash_core) Reply-To:
In-Reply-To: <[email protected]>

Quoted 10 lines · Randy Dunlap
Quoted 4 lines · Stephen Rothwell

Hi all,

Changes since 20231130:

on riscv 32-bit or 64-bit, with
# CONFIG_MMU is not set

Thanks for providing the kernel config to ease reproduction. In the config, there are:

CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_CRASH_DUMP=y
......
# CONFIG_MMU is not set

After investigation, I found this happened after Ignat's patch:
commit 1c7a3fa49ef7 ("kexec: drop dependency on ARCH_SUPPORTS_KEXEC from CRASH_DUMP")

Copy above commit change here for reference, and also risc-v's ARCH_SUPPORTS_KEXEC depends on MMU:
--------------------------------------------------------

kernel/Kconfig.kexec +0 -1
index fc38f1ae3a30..946dffa048b7 100644
@@ -96,7 +96,6 @@ config KEXEC_JUMP
 config CRASH_DUMP
        bool "kernel crash dumps"
        depends on ARCH_SUPPORTS_CRASH_DUMP
-       depends on ARCH_SUPPORTS_KEXEC
        select CRASH_CORE
        select KEXEC_CORE
        help

arch/riscv/Kconfig
---------------------
config ARCH_SUPPORTS_KEXEC
def_bool MMU

Before Ignat's patch, once CONFIG_MMU is unset, CONFIG_CRASH_DUMP, CONFIG_KEXEC_CORE, CONFIG_CRASH_CORE are all unset automatically. The crash_core codes are not compiled. That's why no compiling error is seen.

After Ignat's patch applied, we can enable CONFIG_CRASH_DUMP, CONFIG_KEXEC_CORE, CONFIG_CRASH_CORE independently. However, there are several macro definitions, such as VA_BITS, VMEMMAP_START, VMEMMAP_END, MODULES_VADDR, MODULES_END are only available when CONFIG_MMU=y.

I made two patches to decouple the kexec/crash code with CONFIG_MMU. Not sure if risc-v wants that.

Or we can simply add dependency on MMU for ARCH_SUPPORTS_CRASH_DUMP. Then when CONFIG_MMU=n, CONFIG_CRASH_DUMP, CONFIG_KEXEC_CORE, CONFIG_CRASH_CORE will be unset too. Please help check which one need be taken.

arch/riscv/Kconfig +1 -0
index 24c1799e2ec4..03d290da7262 100644
@@ -708,6 +708,7 @@ config ARCH_SUPPORTS_KEXEC_PURGATORY
 
 config ARCH_SUPPORTS_CRASH_DUMP
 	def_bool y
+	depends on MMU=y
 
 config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
 	def_bool CRASH_CORE
Quoted 43 lines

In file included from ../arch/riscv/kernel/crash_core.c:3:
../arch/riscv/kernel/crash_core.c: In function 'arch_crash_save_vmcoreinfo':
../arch/riscv/kernel/crash_core.c:8:27: error: 'VA_BITS' undeclared (first use in this function)

    8 |         VMCOREINFO_NUMBER(VA_BITS);
      |                           ^~~~~~~

../include/linux/crash_core.h:78:64: note: in definition of macro 'VMCOREINFO_NUMBER'
78 | vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name)
| ^~~~
../arch/riscv/kernel/crash_core.c:8:27: note: each undeclared identifier is reported only once for each function it appears in

    8 |         VMCOREINFO_NUMBER(VA_BITS);
      |                           ^~~~~~~

../include/linux/crash_core.h:78:64: note: in definition of macro 'VMCOREINFO_NUMBER'
78 | vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name)
| ^~~~
../arch/riscv/kernel/crash_core.c:12:58: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'int' [-Wformat=]

   12 |         vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
      |                                                        ~~^
      |                                                          |
      |                                                          long unsigned int
      |                                                        %x

../arch/riscv/kernel/crash_core.c:14:64: error: 'VMEMMAP_START' undeclared (first use in this function)
14 | vmcoreinfo_append_str("NUMBER(VMEMMAP_START)=0x%lx\n", VMEMMAP_START);
| ^~~~~~~~~~~~~
../arch/riscv/kernel/crash_core.c:15:62: error: 'VMEMMAP_END' undeclared (first use in this function); did you mean 'MEMREMAP_ENC'?

   15 |         vmcoreinfo_append_str("NUMBER(VMEMMAP_END)=0x%lx\n", VMEMMAP_END);
      |                                                              ^~~~~~~~~~~
      |                                                              MEMREMAP_ENC

64-bit only:

../arch/riscv/kernel/crash_core.c:17:64: error: 'MODULES_VADDR' undeclared (first use in this function)
17 | vmcoreinfo_append_str("NUMBER(MODULES_VADDR)=0x%lx\n", MODULES_VADDR);
| ^~~~~~~~~~~~~
../arch/riscv/kernel/crash_core.c:18:62: error: 'MODULES_END' undeclared (first use in this function)
18 | vmcoreinfo_append_str("NUMBER(MODULES_END)=0x%lx\n", MODULES_END);
| ^~~~~~~~~~~

Signature · 1 line
~Randy
author
#1 lore raw

PATCH 1/2 riscv, crash: don't export some symbols when CONFIG_MMU=n

When dropping select of KEXEC and dependency on ARCH_SUPPORTS_KEXEC from CRASH_DUMP, compiling error is reported when below config items are set:
-----------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_CRASH_DUMP=y
......
-----------------------

-------------------------------------------------------------------------------------------------
arch/riscv/kernel/crash_core.c:8:27: error: 'VA_BITS' undeclared (first use in this function)
8 | VMCOREINFO_NUMBER(VA_BITS);
| ^~~~~~~
include/linux/crash_core.h:78:64: note: in definition of macro 'VMCOREINFO_NUMBER'
78 | vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name)
| ^~~~

arch/riscv/kernel/crash_core.c:14:64: error: 'VMEMMAP_START' undeclared (first use in this function)
14 | vmcoreinfo_append_str("NUMBER(VMEMMAP_START)=0x%lx\n", VMEMMAP_START);
| ^~~~~~~~~~~~~
arch/riscv/kernel/crash_core.c:15:62: error: 'VMEMMAP_END' undeclared (first use in this function); did you mean 'MEMREMAP_ENC'?

15 |         vmcoreinfo_append_str("NUMBER(VMEMMAP_END)=0x%lx\n", VMEMMAP_END);
   |                                                              ^~~~~~~~~~~
   |                                                              MEMREMAP_ENC

arch/riscv/kernel/crash_core.c:17:64: error: 'MODULES_VADDR' undeclared (first use in this function)
17 | vmcoreinfo_append_str("NUMBER(MODULES_VADDR)=0x%lx\n", MODULES_VADDR);
| ^~~~~~~~~~~~~
arch/riscv/kernel/crash_core.c:18:62: error: 'MODULES_END' undeclared (first use in this function)
18 | vmcoreinfo_append_str("NUMBER(MODULES_END)=0x%lx\n", MODULES_END);
-------------------------------------------------------------------------------------------------

Currently, riscv's ARCH_SUPPORTS_KEXEC has dependency on MMU. Before dropping ARCH_SUPPORTS_KEXEC, disabling CONFIG_MMU will unset CONFIG_CRASH_DUMP, CONFIG_KEXEC_CORE, CONFIG_CRASH_CORE. Hence crash_core related codes won't be compiled.

---------------------
arch/riscv/Kconfig:
config ARCH_SUPPORTS_KEXEC
def_bool MMU
---------------------

After dropping ARCH_SUPPORTS_KEXEC, CONFIG_CRASH_DUMP, CONFIG_KEXEC_CORE, CONFIG_CRASH_CORE can be set independently of CONFIG_MMU. However, there are several macro definitions, such as VA_BITS, VMEMMAP_START, VMEMMAP_END, MODULES_VADDR, MODULES_END are only available when CONFIG_MMU=y. Then compiling errors are triggered.

Here, add CONFIG_MMU ifdeffery in arch_crash_save_vmcoreinfo() to export those symbols when CONFIG_MMU is enabled.

---
 arch/riscv/kernel/crash_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/kernel/crash_core.c +3 -1
index 55f1d7856b54..8706736fd4e2 100644
@@ -5,17 +5,19 @@
 
 void arch_crash_save_vmcoreinfo(void)
 {
-	VMCOREINFO_NUMBER(VA_BITS);
 	VMCOREINFO_NUMBER(phys_ram_base);
 
 	vmcoreinfo_append_str("NUMBER(PAGE_OFFSET)=0x%lx\n", PAGE_OFFSET);
 	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
 	vmcoreinfo_append_str("NUMBER(VMALLOC_END)=0x%lx\n", VMALLOC_END);
+#ifdef CONFIG_MMU
+	VMCOREINFO_NUMBER(VA_BITS);
 	vmcoreinfo_append_str("NUMBER(VMEMMAP_START)=0x%lx\n", VMEMMAP_START);
 	vmcoreinfo_append_str("NUMBER(VMEMMAP_END)=0x%lx\n", VMEMMAP_END);
 #ifdef CONFIG_64BIT
 	vmcoreinfo_append_str("NUMBER(MODULES_VADDR)=0x%lx\n", MODULES_VADDR);
 	vmcoreinfo_append_str("NUMBER(MODULES_END)=0x%lx\n", MODULES_END);
+#endif
 #endif
 	vmcoreinfo_append_str("NUMBER(KERNEL_LINK_ADDR)=0x%lx\n", KERNEL_LINK_ADDR);
 	vmcoreinfo_append_str("NUMBER(va_kernel_pa_offset)=0x%lx\n",
Signature · 1 line
2.41.0
author
#6 lore raw

PATCH 2/2 riscv, kexec: fix dependency of two items

In reply to Baoquan He

Drop the dependency on MMU from ARCH_SUPPORTS_KEXEC and ARCH_SUPPORTS_KEXEC_FILE because CONFIG_MMU could be disabled while people may still want to have KEXEC/KEXEC_FILE functionality.

---
 arch/riscv/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/Kconfig +2 -2
index 95a2a06acc6a..24c1799e2ec4 100644
@@ -685,7 +685,7 @@ config RISCV_BOOT_SPINWAIT
 	  If unsure what to do here, say N.
 
 config ARCH_SUPPORTS_KEXEC
-	def_bool MMU
+	def_bool y
 
 config ARCH_SELECTS_KEXEC
 	def_bool y
@@ -693,7 +693,7 @@ config ARCH_SELECTS_KEXEC
 	select HOTPLUG_CPU if SMP
 
 config ARCH_SUPPORTS_KEXEC_FILE
-	def_bool 64BIT && MMU
+	def_bool 64BIT
 
 config ARCH_SELECTS_KEXEC_FILE
 	def_bool y
Signature · 1 line
2.41.0
Tested-by
#8 lore raw
In reply to Baoquan He

Hi,

Quoted 10 lines · Baoquan He

[email protected], [email protected],
Linux Next Mailing List <[email protected]>, Linux Kernel Mailing List <[email protected]>, linux-riscv <[email protected]>, kexec <[email protected]>
Bcc: [email protected]
Subject: Re: linux-next: Tree for Dec 1 (riscv, crash_core) Reply-To:
In-Reply-To: <[email protected]>

Quoted 12 lines
Quoted 10 lines · Randy Dunlap
Quoted 4 lines · Stephen Rothwell

Hi all,

Changes since 20231130:

on riscv 32-bit or 64-bit, with
# CONFIG_MMU is not set

[]

Quoted 15 lines

I made two patches to decouple the kexec/crash code with CONFIG_MMU. Not sure if risc-v wants that.

Or we can simply add dependency on MMU for ARCH_SUPPORTS_CRASH_DUMP. Then when CONFIG_MMU=n, CONFIG_CRASH_DUMP, CONFIG_KEXEC_CORE, CONFIG_CRASH_CORE will be unset too. Please help check which one need be taken.

arch/riscv/Kconfig +0 -0
index 24c1799e2ec4..03d290da7262 100644

arch/riscv/Kconfig config ARCH_SUPPORTS_KEXEC_PURGATORY · line 714

Quoted 7 lines
arch/riscv/Kconfig +1 -0
@@ -708,6 +708,7 @@ config ARCH_SUPPORTS_KEXEC_PURGATORY
 
 config ARCH_SUPPORTS_CRASH_DUMP
 	def_bool y
+	depends on MMU=y
 
 config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
 	def_bool CRASH_CORE

That works if the RISC-V folks prefer it.

Thanks.

Signature · 1 line
~Randy
Tested-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] riscv, crash: don't export some symbols when CONFIG_MMU=n

In reply to Baoquan He
Quoted 10 lines · Baoquan He

When dropping select of KEXEC and dependency on ARCH_SUPPORTS_KEXEC from CRASH_DUMP, compiling error is reported when below config items are set:
-----------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_CRASH_DUMP=y
......
-----------------------

[]

Quoted 41 lines

Currently, riscv's ARCH_SUPPORTS_KEXEC has dependency on MMU. Before dropping ARCH_SUPPORTS_KEXEC, disabling CONFIG_MMU will unset CONFIG_CRASH_DUMP, CONFIG_KEXEC_CORE, CONFIG_CRASH_CORE. Hence crash_core related codes won't be compiled.

---------------------
arch/riscv/Kconfig:
config ARCH_SUPPORTS_KEXEC
def_bool MMU
---------------------

After dropping ARCH_SUPPORTS_KEXEC, CONFIG_CRASH_DUMP, CONFIG_KEXEC_CORE, CONFIG_CRASH_CORE can be set independently of CONFIG_MMU. However, there are several macro definitions, such as VA_BITS, VMEMMAP_START, VMEMMAP_END, MODULES_VADDR, MODULES_END are only available when CONFIG_MMU=y. Then compiling errors are triggered.

Here, add CONFIG_MMU ifdeffery in arch_crash_save_vmcoreinfo() to export those symbols when CONFIG_MMU is enabled.

---
 arch/riscv/kernel/crash_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/kernel/crash_core.c +1 -1
index 55f1d7856b54..8706736fd4e2 100644
@@ -5,17 +5,19 @@
 
 void arch_crash_save_vmcoreinfo(void)
 {
-	VMCOREINFO_NUMBER(VA_BITS);
 	VMCOREINFO_NUMBER(phys_ram_base);
 
 	vmcoreinfo_append_str("NUMBER(PAGE_OFFSET)=0x%lx\n", PAGE_OFFSET);
 	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
 	vmcoreinfo_append_str("NUMBER(VMALLOC_END)=0x%lx\n", VMALLOC_END);
+#ifdef CONFIG_MMU

arch/riscv/kernel/crash_core.c line 23

Quoted 10 lines
arch/riscv/kernel/crash_core.c +2 -0
+	VMCOREINFO_NUMBER(VA_BITS);
 	vmcoreinfo_append_str("NUMBER(VMEMMAP_START)=0x%lx\n", VMEMMAP_START);
 	vmcoreinfo_append_str("NUMBER(VMEMMAP_END)=0x%lx\n", VMEMMAP_END);
 #ifdef CONFIG_64BIT
 	vmcoreinfo_append_str("NUMBER(MODULES_VADDR)=0x%lx\n", MODULES_VADDR);
 	vmcoreinfo_append_str("NUMBER(MODULES_END)=0x%lx\n", MODULES_END);
+#endif
 #endif
 	vmcoreinfo_append_str("NUMBER(KERNEL_LINK_ADDR)=0x%lx\n", KERNEL_LINK_ADDR);
 	vmcoreinfo_append_str("NUMBER(va_kernel_pa_offset)=0x%lx\n",

Both riscv 32-bit and 64-bit complain:

../arch/riscv/kernel/crash_core.c: In function 'arch_crash_save_vmcoreinfo':
../arch/riscv/kernel/crash_core.c:11:58: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'int' [-Wformat=]

   11 |         vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
      |                                                        ~~^
      |                                                          |
      |                                                          long unsigned int
      |                                                        %x

Otherwise this builds without failure.

Thanks.

Signature · 1 line
~Randy
Tested-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] riscv, kexec: fix dependency of two items

In reply to Baoquan He
Quoted 5 lines · Baoquan He

Drop the dependency on MMU from ARCH_SUPPORTS_KEXEC and ARCH_SUPPORTS_KEXEC_FILE because CONFIG_MMU could be disabled while people may still want to have KEXEC/KEXEC_FILE functionality.

Thanks.

Quoted 26 lines
---
 arch/riscv/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/Kconfig +2 -2
index 95a2a06acc6a..24c1799e2ec4 100644
@@ -685,7 +685,7 @@ config RISCV_BOOT_SPINWAIT
 	  If unsure what to do here, say N.
 
 config ARCH_SUPPORTS_KEXEC
-	def_bool MMU
+	def_bool y
 
 config ARCH_SELECTS_KEXEC
 	def_bool y
@@ -693,7 +693,7 @@ config ARCH_SELECTS_KEXEC
 	select HOTPLUG_CPU if SMP
 
 config ARCH_SUPPORTS_KEXEC_FILE
-	def_bool 64BIT && MMU
+	def_bool 64BIT
 
 config ARCH_SELECTS_KEXEC_FILE
 	def_bool y
Signature · 1 line
~Randy
author
#3 lore raw

Re: [PATCH 1/2] riscv, crash: don't export some symbols when CONFIG_MMU=n

In reply to Randy Dunlap

On 12/04/23 at 11:14am, Randy Dunlap wrote:
......

Quoted 32 lines
Quoted 19 lines
---
 arch/riscv/kernel/crash_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/kernel/crash_core.c +1 -1
index 55f1d7856b54..8706736fd4e2 100644
@@ -5,17 +5,19 @@
 
 void arch_crash_save_vmcoreinfo(void)
 {
-	VMCOREINFO_NUMBER(VA_BITS);
 	VMCOREINFO_NUMBER(phys_ram_base);
 
 	vmcoreinfo_append_str("NUMBER(PAGE_OFFSET)=0x%lx\n", PAGE_OFFSET);
 	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
 	vmcoreinfo_append_str("NUMBER(VMALLOC_END)=0x%lx\n", VMALLOC_END);
+#ifdef CONFIG_MMU

arch/riscv/kernel/crash_core.c line 23

Quoted 10 lines
arch/riscv/kernel/crash_core.c +2 -0
+	VMCOREINFO_NUMBER(VA_BITS);
 	vmcoreinfo_append_str("NUMBER(VMEMMAP_START)=0x%lx\n", VMEMMAP_START);
 	vmcoreinfo_append_str("NUMBER(VMEMMAP_END)=0x%lx\n", VMEMMAP_END);
 #ifdef CONFIG_64BIT
 	vmcoreinfo_append_str("NUMBER(MODULES_VADDR)=0x%lx\n", MODULES_VADDR);
 	vmcoreinfo_append_str("NUMBER(MODULES_END)=0x%lx\n", MODULES_END);
+#endif
 #endif
 	vmcoreinfo_append_str("NUMBER(KERNEL_LINK_ADDR)=0x%lx\n", KERNEL_LINK_ADDR);
 	vmcoreinfo_append_str("NUMBER(va_kernel_pa_offset)=0x%lx\n",

Both riscv 32-bit and 64-bit complain:

Quoted 7 lines

../arch/riscv/kernel/crash_core.c: In function 'arch_crash_save_vmcoreinfo':
../arch/riscv/kernel/crash_core.c:11:58: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'int' [-Wformat=]

   11 |         vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
      |                                                        ~~^
      |                                                          |
      |                                                          long unsigned int
      |                                                        %x

Thanks for all these testing.

This warning is irrelevant to the kexec patch, it's becasue VMALLOC_START is defined as 0 which is int when CONFIG_MMU=n.

Below patch can fix the warning.

From 46984a0287e5f1b41ae3e9adfcfa0d26b71db8f4 Mon Sep 17 00:00:00 2001
From: Baoquan He <[email protected]>
Date: Tue, 5 Dec 2023 11:02:55 +0800
Subject: [PATCH] riscv: fix VMALLC_START definition
Content-type: text/plain

When below config items are set, compiler complained:

--------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_CRASH_DUMP=y
......
-----------------------

-------------------------------------------------------------------
arch/riscv/kernel/crash_core.c: In function 'arch_crash_save_vmcoreinfo':
arch/riscv/kernel/crash_core.c:11:58: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'int' [-Wformat=]

11 |         vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
   |                                                        ~~^
   |                                                          |
   |                                                          long unsigned int
   |                                                        %x

----------------------------------------------------------------------

This is because on riscv macro VMALLOC_START has different type when CONFIG_MMU is set or unset.

arch/riscv/include/asm/pgtable.h:
--------------------------------------------------

Changing it to _AC(0, UL) in case CONFIG_MMU=n can fix the warning.

---
 arch/riscv/include/asm/pgtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/include/asm/pgtable.h +1 -1
index 294044429e8e..ab00235b018f 100644
@@ -899,7 +899,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
 #define PAGE_KERNEL		__pgprot(0)
 #define swapper_pg_dir		NULL
 #define TASK_SIZE		0xffffffffUL
-#define VMALLOC_START		0
+#define VMALLOC_START		_AC(0, UL)
 #define VMALLOC_END		TASK_SIZE
 
 #endif /* !CONFIG_MMU */
Signature · 1 line
2.41.0
Acked-by Tested-by
#4 lore raw

Re: [PATCH 1/2] riscv, crash: don't export some symbols when CONFIG_MMU=n

Quoted 1 line · Baoquan He

On 12/04/23 at 11:14am, Randy Dunlap wrote:

[]

Quoted 46 lines
Quoted 10 lines

Both riscv 32-bit and 64-bit complain:

../arch/riscv/kernel/crash_core.c: In function 'arch_crash_save_vmcoreinfo':
../arch/riscv/kernel/crash_core.c:11:58: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'int' [-Wformat=]

   11 |         vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
      |                                                        ~~^
      |                                                          |
      |                                                          long unsigned int
      |                                                        %x

Thanks for all these testing.

This warning is irrelevant to the kexec patch, it's becasue VMALLOC_START is defined as 0 which is int when CONFIG_MMU=n.

Below patch can fix the warning.

From 46984a0287e5f1b41ae3e9adfcfa0d26b71db8f4 Mon Sep 17 00:00:00 2001
From: Baoquan He <[email protected]>
Date: Tue, 5 Dec 2023 11:02:55 +0800
Subject: [PATCH] riscv: fix VMALLC_START definition
Content-type: text/plain

When below config items are set, compiler complained:

--------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_CRASH_DUMP=y
......
-----------------------

-------------------------------------------------------------------
arch/riscv/kernel/crash_core.c: In function 'arch_crash_save_vmcoreinfo':
arch/riscv/kernel/crash_core.c:11:58: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'int' [-Wformat=]

11 |         vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
   |                                                        ~~^
   |                                                          |
   |                                                          long unsigned int
   |                                                        %x

----------------------------------------------------------------------

This is because on riscv macro VMALLOC_START has different type when CONFIG_MMU is set or unset.

Quoted 6 lines

arch/riscv/include/asm/pgtable.h:
--------------------------------------------------

Changing it to _AC(0, UL) in case CONFIG_MMU=n can fix the warning.

Thanks.

Quoted 17 lines
---
 arch/riscv/include/asm/pgtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/include/asm/pgtable.h +1 -1
index 294044429e8e..ab00235b018f 100644
@@ -899,7 +899,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
 #define PAGE_KERNEL		__pgprot(0)
 #define swapper_pg_dir		NULL
 #define TASK_SIZE		0xffffffffUL
-#define VMALLOC_START		0
+#define VMALLOC_START		_AC(0, UL)
 #define VMALLOC_END		TASK_SIZE
 
 #endif /* !CONFIG_MMU */
Signature · 6 lines
~Randy

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#5 lore raw

Re: [PATCH 1/2] riscv, crash: don't export some symbols when CONFIG_MMU=n

In reply to Baoquan He
This series was applied to riscv/linux.git (fixes) by Andrew Morton <[email protected]>:

Hello:

This series was applied to riscv/linux.git (fixes) by Andrew Morton <[email protected]>:

Quoted 10 lines · On Mon, 4 Dec 2023 10:19:36 +0800 you wrote:

When dropping select of KEXEC and dependency on ARCH_SUPPORTS_KEXEC from CRASH_DUMP, compiling error is reported when below config items are set:
-----------------------
CONFIG_CRASH_CORE=y
CONFIG_KEXEC_CORE=y
CONFIG_CRASH_DUMP=y
......

[...]

Here is the summary with links:
- [1/2] riscv, crash: don't export some symbols when CONFIG_MMU=n

    https://git.kernel.org/riscv/c/c41bd2514184

- [2/2] riscv, kexec: fix dependency of two items (no matching commit)

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html