[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1449167222-17562-1-git-send-email-bp@alien8.de>
Date: Thu, 3 Dec 2015 19:27:02 +0100
From: Borislav Petkov <bp@...en8.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: [PATCH] x86/rapl: Do not load in a guest
From: Borislav Petkov <bp@...e.de>
qemu/kvm doesn't support RAPL and RAPL doesn't have a CPUID feature bit
so check whether we're in a guest instead.
Reported-by: Hannes Reinecke <hare@...e.de>
Signed-off-by: Borislav Petkov <bp@...e.de>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Jacob Pan <jacob.jun.pan@...ux.intel.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
---
arch/x86/kernel/cpu/perf_event_intel_rapl.c | 3 +++
drivers/powercap/intel_rapl.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
index ed446bdcbf31..bc60bc1118b4 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
@@ -711,6 +711,9 @@ static int __init rapl_pmu_init(void)
struct x86_pmu_quirk *quirk;
int i;
+ if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
+ return 0;
+
/*
* check for Intel processor family 6
*/
diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
index cc97f0869791..297a9b5074e2 100644
--- a/drivers/powercap/intel_rapl.c
+++ b/drivers/powercap/intel_rapl.c
@@ -1511,6 +1511,9 @@ static int __init rapl_init(void)
int ret = 0;
const struct x86_cpu_id *id;
+ if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
+ return -ENODEV;
+
id = x86_match_cpu(rapl_ids);
if (!id) {
pr_err("driver does not support CPU family %d model %d\n",
--
2.3.5
--
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