From: <yee.lee@mediatek.com>
To: <linux-kernel@vger.kernel.org>
Cc: <nicholas.Tang@mediatek.com>, <Kuan-Ying.lee@mediatek.com>,
<chinwen.chang@mediatek.com>, Yee Lee <yee.lee@mediatek.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Marc Zyngier <maz@kernel.org>,
David Brazdil <dbrazdil@google.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ionela Voinescu <ionela.voinescu@arm.com>,
Amit Daniel Kachhap <amit.kachhap@arm.com>,
Quentin Perret <qperret@google.com>,
Andrew Scull <ascull@google.com>,
James Morse <james.morse@arm.com>, Fuad Tabba <tabba@google.com>,
"moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)"
<linux-arm-kernel@lists.infradead.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@lists.infradead.org>
Subject: [PATCH 1/1] arm64/cpufeature: Add option to disable mte support
Date: Wed, 28 Jul 2021 17:42:58 +0800 [thread overview]
Message-ID: <20210728094302.9949-2-yee.lee@mediatek.com> (raw)
In-Reply-To: <20210728094302.9949-1-yee.lee@mediatek.com>
From: Yee Lee <yee.lee@mediatek.com>
Add a static key to exapnd the logic of system_supports_mte().
This function controls mte enablement in both EL1 and EL0.
The static key, "arm64_mte_support" is default true and can
be disabled via the early_param.
Signed-off-by: Yee Lee <yee.lee@mediatek.com>
---
arch/arm64/include/asm/cpufeature.h | 4 +++-
arch/arm64/kernel/cpufeature.c | 13 +++++++++++++
arch/arm64/kernel/image-vars.h | 3 +++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 9bb9d11750d7..0e5c82f2e012 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -420,6 +420,7 @@ static __always_inline bool is_hyp_code(void)
extern DECLARE_BITMAP(cpu_hwcaps, ARM64_NCAPS);
extern struct static_key_false cpu_hwcap_keys[ARM64_NCAPS];
extern struct static_key_false arm64_const_caps_ready;
+extern struct static_key_true arm64_mte_support;
/* ARM64 CAPS + alternative_cb */
#define ARM64_NPATCHABLE (ARM64_NCAPS + 1)
@@ -756,7 +757,8 @@ static __always_inline bool system_uses_irq_prio_masking(void)
static inline bool system_supports_mte(void)
{
return IS_ENABLED(CONFIG_ARM64_MTE) &&
- cpus_have_const_cap(ARM64_MTE);
+ cpus_have_const_cap(ARM64_MTE) &&
+ static_branch_likely(&arm64_mte_support);
}
static inline bool system_has_prio_mask_debugging(void)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 0ead8bfedf20..b1602ad3d7c0 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1840,9 +1840,22 @@ static void bti_enable(const struct arm64_cpu_capabilities *__unused)
}
#endif /* CONFIG_ARM64_BTI */
+DEFINE_STATIC_KEY_TRUE(arm64_mte_support);
+EXPORT_SYMBOL(arm64_mte_support);
#ifdef CONFIG_ARM64_MTE
+static int __init disable_arm64_mte_support(char *str)
+{
+ static_branch_disable(&arm64_mte_support);
+ return 0;
+}
+early_param("arm64_mte_not_support", disable_arm64_mte_support);
+
static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap)
{
+ if(!system_supports_mte()){
+ pr_info("MTE is disabled since system does not support.\n");
+ return ;
+ }
/*
* Clear the tags in the zero page. This needs to be done via the
* linear map which has the Tagged attribute.
diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h
index c96a9a0043bf..04cf30ec84e7 100644
--- a/arch/arm64/kernel/image-vars.h
+++ b/arch/arm64/kernel/image-vars.h
@@ -83,6 +83,9 @@ KVM_NVHE_ALIAS(__icache_flags);
KVM_NVHE_ALIAS(arm64_const_caps_ready);
KVM_NVHE_ALIAS(cpu_hwcap_keys);
+/* Static key which indicates if system supports mte */
+KVM_NVHE_ALIAS(arm64_mte_support);
+
/* Static keys which are set if a vGIC trap should be handled in hyp. */
KVM_NVHE_ALIAS(vgic_v2_cpuif_trap);
KVM_NVHE_ALIAS(vgic_v3_cpuif_trap);
--
2.18.0
next prev parent reply other threads:[~2021-07-28 9:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 9:42 [PATCH 0/1] arm64/cpufeature: Add an option for mte support yee.lee
2021-07-28 9:42 ` yee.lee [this message]
2021-07-28 9:59 ` [PATCH 1/1] arm64/cpufeature: Add option to disable " Suzuki K Poulose
2021-07-28 10:05 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210728094302.9949-2-yee.lee@mediatek.com \
--to=yee.lee@mediatek.com \
--cc=Kuan-Ying.lee@mediatek.com \
--cc=amit.kachhap@arm.com \
--cc=ascull@google.com \
--cc=catalin.marinas@arm.com \
--cc=chinwen.chang@mediatek.com \
--cc=dbrazdil@google.com \
--cc=ionela.voinescu@arm.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=maz@kernel.org \
--cc=nicholas.Tang@mediatek.com \
--cc=qperret@google.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).