mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/kernel/cpu/amd.c: don't apply the lahf_lm workaround in a hypervisor
@ 2017-07-12  7:19 Mikulas Patocka
  2017-07-12 13:47 ` Borislav Petkov
  0 siblings, 1 reply; 6+ messages in thread
From: Mikulas Patocka @ 2017-07-12  7:19 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin; +Cc: x86, linux-kernel

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);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/kernel/cpu/amd.c: don't apply the lahf_lm workaround in a hypervisor
  2017-07-12  7:19 [PATCH] x86/kernel/cpu/amd.c: don't apply the lahf_lm workaround in a hypervisor Mikulas Patocka
@ 2017-07-12 13:47 ` Borislav Petkov
  2017-07-13  2:27   ` Mikulas Patocka
  0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2017-07-12 13:47 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel

On Wed, Jul 12, 2017 at 03:19:56AM -0400, Mikulas Patocka wrote:
> 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.

No need - there are a lot of qemu configurations which cause the
unhandled MSR warning so no need to pollute the kernel unnecessarily.
The warning is harmless at that.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/kernel/cpu/amd.c: don't apply the lahf_lm workaround in a hypervisor
  2017-07-12 13:47 ` Borislav Petkov
@ 2017-07-13  2:27   ` Mikulas Patocka
  2017-07-13  6:32     ` Borislav Petkov
  0 siblings, 1 reply; 6+ messages in thread
From: Mikulas Patocka @ 2017-07-13  2:27 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel



On Wed, 12 Jul 2017, Borislav Petkov wrote:

> On Wed, Jul 12, 2017 at 03:19:56AM -0400, Mikulas Patocka wrote:
> > 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.
> 
> No need - there are a lot of qemu configurations which cause the
> unhandled MSR warning so no need to pollute the kernel unnecessarily.
> The warning is harmless at that.

It is not strictly needed, but it is annoying. I work in the console and 
it is annoying to see these "unhandled rdmsr" messages printed over the 
screen every time I reboot a virtual machine.

Or do you thnik that the code that prints this warning should be removed 
from the kernel instead?

Mikulas

> -- 
> Regards/Gruss,
>     Boris.
> 
> ECO tip #101: Trim your mails when you reply.
> --

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/kernel/cpu/amd.c: don't apply the lahf_lm workaround in a hypervisor
  2017-07-13  2:27   ` Mikulas Patocka
@ 2017-07-13  6:32     ` Borislav Petkov
  2017-07-21 11:34       ` Mikulas Patocka
  0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2017-07-13  6:32 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel, kvm-ML

On Wed, Jul 12, 2017 at 10:27:44PM -0400, Mikulas Patocka wrote:
> It is not strictly needed, but it is annoying. I work in the console and 
> it is annoying to see these "unhandled rdmsr" messages printed over the 
> screen every time I reboot a virtual machine.

Those messages are already pr_debug_ratelimited(). Fix your loglevel to
not see them.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/kernel/cpu/amd.c: don't apply the lahf_lm workaround in a hypervisor
  2017-07-13  6:32     ` Borislav Petkov
@ 2017-07-21 11:34       ` Mikulas Patocka
  2017-07-21 12:28         ` Borislav Petkov
  0 siblings, 1 reply; 6+ messages in thread
From: Mikulas Patocka @ 2017-07-21 11:34 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel, kvm-ML



On Thu, 13 Jul 2017, Borislav Petkov wrote:

> On Wed, Jul 12, 2017 at 10:27:44PM -0400, Mikulas Patocka wrote:
> > It is not strictly needed, but it is annoying. I work in the console and 
> > it is annoying to see these "unhandled rdmsr" messages printed over the 
> > screen every time I reboot a virtual machine.
> 
> Those messages are already pr_debug_ratelimited(). Fix your loglevel to
> not see them.

The message 'unhandled rdmsr' is printed with "pr_err_ratelimited" in the 
kernels up to and including 4.9. So it can't be easily silenced, silencing 
it silences any errors.

(and I can't use kernels newer that 4.4 on the host machine because of 
broken hibernation)

Mikulas

> -- 
> Regards/Gruss,
>     Boris.
> 
> ECO tip #101: Trim your mails when you reply.
> --

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86/kernel/cpu/amd.c: don't apply the lahf_lm workaround in a hypervisor
  2017-07-21 11:34       ` Mikulas Patocka
@ 2017-07-21 12:28         ` Borislav Petkov
  0 siblings, 0 replies; 6+ messages in thread
From: Borislav Petkov @ 2017-07-21 12:28 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel, kvm-ML

On Fri, Jul 21, 2017 at 07:34:59AM -0400, Mikulas Patocka wrote:
> (and I can't use kernels newer that 4.4 on the host machine because of 
> broken hibernation)

And what do we do with upstream patches which we need in older kernels?

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-07-21 12:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-12  7:19 [PATCH] x86/kernel/cpu/amd.c: don't apply the lahf_lm workaround in a hypervisor Mikulas Patocka
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

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®