From: tip-bot for Thomas Gleixner <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: torvalds@linuxfoundation.org, dave.hansen@intel.com,
peterz@infradead.org, gregkh@linuxfoundation.org,
will.deacon@arm.com, mingo@kernel.org, tglx@linutronix.de,
linux-kernel@vger.kernel.org, konrad.wilk@oracle.com,
dwmw@amazon.co.uk, hpa@zytor.com, bp@alien8.de
Subject: [tip:x86/pti] x86/cpu: Implement CPU vulnerabilites sysfs functions
Date: Mon, 8 Jan 2018 02:17:01 -0800 [thread overview]
Message-ID: <tip-61dc0f555b5c761cdafb0ba5bd41ecf22d68a4c4@git.kernel.org> (raw)
In-Reply-To: <20180107214913.177414879@linutronix.de>
Commit-ID: 61dc0f555b5c761cdafb0ba5bd41ecf22d68a4c4
Gitweb: https://git.kernel.org/tip/61dc0f555b5c761cdafb0ba5bd41ecf22d68a4c4
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 7 Jan 2018 22:48:01 +0100
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 8 Jan 2018 11:10:40 +0100
x86/cpu: Implement CPU vulnerabilites sysfs functions
Implement the CPU vulnerabilty show functions for meltdown, spectre_v1 and
spectre_v2.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Linus Torvalds <torvalds@linuxfoundation.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Link: https://lkml.kernel.org/r/20180107214913.177414879@linutronix.de
---
arch/x86/Kconfig | 1 +
arch/x86/kernel/cpu/bugs.c | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cd5199d..e23d21a 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -89,6 +89,7 @@ config X86
select GENERIC_CLOCKEVENTS_MIN_ADJUST
select GENERIC_CMOS_UPDATE
select GENERIC_CPU_AUTOPROBE
+ select GENERIC_CPU_VULNERABILITIES
select GENERIC_EARLY_IOREMAP
select GENERIC_FIND_FIRST_BIT
select GENERIC_IOMAP
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index ba0b242..76ad6cb 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -10,6 +10,7 @@
*/
#include <linux/init.h>
#include <linux/utsname.h>
+#include <linux/cpu.h>
#include <asm/bugs.h>
#include <asm/processor.h>
#include <asm/processor-flags.h>
@@ -60,3 +61,31 @@ void __init check_bugs(void)
set_memory_4k((unsigned long)__va(0), 1);
#endif
}
+
+#ifdef CONFIG_SYSFS
+ssize_t cpu_show_meltdown(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ if (!boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN))
+ return sprintf(buf, "Not affected\n");
+ if (boot_cpu_has(X86_FEATURE_PTI))
+ return sprintf(buf, "Mitigation: PTI\n");
+ return sprintf(buf, "Vulnerable\n");
+}
+
+ssize_t cpu_show_spectre_v1(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1))
+ return sprintf(buf, "Not affected\n");
+ return sprintf(buf, "Vulnerable\n");
+}
+
+ssize_t cpu_show_spectre_v2(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
+ return sprintf(buf, "Not affected\n");
+ return sprintf(buf, "Vulnerable\n");
+}
+#endif
prev parent reply other threads:[~2018-01-08 10:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-07 21:47 [patch V2 0/2] sysfs/cpu: Implement generic vulnerabilites directory Thomas Gleixner
2018-01-07 21:48 ` [patch V2 1/2] sysfs/cpu: Add vulnerability folder Thomas Gleixner
2018-01-07 22:14 ` Konrad Rzeszutek Wilk
2018-01-08 6:53 ` Greg Kroah-Hartman
2018-01-08 7:29 ` Dominik Brodowski
2018-01-08 7:33 ` Thomas Gleixner
2018-01-08 10:16 ` [tip:x86/pti] " tip-bot for Thomas Gleixner
2018-01-26 16:23 ` [patch V2 1/2] " Andrea Arcangeli
2018-01-26 16:35 ` Greg Kroah-Hartman
2018-01-29 5:30 ` Jon Masters
2018-01-07 21:48 ` [patch V2 2/2] x86/cpu: Implement CPU vulnerabilites sysfs functions Thomas Gleixner
2018-01-07 22:14 ` Konrad Rzeszutek Wilk
2018-01-08 6:54 ` Greg Kroah-Hartman
2018-01-08 10:17 ` tip-bot for Thomas Gleixner [this message]
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=tip-61dc0f555b5c761cdafb0ba5bd41ecf22d68a4c4@git.kernel.org \
--to=tipbot@zytor.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dwmw@amazon.co.uk \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linuxfoundation.org \
--cc=will.deacon@arm.com \
/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).