All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch "x86/cpu: Deal with broken firmware (VMWare/XEN)" has been added to the 4.8-stable tree
@ 2016-11-21 10:56 gregkh
  2016-11-22 15:04 ` Borislav Petkov
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2016-11-21 10:56 UTC (permalink / raw)
  To: tglx, akataria, bigeasy, boris.ostrovsky, bp, ciwillia, gregkh,
	m.v.b, peterz
  Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    x86/cpu: Deal with broken firmware (VMWare/XEN)

to the 4.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-cpu-deal-with-broken-firmware-vmware-xen.patch
and it can be found in the queue-4.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From d49597fd3bc7d9534de55e9256767f073be1b33a Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 9 Nov 2016 16:35:51 +0100
Subject: x86/cpu: Deal with broken firmware (VMWare/XEN)

From: Thomas Gleixner <tglx@linutronix.de>

commit d49597fd3bc7d9534de55e9256767f073be1b33a upstream.

Both ACPI and MP specifications require that the APIC id in the respective
tables must be the same as the APIC id in CPUID.

The kernel retrieves the physical package id from the APIC id during the
ACPI/MP table scan and builds the physical to logical package map. The
physical package id which is used after a CPU comes up is retrieved from
CPUID. So we rely on ACPI/MP tables and CPUID agreeing in that respect.

There exist VMware and XEN implementations which violate the spec. As a
result the physical to logical package map, which relies on the ACPI/MP
tables does not work on those systems, because the CPUID initialized
physical package id does not match the firmware id. This causes system
crashes and malfunction due to invalid package mappings.

The only way to cure this is to sanitize the physical package id after the
CPUID enumeration and yell when the APIC ids are different. Fix up the
initial APIC id, which is fine as it is only used printout purposes.

If the physical package IDs differ yell and use the package information
from the ACPI/MP tables so the existing logical package map just works.

Chas provided the resulting dmesg output for his affected 4 virtual
sockets, 1 core per socket VM:

[Firmware Bug]: CPU1: APIC id mismatch. Firmware: 1 CPUID: 2
[Firmware Bug]: CPU1: Using firmware package id 1 instead of 2
....

Reported-and-tested-by: "Charles (Chas) Williams" <ciwillia@brocade.com>,
Reported-by: M. Vefa Bicakci <m.v.b@runbox.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Alok Kataria <akataria@vmware.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1611091613540.3501@nanos
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/cpu/common.c |   32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -979,6 +979,35 @@ static void x86_init_cache_qos(struct cp
 }
 
 /*
+ * The physical to logical package id mapping is initialized from the
+ * acpi/mptables information. Make sure that CPUID actually agrees with
+ * that.
+ */
+static void sanitize_package_id(struct cpuinfo_x86 *c)
+{
+#ifdef CONFIG_SMP
+	unsigned int pkg, apicid, cpu = smp_processor_id();
+
+	apicid = apic->cpu_present_to_apicid(cpu);
+	pkg = apicid >> boot_cpu_data.x86_coreid_bits;
+
+	if (apicid != c->initial_apicid) {
+		pr_err(FW_BUG "CPU%u: APIC id mismatch. Firmware: %x CPUID: %x\n",
+		       cpu, apicid, c->initial_apicid);
+		c->initial_apicid = apicid;
+	}
+	if (pkg != c->phys_proc_id) {
+		pr_err(FW_BUG "CPU%u: Using firmware package id %u instead of %u\n",
+		       cpu, pkg, c->phys_proc_id);
+		c->phys_proc_id = pkg;
+	}
+	c->logical_proc_id = topology_phys_to_logical_pkg(pkg);
+#else
+	c->logical_proc_id = 0;
+#endif
+}
+
+/*
  * This does the hard work of actually picking apart the CPU stuff...
  */
 static void identify_cpu(struct cpuinfo_x86 *c)
@@ -1103,8 +1132,7 @@ static void identify_cpu(struct cpuinfo_
 #ifdef CONFIG_NUMA
 	numa_add_cpu(smp_processor_id());
 #endif
-	/* The boot/hotplug time assigment got cleared, restore it */
-	c->logical_proc_id = topology_phys_to_logical_pkg(c->phys_proc_id);
+	sanitize_package_id(c);
 }
 
 /*


Patches currently in stable-queue which might be from tglx@linutronix.de are

queue-4.8/x86-cpu-amd-fix-cpu_llc_id-for-amd-fam17h-systems.patch
queue-4.8/x86-cpu-deal-with-broken-firmware-vmware-xen.patch

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

* Re: Patch "x86/cpu: Deal with broken firmware (VMWare/XEN)" has been added to the 4.8-stable tree
  2016-11-21 10:56 Patch "x86/cpu: Deal with broken firmware (VMWare/XEN)" has been added to the 4.8-stable tree gregkh
@ 2016-11-22 15:04 ` Borislav Petkov
  2016-11-22 17:08   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Borislav Petkov @ 2016-11-22 15:04 UTC (permalink / raw)
  To: gregkh
  Cc: tglx, akataria, bigeasy, boris.ostrovsky, ciwillia, m.v.b,
	peterz, stable, stable-commits

On Mon, Nov 21, 2016 at 11:56:22AM +0100, gregkh@linuxfoundation.org wrote:
> 
> This is a note to let you know that I've just added the patch titled
> 
>     x86/cpu: Deal with broken firmware (VMWare/XEN)
> 
> to the 4.8-stable tree which can be found at:
>     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> 
> The filename of the patch is:
>      x86-cpu-deal-with-broken-firmware-vmware-xen.patch
> and it can be found in the queue-4.8 subdirectory.
> 
> If you, or anyone else, feels it should not be added to the stable tree,
> please let <stable@vger.kernel.org> know about it.

Yes, please remove it from the stable queue for now. We'll have a fix ontop
first and we'll submit both then as the check

	if (apicid != c->initial_apicid) {

fires on pretty much everything-AMD now.

Thanks.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

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

* Re: Patch "x86/cpu: Deal with broken firmware (VMWare/XEN)" has been added to the 4.8-stable tree
  2016-11-22 15:04 ` Borislav Petkov
@ 2016-11-22 17:08   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2016-11-22 17:08 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: tglx, akataria, bigeasy, boris.ostrovsky, ciwillia, m.v.b,
	peterz, stable, stable-commits

On Tue, Nov 22, 2016 at 04:04:58PM +0100, Borislav Petkov wrote:
> On Mon, Nov 21, 2016 at 11:56:22AM +0100, gregkh@linuxfoundation.org wrote:
> > 
> > This is a note to let you know that I've just added the patch titled
> > 
> >     x86/cpu: Deal with broken firmware (VMWare/XEN)
> > 
> > to the 4.8-stable tree which can be found at:
> >     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> > 
> > The filename of the patch is:
> >      x86-cpu-deal-with-broken-firmware-vmware-xen.patch
> > and it can be found in the queue-4.8 subdirectory.
> > 
> > If you, or anyone else, feels it should not be added to the stable tree,
> > please let <stable@vger.kernel.org> know about it.
> 
> Yes, please remove it from the stable queue for now. We'll have a fix ontop
> first and we'll submit both then as the check
> 
> 	if (apicid != c->initial_apicid) {
> 
> fires on pretty much everything-AMD now.

Now removed, thanks for letting me know.

greg k-h

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

end of thread, other threads:[~2016-11-22 17:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-21 10:56 Patch "x86/cpu: Deal with broken firmware (VMWare/XEN)" has been added to the 4.8-stable tree gregkh
2016-11-22 15:04 ` Borislav Petkov
2016-11-22 17:08   ` Greg KH

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.