Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933672AbcKIQDl (ORCPT ); Wed, 9 Nov 2016 11:03:41 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:53232 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751677AbcKIQDk (ORCPT ); Wed, 9 Nov 2016 11:03:40 -0500 Date: Wed, 9 Nov 2016 17:03:24 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: "Charles (Chas) Williams" , Sebastian Andrzej Siewior , x86@kernel.org, LKML , "M. Vefa Bicakci" , Borislav Petkov Subject: Re: [PATCH] x86/cpuid: Deal with broken firmware once more Message-ID: <20161109160324.GR3142@twins.programming.kicks-ass.net> References: <20161102122557.qs4rl6mb7n7l7j7p@linutronix.de> <24e69019-60d0-29e7-e31f-c6f00f9ed98a@brocade.com> <58e229e2-91f4-a97f-1b9f-089f48ef994a@brocade.com> <86609338-2b45-ed7e-fb07-99421e43a2f1@brocade.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1441 Lines: 45 On Wed, Nov 09, 2016 at 04:35:51PM +0100, Thomas Gleixner wrote: > 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. > > There exist Virtualbox and Xen implementations which violate the spec. As a ISTR it was VMware, not VirtualBox, but whatever.. they're both crazy virt stuff. > /* > + * 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); Should we not also 'fix' c->initial_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->locical_proc_id = 0; UP FTW ;-) > +#endif > +}