From patchwork Fri Jul 1 13:04:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12903274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8072FC433EF for ; Fri, 1 Jul 2022 13:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2lShKAmbHtYKpiIQCZkenNGAQcZQ+RLB9dtO9xHp3lY=; b=akPQ6IQZLT2rD6 X1LBipgUfixcAJ0yLp9qc7nn8o3E8af83vvg5hgtqyVJRpxnL53h+icjKB5Gcw2YqwmFuLx72K2eG Znb+7Cd4dOAabYb0Rzk0AUKf5Y7D8AsGXwU7QHDNij4xkUILYmlDAfM0FjvlU2S3catuG0NaMX0GH Nf7iCabwmzCaAwJJlccK67Z2aimHLsr085rNSvFj4VW7GtIFb35VmqCXwlBo4MBRA1b4s5i+ewIjg qIT1URc9f6ez84kEvBOJipkN6KS5vs7EtUxG/EYol/iB8wOv154NW4Lv/BxPSkoMPNfWGTg/Ype68 yl/RpJQK0myQnM1+gaCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7GKw-004vtX-Ns; Fri, 01 Jul 2022 13:05:30 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7GKT-004vgJ-Ed for linux-arm-kernel@lists.infradead.org; Fri, 01 Jul 2022 13:05:03 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C1432B8302D; Fri, 1 Jul 2022 13:04:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C159C341C7; Fri, 1 Jul 2022 13:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656680698; bh=hhZG/Pphu9S39tBBJMD1NPdYwMIaQB5X07LeYGstpG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ItSrPBzFiEfj7Mhn4MVUEgXLd+mZRb/FAIIK7m/1CcQ876CLXfUc8f6qWG7VH2/NN OaWhayZrtPjH0DJk/4m9EcjXQt5NgL23zosouhNo9THj9ojs4PLk5ehVEZGZLlheTE QXcJDmInW4aaWz4nAbRLUK5ODnoqGfEIThLiZldrdCTFamsZ2VUBPYdIbW/ktJQGnL +GETUufvmWlxpR2L/BfnUaHpotqm4fuKfByOKmic+DhF5izAp4OInLHoBgF/ywxoww ZifFzZ7Q25qMO3uDE80IWXWhuBqjd2KXlJIdb/Dq6kikRLavxtwAaFGfSQqnsKoGY2 /Zm4eS7iHc19Q== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Marc Zyngier , Will Deacon , Mark Rutland , Kees Cook , Catalin Marinas , Mark Brown , Anshuman Khandual Subject: [PATCH v6 1/9] arm64: kaslr: use an ordinary command line param for nokaslr Date: Fri, 1 Jul 2022 15:04:36 +0200 Message-Id: <20220701130444.2945106-2-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220701130444.2945106-1-ardb@kernel.org> References: <20220701130444.2945106-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2447; h=from:subject; bh=hhZG/Pphu9S39tBBJMD1NPdYwMIaQB5X07LeYGstpG0=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBivvDc0/5ywsCzKxzJlx16rk6+tsOu+v1+IcWv37Ak 6/cwu/CJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYr7w3AAKCRDDTyI5ktmPJGzhDA C+mRBCDOvhVZoPCumTAFuGtkw6HezcljYvX0Dd+jBHw1++saGqMEo3Ot2669ZyrhYWohXzWSLBhhau bUUiMuZ/n31+6+40EgDt2tJsWDH09oia2bNwTOxUgcr89Bth9QuojMy35AJs2W82NNupVvzZO/rnHJ H5VfoIEsuYnyhqfEmUqB3m9R6MA7cdDr/tXppwjkFLCPVnHgoWyuLytS4qeZfHfQKPCg9YpSmAvjKt f9QAWvOm06AZ56AzfiVKrZo7DP6idQcB590V1UbDn5QCmyw3Mm4a2JR73Jn9D5DQZait/LFtUY/rl2 tMkHj1uyB6Zppg8xP8AbOYXH3xahsEpXPidWw8AIZbhHiDd7LcbdHKjSQuwMXMRLNuiE3qpK+YkrqP 02vpjG57ud/ZhgqarUszdJ+1JlfXEr246fgppSyd9J0ln1ll+/ZBrWbEGv5EG3OnVx7MWb7yGf085t FFv1GGYarl0iFN/2yD2ROMbAIj4H+Wdlj2Ec9IaTaMZko= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220701_060501_859791_F545BE81 X-CRM114-Status: GOOD ( 16.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Mark Brown --- arch/arm64/kernel/idreg-override.c | 15 --------------- arch/arm64/kernel/kaslr.c | 6 ++++-- 2 files changed, 4 insertions(+), 17 deletions(-) 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 #include #include +#include #include #include #include @@ -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; }