lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 03 Sep 2010 11:13:47 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Ingo Molnar <mingo@...e.hu>, Stephane Eranian <eranian@...gle.com>,
	"robert.richter" <robert.richter@....com>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Arjan Van De Ven <arjan@...ux.intel.com>,
	"H. Peter Anvin" <hpa@...ux.kernel.org>
Subject: [PATCH] perf, x86: Disable perf if the BIOS got its grubby paws on
 the PMU

Disable all of perf if we find any active PMCs on boot.

It has been reported that some BIOSes access the PMU, for obscure things
better done by the OS. Come down hard on this practice and fully disable
the PMU.

[ Boot tested on a westmere system with a sane BIOS -- I don't actually
  have an affected system to test this on. ]

Signed-off-by: Peter Zijlstra <a.p.zijlstra@...llo.nl>
---

Robert, do you know if any AMD system BIOSes carry similar
Feat^H^H^H^HFailureAdd?

 arch/x86/kernel/cpu/perf_event_intel.c |   35 ++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index ee05c90..6849653 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -923,6 +923,19 @@ static void intel_clovertown_quirks(void)
 	x86_pmu.pebs_constraints = NULL;
 }
 
+static void print_BIOS_fail(void)
+{
+	printk(KERN_ERR "\n");
+	printk(KERN_ERR "=============================================\n");
+	printk(KERN_ERR "It appears the BIOS is actively using the PMU\n");
+	printk(KERN_ERR "this avoids Linux from using it, please de-  \n");
+	printk(KERN_ERR "activate this BIOS feature or request a BIOS \n");
+	printk(KERN_ERR "update from your vendor.                     \n");
+	printk(KERN_ERR "=============================================\n");
+
+	memset(&x86_pmu, 0, sizeof(x86_pmu));
+}
+
 static __init int intel_pmu_init(void)
 {
 	union cpuid10_edx edx;
@@ -930,6 +943,8 @@ static __init int intel_pmu_init(void)
 	unsigned int unused;
 	unsigned int ebx;
 	int version;
+	u64 val;
+	int i;
 
 	if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
 		switch (boot_cpu_data.x86) {
@@ -968,6 +983,26 @@ static __init int intel_pmu_init(void)
 		x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
 
 	/*
+	 * Check to see if the BIOS enabled any of the counters, if so
+	 * complain and bail.
+	 */
+	for (i = 0; i < x86_pmu.num_counters; i++) {
+		rdmsrl(x86_pmu.eventsel + i, val);
+		if (val & ARCH_PERFMON_EVENTSEL_ENABLE) {
+			print_BIOS_fail();
+			return -EBUSY;
+		}
+	}
+
+	for (i = 0; i < x86_pmu.num_counters_fixed; i++) {
+		rdmsrl(MSR_ARCH_PERFMON_FIXED_CTR_CTRL, val);
+		if (val & (0x03 << i*4)) {
+			print_BIOS_fail();
+			return -EBUSY;
+		}
+	}
+
+	/*
 	 * v2 and above have a perf capabilities MSR
 	 */
 	if (version > 1) {

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ