From patchwork Fri Nov 11 17:11:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13040644 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 35FA9C4332F for ; Fri, 11 Nov 2022 17:30:33 +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=elqNKG87J1QNs/JFrUFcIlOYJLQzbKT9JjPHgRHhlTA=; b=ThO8jI4EaKsKzq BcAN/jZ65KImdmvAo5evYDMmmngeg/OIguOjXsn5MSgSlIUVaHbcXdWNTZONhzXlk7jv9MwZcxCrN Uik3nE19A/6APrZCS9NGGtb/zqxAweGoA2Vns+7vM/mLa6g2KVPgoo8pl7WlV2dlMINIG4Hm+Am10 v3ctLQP3UMqO1kN5MayoT9JLIJ4muNBroEexYy9Q07JogLMnOrP1amzXbXkNUfhPrwKK41UmLag0i HI6ljmEEmJg7Ad7AcvF+9+ekm5sLYjtCT19NhrUpyJId8SaDHqOQNTZBGYI6P0sL2t7rWpfmh1W0x pf+W1shOgOE9TieeaNww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1otXqK-00HGXo-B6; Fri, 11 Nov 2022 17:29:28 +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 1otXae-00H7zF-87 for linux-arm-kernel@lists.infradead.org; Fri, 11 Nov 2022 17:13:18 +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 D5C2DB8267A; Fri, 11 Nov 2022 17:13:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1748C433D6; Fri, 11 Nov 2022 17:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668186793; bh=2L8qq3K6u+GRcQSYfqhjGnpNpR+PijC/5NMw6UtzX7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bsPODVAi6HtynEkFOdx6tFecrOq5h1XJZkShmdAdQwu1ZaxIwOUOgtciSw6y7kdG1 lI1ZwIAfxZ7Vwfd+JawbvrDpevbjlUVQJsgwOEmN37r4K8iQr04gp8cYdmOfwWku6j c6Kvo0lcElavm9DueL9hPeLTz9J8SPFgH1CE1GZ0Dp8RjyzxOfc2RvgM0Mlu1fsB8f 3RHcl/utp0nEllQxz/0P/MqEUSAknv5ScYzbxAy8PK8hoqzkFBATWyOZlNOMu9kcPB 57PIR/YlSQKB7/k/1j7SlPIsM0SOoAZks3TPCfks7ff6nUNvajkU9H3jWcINd2Emyx 0V2LfC/uHC1aQ== 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 v7 24/33] arm64: idreg-override: Create a pseudo feature for rodata=off Date: Fri, 11 Nov 2022 18:11:52 +0100 Message-Id: <20221111171201.2088501-25-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221111171201.2088501-1-ardb@kernel.org> References: <20221111171201.2088501-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1642; i=ardb@kernel.org; h=from:subject; bh=2L8qq3K6u+GRcQSYfqhjGnpNpR+PijC/5NMw6UtzX7E=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjboJR9BznuYr1gP5ZGeSxJ1m1etUnyN+MXK0zCmiJ cNGUNhmJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY26CUQAKCRDDTyI5ktmPJHbEC/ wIfUMsg5/cxXsuWsiB6GAgyghFDs6xXCUscA8aOW8x3jtYnzTYNq6furkWuortWtxE+ucxJSXGFwti 7T51YFMItH7xi2D6n8awEFBGOANJ/rgciY3Z2oqqbXaSEAs7ssJSCxjis/85frZJW+o0cZywVuAkAG u+XXCegn1OOcDYlkVTp6OKT3/a1NzZJ1LYODgzkHz+DHANLiJQjU3pZ72i1TQ5FHSKrLZzu1HC1MFx ioYFeXwF9UOiQs152ja8ajWWSQKkhLCqnjffBBA6Evkn6TinUeyR7I7FS5QydLPV3KwpHB00A6NrnV pJz+xCYmAJmRJW6wzHRT/qNoiyMAdxaAdwvSG/4w2RtUlPVjb3OOlXxjmyAMyJDLm3DikV8uRENFCB +0KahcRHAluRZcskouIrGevzqdrnCsGVfmlXx35lC4wAOcQG3UOf8weNdc2TywmLIF7QzYKoPfljV5 9nRWhLiK7HA6sMIzpoxCcDecOP94jRBzeqxEQPjL0IcTA= 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-20221111_091316_591641_38E4FF72 X-CRM114-Status: GOOD ( 13.55 ) 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 f44a7860636fd411..b8c7a2d13bbe44e2 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 c21d1e9f43a11ba7..e524d36d8fc1526f 100644 --- a/arch/arm64/kernel/pi/idreg-override.c +++ b/arch/arm64/kernel/pi/idreg-override.c @@ -133,6 +133,7 @@ DEFINE_OVERRIDE(5, smfr0, "id_aa64smfr0", id_aa64smfr0_override, DEFINE_OVERRIDE(6, sw_features, "arm64_sw", arm64_sw_feature_override, FIELD("nokaslr", ARM64_SW_FEATURE_OVERRIDE_NOKASLR), + FIELD("rodataoff", ARM64_SW_FEATURE_OVERRIDE_RODATA_OFF), {}); /* @@ -164,6 +165,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 find_field(const char *cmdline, char *opt, int len,