From: ykaukab@suse.de (Mian Yousaf Kaukab)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/6] arm64: kpti: move check for non-vulnerable CPUs to a function
Date: Tue, 7 Aug 2018 20:14:14 +0200 [thread overview]
Message-ID: <20180807181419.15690-2-ykaukab@suse.de> (raw)
In-Reply-To: <20180807181419.15690-1-ykaukab@suse.de>
Prepare to call it in generic cpu vulnerabilities support.
Signed-off-by: Mian Yousaf Kaukab <ykaukab@suse.de>
---
arch/arm64/include/asm/cpufeature.h | 16 ++++++++++++++++
arch/arm64/kernel/cpufeature.c | 9 +--------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 1717ba1db35d..0b0b5b3e36ba 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -530,6 +530,22 @@ void arm64_set_ssbd_mitigation(bool state);
static inline void arm64_set_ssbd_mitigation(bool state) {}
#endif
+static inline bool is_cpu_meltdown_safe(void)
+{
+ /* List of CPUs that are not vulnerable and don't need KPTI */
+ static const struct midr_range kpti_safe_list[] = {
+ MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2),
+ MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN),
+ { /* sentinel */ }
+ };
+
+ /* Don't force KPTI for CPUs that are not vulnerable */
+ if (is_midr_in_range_list(read_cpuid_id(), kpti_safe_list))
+ return true;
+
+ return false;
+}
+
#endif /* __ASSEMBLY__ */
#endif
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index e238b7932096..6a94f8bce35a 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -865,12 +865,6 @@ static int __kpti_forced; /* 0: not forced, >0: forced on, <0: forced off */
static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
int scope)
{
- /* List of CPUs that are not vulnerable and don't need KPTI */
- static const struct midr_range kpti_safe_list[] = {
- MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2),
- MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN),
- { /* sentinel */ }
- };
char const *str = "command line option";
/*
@@ -894,8 +888,7 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE))
return true;
- /* Don't force KPTI for CPUs that are not vulnerable */
- if (is_midr_in_range_list(read_cpuid_id(), kpti_safe_list))
+ if (is_cpu_meltdown_safe())
return false;
/* Defer to CPU feature registers */
--
2.11.0
next prev parent reply other threads:[~2018-08-07 18:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-07 18:14 [PATCH 0/6] arm64: add support for generic cpu vulnerabilities Mian Yousaf Kaukab
2018-08-07 18:14 ` Mian Yousaf Kaukab [this message]
2018-08-07 18:14 ` [PATCH 2/6] arm64: add sysfs vulnerability show for meltdown Mian Yousaf Kaukab
2018-08-07 18:14 ` [PATCH 3/6] arm64: add sysfs vulnerability show for spectre v1 Mian Yousaf Kaukab
2018-08-07 18:14 ` [PATCH 4/6] arm64: add sysfs vulnerability show for spectre v2 Mian Yousaf Kaukab
2018-08-07 18:14 ` [PATCH 5/6] arm64: add sysfs vulnerability show for speculative store bypass Mian Yousaf Kaukab
2018-08-07 18:14 ` [PATCH 6/6] arm64: enable generic CPU vulnerabilites support Mian Yousaf Kaukab
-- strict thread matches above, loose matches on Subject: below --
2018-12-06 23:44 [PATCH 0/6] add system vulnerability sysfs entries Jeremy Linton
2018-12-06 23:44 ` [PATCH 1/6] arm64: kpti: move check for non-vulnerable CPUs to a function Jeremy Linton
2018-12-13 9:13 ` Julien Thierry
2018-12-12 14:36 ` Jeremy Linton
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=20180807181419.15690-2-ykaukab@suse.de \
--to=ykaukab@suse.de \
--cc=linux-arm-kernel@lists.infradead.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