mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] x86/kernel/cpu/amd.c: don't apply the lahf_lm workaround in a hypervisor
Date: Wed, 12 Jul 2017 03:19:56 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LRH.2.02.1707120318530.4739@file01.intranet.prod.int.rdu2.redhat.com> (raw)

When I start a virtual machine, kvm complains about accesses to an unknown
MSR ("vcpu0 unhandled rdmsr: 0xc001100d"). This is caused by the code in
init_amd_k8 that tries to work around a BIOS bug that incorrectly sets
lahf_lm.

This patch disables this workaround when running in a hypervisor.

Note that the processors for which this erratum applies do not support
virtualization at all, so if we are running in a hypervisor, we can be
sure that the workaronud doesn't apply.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 arch/x86/kernel/cpu/amd.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: linux-2.6/arch/x86/kernel/cpu/amd.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/amd.c
+++ linux-2.6/arch/x86/kernel/cpu/amd.c
@@ -627,8 +627,12 @@ static void init_amd_k8(struct cpuinfo_x
 	 * Some BIOSes incorrectly force this feature, but only K8 revision D
 	 * (model = 0x14) and later actually support it.
 	 * (AMD Erratum #110, docId: 25759).
+	 *
+	 * Don't apply this workaround in a virtual machine because kvm
+	 * complains about reads from an unknown MSR.
 	 */
-	if (c->x86_model < 0x14 && cpu_has(c, X86_FEATURE_LAHF_LM)) {
+	if (c->x86_model < 0x14 && cpu_has(c, X86_FEATURE_LAHF_LM) &&
+	    !boot_cpu_has(X86_FEATURE_HYPERVISOR)) {
 		clear_cpu_cap(c, X86_FEATURE_LAHF_LM);
 		if (!rdmsrl_amd_safe(0xc001100d, &value)) {
 			value &= ~BIT_64(32);

             reply	other threads:[~2017-07-12  7:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12  7:19 Mikulas Patocka [this message]
2017-07-12 13:47 ` Borislav Petkov
2017-07-13  2:27   ` Mikulas Patocka
2017-07-13  6:32     ` Borislav Petkov
2017-07-21 11:34       ` Mikulas Patocka
2017-07-21 12:28         ` Borislav Petkov

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=alpine.LRH.2.02.1707120318530.4739@file01.intranet.prod.int.rdu2.redhat.com \
    --to=mpatocka@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®