mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] loongarch: improve logging of disabling KASLR.
@ 2026-04-03  6:30 Yuqian Yang
  2026-04-12  4:42 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yuqian Yang @ 2026-04-03  6:30 UTC (permalink / raw)
  To: Huacai Chen
  Cc: WANG Xuerui, Cheng Nie, Wentao Guan, Dandan Zhang, loongarch,
	linux-kernel, Yuqian Yang

Whether KASLR is disabled is not handled in nokaslr (early param
"nokaslr" setup function) but in kaslr_disabled. However, the logging
was done in nokaslr previously. So we move the logging to the right
place and add more specific info about why it's disabled.

Suggested-by: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: Yuqian Yang <yangyuqian@uniontech.com>
---
 arch/loongarch/kernel/relocate.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/arch/loongarch/kernel/relocate.c b/arch/loongarch/kernel/relocate.c
index 82aa3f0359278..be11096c3c009 100644
--- a/arch/loongarch/kernel/relocate.c
+++ b/arch/loongarch/kernel/relocate.c
@@ -128,9 +128,8 @@ static inline __init unsigned long get_random_boot(void)
 
 static int __init nokaslr(char *p)
 {
-	pr_info("KASLR is disabled.\n");
-
-	return 0; /* Print a notice and silence the boot warning */
+	/* The real check is handled in kaslr_disabled() below. */
+	return 0;
 }
 early_param("nokaslr", nokaslr);
 
@@ -138,14 +137,19 @@ static inline __init bool kaslr_disabled(void)
 {
 	char *str;
 	const char *builtin_cmdline = CONFIG_CMDLINE;
+	const char *const message = "KASLR is disabled by %s in %s cmdline.\n";
 
 	str = strstr(builtin_cmdline, "nokaslr");
-	if (str == builtin_cmdline || (str > builtin_cmdline && *(str - 1) == ' '))
+	if (str == builtin_cmdline || (str > builtin_cmdline && *(str - 1) == ' ')) {
+		pr_info(message, "nokaslr", "built-in");
 		return true;
+	}
 
 	str = strstr(boot_command_line, "nokaslr");
-	if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' '))
+	if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' ')) {
+		pr_info(message, "nokaslr", "boot");
 		return true;
+	}
 
 #ifdef CONFIG_HIBERNATION
 	str = strstr(builtin_cmdline, "nohibernate");
@@ -165,17 +169,23 @@ static inline __init bool kaslr_disabled(void)
 		return false;
 
 	str = strstr(builtin_cmdline, "resume=");
-	if (str == builtin_cmdline || (str > builtin_cmdline && *(str - 1) == ' '))
+	if (str == builtin_cmdline || (str > builtin_cmdline && *(str - 1) == ' ')) {
+		pr_info(message, "resume=", "built-in");
 		return true;
+	}
 
 	str = strstr(boot_command_line, "resume=");
-	if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' '))
+	if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' ')) {
+		pr_info(message, "resume=", "boot");
 		return true;
+	}
 #endif
 
 	str = strstr(boot_command_line, "kexec_file");
-	if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' '))
+	if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' ')) {
+		pr_info(message, "kexec_file", "boot");
 		return true;
+	}
 
 	return false;
 }
-- 
2.50.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-13  8:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-03  6:30 [PATCH] loongarch: improve logging of disabling KASLR Yuqian Yang
2026-04-12  4:42 ` kernel test robot
2026-04-12  8:58 ` kernel test robot
2026-04-13  8:29 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome