From: Huacai Chen <chenhuacai@kernel.org>
To: Yuqian Yang <yangyuqian@uniontech.com>
Cc: WANG Xuerui <kernel@xen0n.name>,
Cheng Nie <niecheng1@uniontech.com>,
Wentao Guan <guanwentao@uniontech.com>,
Dandan Zhang <zhangdandan@uniontech.com>,
loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] LoongArch: improve logging of disabling KASLR
Date: Fri, 17 Apr 2026 11:15:13 +0800 [thread overview]
Message-ID: <CAAhV-H5TmQUjcqCn6b_fXo+Fi9ovtkJNENpRh9ekqbc4xOJA9g@mail.gmail.com> (raw)
In-Reply-To: <80CA78395583F396+20260413031236.2512416-1-yangyuqian@uniontech.com>
Applied with some modifications, thanks.
Huacai
On Mon, Apr 13, 2026 at 11:13 AM Yuqian Yang <yangyuqian@uniontech.com> wrote:
>
> 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>
> ---
>
> Changes since v1:
> * update commit title, loongarch -> LoongArch, remove trailing period.
> * use macro instead of const variable as log message to avoid build error.
>
> arch/loongarch/kernel/relocate.c | 27 +++++++++++++++++++--------
> 1 file changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/arch/loongarch/kernel/relocate.c b/arch/loongarch/kernel/relocate.c
> index 82aa3f0359278..80720175c89dc 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;
> +#define LOONGARCH_KASLR_DISABLED_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(LOONGARCH_KASLR_DISABLED_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(LOONGARCH_KASLR_DISABLED_MESSAGE, "nokaslr", "boot");
> return true;
> + }
>
> #ifdef CONFIG_HIBERNATION
> str = strstr(builtin_cmdline, "nohibernate");
> @@ -165,19 +169,26 @@ 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(LOONGARCH_KASLR_DISABLED_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(LOONGARCH_KASLR_DISABLED_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(LOONGARCH_KASLR_DISABLED_MESSAGE, "kexec_file", "boot");
> return true;
> + }
>
> return false;
> +#undef LOONGARCH_KASLR_DISABLED_MESSAGE
> }
>
> /* Choose a new address for the kernel */
>
> base-commit: e774d5f1bc27a85f858bce7688509e866f8e8a4e
> --
> 2.50.1
>
prev parent reply other threads:[~2026-04-17 3:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 3:12 [PATCH v2] LoongArch: improve logging of disabling KASLR Yuqian Yang
2026-04-17 3:15 ` Huacai Chen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAhV-H5TmQUjcqCn6b_fXo+Fi9ovtkJNENpRh9ekqbc4xOJA9g@mail.gmail.com \
--to=chenhuacai@kernel.org \
--cc=guanwentao@uniontech.com \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=niecheng1@uniontech.com \
--cc=yangyuqian@uniontech.com \
--cc=zhangdandan@uniontech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).