diff mbox series

[v6,1/9] arm64: kaslr: use an ordinary command line param for nokaslr

Message ID 20220701130444.2945106-2-ardb@kernel.org (mailing list archive)
State New, archived
Headers show
Series arm64: add support for WXN | expand

Commit Message

Ard Biesheuvel July 1, 2022, 1:04 p.m. UTC
We no longer need to rely on the idreg-override hack to parse the
'nokaslr' command line parameter, given that we now parse it way earlier
already, before the kernel is even mapped. So for later access to its
value, we can just use core_param() instead.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm64/kernel/idreg-override.c | 15 ---------------
 arch/arm64/kernel/kaslr.c          |  6 ++++--
 2 files changed, 4 insertions(+), 17 deletions(-)

Comments

Mark Brown July 1, 2022, 2:07 p.m. UTC | #1
On Fri, Jul 01, 2022 at 03:04:36PM +0200, Ard Biesheuvel wrote:
> We no longer need to rely on the idreg-override hack to parse the
> 'nokaslr' command line parameter, given that we now parse it way earlier
> already, before the kernel is even mapped. So for later access to its
> value, we can just use core_param() instead.

Reviewed-by: Mark Brown <broonie@kernel.org>
diff mbox series

Patch

diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c
index f92836e196e5..52f858aeba81 100644
--- a/arch/arm64/kernel/idreg-override.c
+++ b/arch/arm64/kernel/idreg-override.c
@@ -81,25 +81,11 @@  static const struct ftr_set_desc isar2 __initconst = {
 	},
 };
 
-extern struct arm64_ftr_override kaslr_feature_override;
-
-static const struct ftr_set_desc kaslr __initconst = {
-	.name		= "kaslr",
-#ifdef CONFIG_RANDOMIZE_BASE
-	.override	= &kaslr_feature_override,
-#endif
-	.fields		= {
-		{ "disabled", 0 },
-		{}
-	},
-};
-
 static const struct ftr_set_desc * const regs[] __initconst = {
 	&mmfr1,
 	&pfr1,
 	&isar1,
 	&isar2,
-	&kaslr,
 };
 
 static const struct {
@@ -114,7 +100,6 @@  static const struct {
 	  "id_aa64isar1.api=0 id_aa64isar1.apa=0 "
 	  "id_aa64isar2.gpa3=0 id_aa64isar2.apa3=0"	   },
 	{ "arm64.nomte",		"id_aa64pfr1.mte=0" },
-	{ "nokaslr",			"kaslr.disabled=1" },
 };
 
 static int __init find_field(const char *cmdline,
diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c
index 325455d16dbc..bcbcca938da8 100644
--- a/arch/arm64/kernel/kaslr.c
+++ b/arch/arm64/kernel/kaslr.c
@@ -8,6 +8,7 @@ 
 #include <linux/init.h>
 #include <linux/libfdt.h>
 #include <linux/mm_types.h>
+#include <linux/moduleparam.h>
 #include <linux/sched.h>
 #include <linux/types.h>
 #include <linux/pgtable.h>
@@ -23,7 +24,8 @@ 
 u64 __ro_after_init module_alloc_base;
 u16 __initdata memstart_offset_seed;
 
-struct arm64_ftr_override kaslr_feature_override __initdata;
+static bool nokaslr;
+core_param(nokaslr, nokaslr, bool, 0);
 
 static int __init kaslr_init(void)
 {
@@ -36,7 +38,7 @@  static int __init kaslr_init(void)
 	 */
 	module_alloc_base = (u64)_etext - MODULES_VSIZE;
 
-	if (kaslr_feature_override.val & kaslr_feature_override.mask & 0xf) {
+	if (nokaslr) {
 		pr_info("KASLR disabled on command line\n");
 		return 0;
 	}