[PATCH] loongarch: improve logging of disabling KASLR.
From: Yuqian Yang
Date: Fri Apr 03 2026 - 02:34:01 EST
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@xxxxxxxxxxxxx>
Signed-off-by: Yuqian Yang <yangyuqian@xxxxxxxxxxxxx>
---
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