All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
	Jacob Pan <jacob.jun.pan@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] x86/rapl: Do not load in a guest
Date: Thu,  3 Dec 2015 19:27:02 +0100	[thread overview]
Message-ID: <1449167222-17562-1-git-send-email-bp@alien8.de> (raw)

From: Borislav Petkov <bp@suse.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@suse.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.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


             reply	other threads:[~2015-12-03 18:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-03 18:27 Borislav Petkov [this message]
2015-12-03 18:38 ` [PATCH] x86/rapl: Do not load in a guest Jacob Pan
2015-12-03 18:42   ` Borislav Petkov
2015-12-03 18:59     ` Jacob Pan
2015-12-03 23:32       ` Rafael J. Wysocki
2015-12-03 23:25         ` Borislav Petkov
2015-12-04  1:00           ` Rafael J. Wysocki
2015-12-04  7:42 ` Ingo Molnar
2015-12-04  8:22   ` Peter Zijlstra
2015-12-04  8:28     ` Ingo Molnar
2015-12-04 10:19       ` Borislav Petkov
2015-12-04 10:41         ` Paolo Bonzini
2015-12-04 10:56           ` Borislav Petkov
2015-12-04 11:53             ` Ingo Molnar
2015-12-04 17:46               ` Jacob Pan
2015-12-04 17:52                 ` Paolo Bonzini
2015-12-04 18:04                 ` Borislav Petkov
2015-12-04 18:16                   ` Jacob Pan
2015-12-04 18:28                     ` Borislav Petkov
2015-12-04 18:37                       ` Jacob Pan
2015-12-04 19:41                         ` Borislav Petkov
2015-12-04 17:51     ` Jacob Pan
2015-12-04 22:14       ` Peter Zijlstra
2015-12-04 22:39         ` H. Peter Anvin

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=1449167222-17562-1-git-send-email-bp@alien8.de \
    --to=bp@alien8.de \
    --cc=acme@kernel.org \
    --cc=hpa@zytor.com \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.