From nobody Mon Jun 15 18:07:13 2026 Received: from smtpbg150.qq.com (smtpbg150.qq.com [18.132.163.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 630E323C4F2 for ; Mon, 13 Apr 2026 03:14:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.132.163.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776050057; cv=none; b=EHrO/X97o6w610Ffh/M4y/rc39eyIbe/4DuGFi3rnJeCkPn9JusyTpjItPk+/cbnnvCyuuKSPSMcRrZOEJQ4w9PpTRJAaIe3Ak2fczrQ9z9gD0HF1RB5lKrkYMFWJoylTiuqI7mAW610VSDgRR2qxi0pAOuF97jkWaTVy+eaWXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776050057; c=relaxed/simple; bh=+smC1gZDSIEm3W6V8Xxx52e3LFFAgqZ3sGaduwuaZiA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Xb0U9ajNeMQAmojqeWDMbLVLfv7Ah/9tRheqvRngRlOb/wtoaqCFjGOk1idpKA+v5ks+KoiKmtSPVCEeUDwkADCNq8a0iEZpEvD9CzugpWJQSxY+MXblFrQbgfT+XhO3XVb4c97tVmuTMtDfxjyn7tWsJ3xiC96wQN2IQ0OgS60= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b=gKZ6qI7h; arc=none smtp.client-ip=18.132.163.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b="gKZ6qI7h" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1776050012; bh=DWpIV1nTLf0MNO8v5X732tsg/2MN5L1BVAcTW6s6HCg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=gKZ6qI7hjVk0dck15wtpyZmeoUWpwhEwG3rMLJkdYnPFK+YftJidT5/JdUhplCD9p p8i3m8ErTj2WqdaOkCOp9HPpzH+XAeAtEJNdbRD+mGiJ9jwcI79QyK1UhNqtK3y9p6 IAC+C0mVjX83dI7DxrSL1Q4/lnUJsyK1cStvGKS8= X-QQ-mid: zesmtpip4t1776049965ta130dce6 X-QQ-Originating-IP: SOQw2YUK0O270g3KpEK8mldnNmYVX3J0Ts2Rw3wHC4I= Received: from yangyuqian ( [localhost]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 13 Apr 2026 11:12:38 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 16364149023987049018 EX-QQ-RecipientCnt: 8 From: Yuqian Yang To: Huacai Chen Cc: WANG Xuerui , Cheng Nie , Wentao Guan , Dandan Zhang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, Yuqian Yang Subject: [PATCH v2] LoongArch: improve logging of disabling KASLR Date: Mon, 13 Apr 2026 11:12:36 +0800 Message-ID: <80CA78395583F396+20260413031236.2512416-1-yangyuqian@uniontech.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: zesmtpip:uniontech.com:qybglogicsvrgz:qybglogicsvrgz3a-1 X-QQ-XMAILINFO: MIiZxjTKFdexjevKf3mGfO7I1TFSnVNQou8JDz1QcsMqOxgT+L618UGD joDo5jzX/M3m6dXgJesyMuf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Q-RECHKSPAM: 0 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Yuqian Yang --- 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/reloc= ate.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) =20 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); =20 @@ -138,14 +137,19 @@ static inline __init bool kaslr_disabled(void) { char *str; const char *builtin_cmdline =3D CONFIG_CMDLINE; +#define LOONGARCH_KASLR_DISABLED_MESSAGE "KASLR is disabled by %s in %s cm= dline.\n" =20 str =3D strstr(builtin_cmdline, "nokaslr"); - if (str =3D=3D builtin_cmdline || (str > builtin_cmdline && *(str - 1) = =3D=3D ' ')) + if (str =3D=3D builtin_cmdline || (str > builtin_cmdline && *(str - 1) = =3D=3D ' ')) { + pr_info(LOONGARCH_KASLR_DISABLED_MESSAGE, "nokaslr", "built-in"); return true; + } =20 str =3D strstr(boot_command_line, "nokaslr"); - if (str =3D=3D boot_command_line || (str > boot_command_line && *(str - 1= ) =3D=3D ' ')) + if (str =3D=3D boot_command_line || (str > boot_command_line && *(str - 1= ) =3D=3D ' ')) { + pr_info(LOONGARCH_KASLR_DISABLED_MESSAGE, "nokaslr", "boot"); return true; + } =20 #ifdef CONFIG_HIBERNATION str =3D strstr(builtin_cmdline, "nohibernate"); @@ -165,19 +169,26 @@ static inline __init bool kaslr_disabled(void) return false; =20 str =3D strstr(builtin_cmdline, "resume=3D"); - if (str =3D=3D builtin_cmdline || (str > builtin_cmdline && *(str - 1) = =3D=3D ' ')) + if (str =3D=3D builtin_cmdline || (str > builtin_cmdline && *(str - 1) = =3D=3D ' ')) { + pr_info(LOONGARCH_KASLR_DISABLED_MESSAGE, "resume=3D", "built-in"); return true; + } =20 str =3D strstr(boot_command_line, "resume=3D"); - if (str =3D=3D boot_command_line || (str > boot_command_line && *(str - 1= ) =3D=3D ' ')) + if (str =3D=3D boot_command_line || (str > boot_command_line && *(str - 1= ) =3D=3D ' ')) { + pr_info(LOONGARCH_KASLR_DISABLED_MESSAGE, "resume=3D", "boot"); return true; + } #endif =20 str =3D strstr(boot_command_line, "kexec_file"); - if (str =3D=3D boot_command_line || (str > boot_command_line && *(str - 1= ) =3D=3D ' ')) + if (str =3D=3D boot_command_line || (str > boot_command_line && *(str - 1= ) =3D=3D ' ')) { + pr_info(LOONGARCH_KASLR_DISABLED_MESSAGE, "kexec_file", "boot"); return true; + } =20 return false; +#undef LOONGARCH_KASLR_DISABLED_MESSAGE } =20 /* Choose a new address for the kernel */ base-commit: e774d5f1bc27a85f858bce7688509e866f8e8a4e --=20 2.50.1