From patchwork Tue Mar 7 14:04:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13163778 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 1EDE6C678D5 for ; Tue, 7 Mar 2023 14:37:12 +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=7qR+cY6ZrHE90aIjqY805Rta8sQwAFH08Mj3NshIDug=; b=jJV553+fzma/7y hvEI2lq9LzlLi7YMyzqVCEgWxaL/Czp5jQdwSgEUCz563Xeh3G1dsegVus0xwXozjHN5cTmrkgLVH yGDkuqTMpdkzwUd31a2ca/FjZ1vW0mJUKatHcZBsCL/WCzySYdJED3A+7sPfMB/VINs8pMcxWrUpr Ek/KuRCdWhvvWZNrlPfzu50xOW5MgX1ZDAu54bPNyEWNA2xIrduY6udvqlDeaujslWVxzDAnUWCYF sPq51cDEdoloY+udqkPv5nPvE3nmHiBOLq7bq9WJq43LQJT3L35DcyoR5TnbiCFKZOdXMc+IkBBFN INs0/THEo+q73svMFF0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZYQ6-000qoQ-FU; Tue, 07 Mar 2023 14:36:02 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZXyp-000eU0-3i for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 14:07:52 +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 dfw.source.kernel.org (Postfix) with ESMTPS id A0A2561454; Tue, 7 Mar 2023 14:07:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 783E6C4339C; Tue, 7 Mar 2023 14:07:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678198070; bh=MgAlosplvEwsGH+1fNbCRsUtWRN8yNAPEnQin/pEaZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qRF8W2LQV8FQJYsf48awPPQKBb2WBFb3V8LC3NgRdG6rMtcklRKsz4b3DhAdSx0kB UieAWGEFDo/F15RpQrialQSBIZ4A/yFGOmOJm5JakllD6YKbAqsrrLsSZF0XxDbzqW h34C0isa4ikt652AMToJIHGXAxYG4gfkj9B6zrMCRUCjHuBXPPWsH+64wuUg/Gfsl2 v4pwULIaBv/OF80BI+78CMNC2TmMEQZv/EpggJpA73TQPSIlKnB0iZnBYSsOrcHma/ 0Zr82T3auhRB2Hi08WyE8YQsqmvroFGOpkwVOyKzLtYGt/as+Jpb9u/FGnkPRToLtu pkYFUxVCAe75A== From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook Subject: [PATCH v3 30/60] arm64: idreg-override: Create a pseudo feature for rodata=off Date: Tue, 7 Mar 2023 15:04:52 +0100 Message-Id: <20230307140522.2311461-31-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307140522.2311461-1-ardb@kernel.org> References: <20230307140522.2311461-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1627; i=ardb@kernel.org; h=from:subject; bh=MgAlosplvEwsGH+1fNbCRsUtWRN8yNAPEnQin/pEaZM=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIYXdxeubg3x1yZqWt9NVJ1zmKVvi+f2c1RTpQ2lX0l/IZ t/tZhbqKGVhEONgkBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABOZ/4rhf+b3hX7sqaL/Rb63 9b8I230r59bsmGvaHmvvWyUlx3/OOsjwP4/v38b9G/xuOedYuxTHsAe813efwa0ZviyLPePWw8j 7nAA= 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-20230307_060751_269291_5529C7B7 X-CRM114-Status: GOOD ( 14.08 ) 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 Add rodata=off to the set of kernel command line options that is parsed early using the CPU feature override detection code, so we can easily refer to it when creating the kernel mapping. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/cpufeature.h | 1 + arch/arm64/kernel/pi/idreg-override.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index bc10098901808c00..edc7733aa49846b2 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -16,6 +16,7 @@ #define cpu_feature(x) KERNEL_HWCAP_ ## x #define ARM64_SW_FEATURE_OVERRIDE_NOKASLR 0 +#define ARM64_SW_FEATURE_OVERRIDE_RODATA_OFF 4 #ifndef __ASSEMBLY__ diff --git a/arch/arm64/kernel/pi/idreg-override.c b/arch/arm64/kernel/pi/idreg-override.c index 4e76db6eb72c2087..6c547cccaf6a9e9c 100644 --- a/arch/arm64/kernel/pi/idreg-override.c +++ b/arch/arm64/kernel/pi/idreg-override.c @@ -151,6 +151,7 @@ static const struct ftr_set_desc sw_features __prel64_initconst = { .override = &arm64_sw_feature_override, .fields = { FIELD("nokaslr", ARM64_SW_FEATURE_OVERRIDE_NOKASLR, NULL), + FIELD("rodataoff", ARM64_SW_FEATURE_OVERRIDE_RODATA_OFF, NULL), {} }, }; @@ -183,6 +184,7 @@ static const struct { "id_aa64isar2.gpa3=0 id_aa64isar2.apa3=0" }, { "arm64.nomte", "id_aa64pfr1.mte=0" }, { "nokaslr", "arm64_sw.nokaslr=1" }, + { "rodata=off", "arm64_sw.rodataoff=1" }, }; static int __init parse_hexdigit(const char *p, u64 *v)