Skip to contentSkip to conversation

mm: vmalloc: Fix a warning in the crash_save_vmcoreinfo_init()

PATCH In review Uladzislau Rezki (Sony) 6 participants 7 messages Jan 11, 2024 – Jan 19, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: vmalloc: Fix a warning in the crash_save_vmcoreinfo_init()

The vmcoreinfo_append_str() function expects "long unsigned int" type as a second argument(0x%lx) to print a beginning of vmalloc start address which is defined as a VMALLOC_START macro.

For some architectures it can be considered as "int" type, for example m68 generates a compile warning message. To fix it cast a second argument to "unsigned long".

---
 kernel/crash_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/crash_core.c +1 -1
index b60de490c1fc..49b31e59d3cc 100644
@@ -748,7 +748,7 @@ static int __init crash_save_vmcoreinfo_init(void)
 	VMCOREINFO_SYMBOL_ARRAY(swapper_pg_dir);
 #endif
 	VMCOREINFO_SYMBOL(_stext);
-	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
+	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", (unsigned long) VMALLOC_START);
 
 #ifndef CONFIG_NUMA
 	VMCOREINFO_SYMBOL(mem_map);
Signature · 1 line
2.39.2
Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines · Uladzislau Rezki (Sony)

The vmcoreinfo_append_str() function expects "long unsigned int" type as a second argument(0x%lx) to print a beginning of vmalloc start address which is defined as a VMALLOC_START macro.

For some architectures it can be considered as "int" type, for example m68 generates a compile warning message. To fix it cast a second argument to "unsigned long".

---
 kernel/crash_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/crash_core.c +0 -0
index b60de490c1fc..49b31e59d3cc 100644

kernel/crash_core.c static int __init crash_save_vmcoreinfo_init(void) · line 751

Quoted 5 lines
kernel/crash_core.c +1 -1
@@ -748,7 +748,7 @@ static int __init crash_save_vmcoreinfo_init(void)
 	VMCOREINFO_SYMBOL_ARRAY(swapper_pg_dir);
 #endif
 	VMCOREINFO_SYMBOL(_stext);
-	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
+	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", (unsigned long) VMALLOC_START);

Thanks for the fix.

Quoted 6 lines
kernel/crash_core.c +0 -0
 #ifndef CONFIG_NUMA
 	VMCOREINFO_SYMBOL(mem_map);
Signature · 1 line
2.39.2
#2 lore raw
In reply to Uladzislau Rezki (Sony)

kernel/crash_core.c static int __init crash_save_vmcoreinfo_init(void) · line 751

Quoted 4 lines · Uladzislau Rezki (Sony)

#endif

kernel/crash_core.c +1 -1
 	VMCOREINFO_SYMBOL(_stext);
-	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
+	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", (unsigned long) VMALLOC_START);

Well, the right fix is of course to make sure VMALLOC_START has a consistent type, else we need to plaster this crud all over. unsigned long seems like the right type for it, so at least m68k should be fixed to confirm to that by adding a UL postfix to the definition.

#3 lore raw
Quoted 11 lines · Uladzislau Rezki (Sony)

kernel/crash_core.c static int __init crash_save_vmcoreinfo_init(void) · line 751

Quoted 4 lines

#endif

kernel/crash_core.c +1 -1
 	VMCOREINFO_SYMBOL(_stext);
-	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
+	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", (unsigned long) VMALLOC_START);

Well, the right fix is of course to make sure VMALLOC_START has a consistent type, else we need to plaster this crud all over. unsigned long seems like the right type for it, so at least m68k should be fixed to confirm to that by adding a UL postfix to the definition.

I agree with you. I wanted to focus on fixing that particular place because i wanted to avoid other(on this step), possible side effects or drawbacks if i went with patching the arch/m68k/* files.

But, in general arch/m68k/* has to be fixed.

--
Uladzislau Rezki

#4 lore raw

CC linux-m68k

Quoted 11 lines · Uladzislau Rezki
Quoted 11 lines · Uladzislau Rezki (Sony)

kernel/crash_core.c static int __init crash_save_vmcoreinfo_init(void) · line 751

Quoted 4 lines
 #endif
    VMCOREINFO_SYMBOL(_stext);
kernel/crash_core.c +1 -1
-   vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
+   vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", (unsigned long) VMALLOC_START);

Well, the right fix is of course to make sure VMALLOC_START has a consistent type, else we need to plaster this crud all over. unsigned long seems like the right type for it, so at least m68k should be fixed to confirm to that by adding a UL postfix to the definition.

Quoted 5 lines

I agree with you. I wanted to focus on fixing that particular place because i wanted to avoid other(on this step), possible side effects or drawbacks if i went with patching the arch/m68k/* files.

But, in general arch/m68k/* has to be fixed.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Reviewed-by on v1 1/1
#5 lore raw
In reply to Uladzislau Rezki (Sony)
Quoted 7 lines · Uladzislau Rezki (Sony)

The vmcoreinfo_append_str() function expects "long unsigned int" type as a second argument(0x%lx) to print a beginning of vmalloc start address which is defined as a VMALLOC_START macro.

For some architectures it can be considered as "int" type, for example m68 generates a compile warning message. To fix it cast a second argument to "unsigned long".

Ugh dear Lord. Insert grumble about maintenance costs surrounding hobbyist architectures. I agree with Christoph the correct fix is within m68 (and any others with inconsistent typing).

But for now we do need to work around this.

Quoted 23 lines
---
 kernel/crash_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/crash_core.c +1 -2
index b60de490c1fc..49b31e59d3cc 100644
@@ -748,7 +748,7 @@ static int __init crash_save_vmcoreinfo_init(void)
 	VMCOREINFO_SYMBOL_ARRAY(swapper_pg_dir);
 #endif
 	VMCOREINFO_SYMBOL(_stext);
-	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
+	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", (unsigned long) VMALLOC_START);
 
 #ifndef CONFIG_NUMA
 	VMCOREINFO_SYMBOL(mem_map);
--
Quoted 2 lines

2.39.2

We definitely need to get this sorted for the bots, though moving forward we should patch this problem correctly in the right arch. However for the purposes of the fix feel free to add:

Reviewed-by on v1 1/1
#6 lore raw
In reply to Uladzislau Rezki (Sony)
Quoted 21 lines · Uladzislau Rezki (Sony)

The vmcoreinfo_append_str() function expects "long unsigned int" type as a second argument(0x%lx) to print a beginning of vmalloc start address which is defined as a VMALLOC_START macro.

For some architectures it can be considered as "int" type, for example m68 generates a compile warning message. To fix it cast a second argument to "unsigned long".

---
 kernel/crash_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/crash_core.c +0 -0
index b60de490c1fc..49b31e59d3cc 100644

kernel/crash_core.c static int __init crash_save_vmcoreinfo_init(void) · line 754

Quoted 8 lines
kernel/crash_core.c +1 -1
@@ -748,7 +748,7 @@ static int __init crash_save_vmcoreinfo_init(void)
 	VMCOREINFO_SYMBOL_ARRAY(swapper_pg_dir);
 #endif
 	VMCOREINFO_SYMBOL(_stext);
-	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START);
+	vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", (unsigned long) VMALLOC_START);
 
 #ifndef CONFIG_NUMA
 	VMCOREINFO_SYMBOL(mem_map);

Agree with Christoph - the right place to have this fixed properly is in m68k platform while defining VMALLOC_START. But otherwise this fix in itself LGTM.