From patchwork Tue Jan 23 14:53:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13527542 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 6E68AC47258 for ; Tue, 23 Jan 2024 14:56:59 +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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=RkwBjAj5VM5v2p1tkuY9bGwz/mB71agn1VBKgyHR5f0=; b=MG6n6lRC9WoVKmxpq/95U66Ab7 vm01X5WyLEKAB3RJVKKj9lXfOZ5CdW8vsGJoVQHI8JlpuxfScWflK2i/GQHfscrRYNy1ioeRAgJbv 41V/0e1plH9z8jYA4yGJ22QZHJAJc/sCwADD98OgTTh9gJ4CBS1t8Rb7Bp0QbDtUksXX48PNtv33Q I03d4ML0evgscD5lqrhoHmolfRyjljY8bCPY3KpCn8AG1tZH/d8mfGGPUo4icuHI1QHX5kDigrjZW 1fOcrYHIWxYyNBfCnxyGQGpmW0ZW1Snu4/qfpI8kcayn68FDIwL50GX9zN7ckibfigUIcdTzzePSm bYO1vTYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSICO-00Gub6-02; Tue, 23 Jan 2024 14:56:24 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSIBG-00Gtvz-32 for linux-arm-kernel@lists.infradead.org; Tue, 23 Jan 2024 14:55:24 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-33941f7e299so461306f8f.0 for ; Tue, 23 Jan 2024 06:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706021706; x=1706626506; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=u5Ytiqm7DJK16NBOWkHGv3NwmmxkyHPu/nv4smY9SHw=; b=S1gK2fJw55C0Ey/lX72c2MhNRVfzZE5TuYmKZH67WZYzjDwqf/ZkrsKvsJAxOeF0HS hAvFcPOdp3xgGzk831YHOIzCVJeHU3D42OYPy8cxUbhiwZvnMw3TXUXGQqFPelQfFNAZ 2tAma4L/qdavvxGNlfXDxI9wd9GU593/rra4+++qKeLhnLmZQ6tlB/9ucLkHe9PMoX/S X3IfATm79mJ97WSwCMiN5BPVMQpK5DR5zdDBo58us+0vcdf1GzCKzTV4j5kEL+r6SUpn wDLw51ZJeY9nPx9E181K/R8RZ3zprj3wuCrywbsTcI/uRCplvf1RCwyspDi65GPXOIbp jAAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706021706; x=1706626506; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u5Ytiqm7DJK16NBOWkHGv3NwmmxkyHPu/nv4smY9SHw=; b=vcP2uyOT2CjNXrQUad+uFyK4rFdHrM2HwX4KhqR6wgtJ+XbxfVKWAaVNeG8Hvjd0pC oyI2+V/BdCczBh1NaLaqs+mbd4Hd4lwt9eATYbwybSK3fN2Ad7uehFfyOaLnGep5qLzw IkXcnDX7eT9Fopc8qXSEsAcyr3Q/WmmsBzAdA+qPkysOoWaRYuUvmdRiYc9ojq4dp0bd gciaXBzlnyP1XLKvz9HI3Gv4mwTMt5P2NxNgZX0qf5+9GQ3RuAjgZiMEDAonOth9++HG c03M1ZiS19W3afurxxJ0MzYUjx6ZNcALb8rVU/8wIWzjfcc0sQ9/IdWmrlJMKebqVsfx 2kmw== X-Gm-Message-State: AOJu0YwhI90oLyluMYZLQwSPe+61Mu1AKA5VNQqUj3QOlcO5xhQPcvtH SKiQsGF4peZf9XLpUsPjnG9ZuwG6pT3txAH0UOA8IjJcA0BQ51VgzPUOOESnJe+xN3PS/OFJmAF GC1dnLtv1S5gjGjFCBU4rA7QfQl1fmYab7MQHkg4avyVma1oBQSvBxzFV74L8E1K/Q40/kq308q aizZWFHA+BNPTNQ61k/+1SLGrPl0TOWi2GHP+bTcuA X-Google-Smtp-Source: AGHT+IEuPt2stG/N6BSal7k5ZGPaDygWtpeGvnjTPB4Fp/0FkaZwBL1P0N3exHpnGuKdEGtCV7inaHJ3 X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:6000:1f0b:b0:339:45ec:a004 with SMTP id bv11-20020a0560001f0b00b0033945eca004mr2349wrb.4.1706021706304; Tue, 23 Jan 2024 06:55:06 -0800 (PST) Date: Tue, 23 Jan 2024 15:53:18 +0100 In-Reply-To: <20240123145258.1462979-52-ardb+git@google.com> Mime-Version: 1.0 References: <20240123145258.1462979-52-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1646; i=ardb@kernel.org; h=from:subject; bh=xxBqTnYojIEb8ydbpndpvYYfpJ0Y7OfGgXRsNkNYvt0=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXX9pftJqft1WudwimUua3z9/W34LC2H5Lgv7e+/6otem tXz4JpfRykLgxgHg6yYIovA7L/vdp6eKFXrPEsWZg4rE8gQBi5OAZhIsD8jw4drr+Yd7G83PCnf vqp6Y95HlZMl0jULRGZoJmZGKl+64sPwP9Lkc6J8525WvYNmxXwq5n1Srz7eW/wz9PYVfX4OqTf cPAA= X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240123145258.1462979-71-ardb+git@google.com> Subject: [PATCH v7 19/50] arm64: idreg-override: Create a pseudo feature for rodata=off From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240123_065515_021897_0B836FBE X-CRM114-Status: GOOD ( 13.15 ) 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 From: Ard Biesheuvel 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 e309255b7f04..03c34242bfc7 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -17,6 +17,7 @@ #define ARM64_SW_FEATURE_OVERRIDE_NOKASLR 0 #define ARM64_SW_FEATURE_OVERRIDE_HVHE 4 +#define ARM64_SW_FEATURE_OVERRIDE_RODATA_OFF 8 #ifndef __ASSEMBLY__ diff --git a/arch/arm64/kernel/pi/idreg-override.c b/arch/arm64/kernel/pi/idreg-override.c index f9e05c10faab..e4bcabcc6860 100644 --- a/arch/arm64/kernel/pi/idreg-override.c +++ b/arch/arm64/kernel/pi/idreg-override.c @@ -159,6 +159,7 @@ static const struct ftr_set_desc sw_features __prel64_initconst = { .fields = { FIELD("nokaslr", ARM64_SW_FEATURE_OVERRIDE_NOKASLR, NULL), FIELD("hvhe", ARM64_SW_FEATURE_OVERRIDE_HVHE, hvhe_filter), + FIELD("rodataoff", ARM64_SW_FEATURE_OVERRIDE_RODATA_OFF, NULL), {} }, }; @@ -190,6 +191,7 @@ static const struct { { "arm64.nomops", "id_aa64isar2.mops=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)