From patchwork Tue Feb 13 21:04:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 200609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp809700dyb; Tue, 13 Feb 2024 13:09:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWMc3fk1P0hq5kgeJ7Yqt8mIJTAmV+utBfDq5Bu3r9QuVrOZ8/m2RmsrAuDmF7Zrcovv8kNctedmgP+PIcf9e9XhTYBTQ== X-Google-Smtp-Source: AGHT+IE3mCl6V9XZ56HFpg2SsTs1tiATuLBF3POVPO/EAaqF4CGM9j8+DmjG2i9S5kYsjEhJX9gy X-Received: by 2002:a17:906:840c:b0:a3d:1649:3bbf with SMTP id n12-20020a170906840c00b00a3d16493bbfmr388817ejx.61.1707858573958; Tue, 13 Feb 2024 13:09:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707858573; cv=pass; d=google.com; s=arc-20160816; b=LXV7+o0PdmLsd78vrTR2mWoD2OzvRiod+r2QGC/SfsCFdXsPs4XhHQ1/1goINEX5ss SyaRL1iiesJ5BQNs7rGbrh6Nx7D/KUPjCPAcgTzooQaIS1rkvk3fy5FzTmS3fkl+dKjW gRvIEiP8seXO0zPO5RebRbD8UQhqMQ06kWbFlCYmGQdd7jUAnHwnVnE2Ln/dTof8ZcFa O6dxQYDItWwlD+CyZRNFr2BmvDAcSW189uPYBJUTcrC8sSZZaspQx+gITFra9AmWCaxH y7vhfQTaqui5UDlXAOmgCp75WPFGw/BQ0JlTrKSUv3KdGfYANHf6f733ASKqf8d3DW+7 zDVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=p1hwX9LEu/e1+Ot1b5cejKkCoScMTR5JGuQ827RCDFo=; fh=9HgqqzbFGd0twT973Rv9mZt9MdfoU9PzEzHVXgNNtFo=; b=wme46uNYWMH+0O1ivybyfhcxHbRJqeitgkTUhaWRoSU1WaAezAfvfOSvvZ2ot1As/q rw1P/E5MlI+1fU+KMvmEc1CNwdmN1gHBUqGq81Jycq4uCWXO4qeYY6vQQLu8cJMuFvDA lbrgSpFs/moDnod+gS3QEm5q35UZGXEn2JQViISE7R0g7rKHhx4kuGzbLO85GBmZGP/Z 7uysV5dhwb+ZkamuNQQl00GUmL6B6jcCcJoRPUjtrQlHWYNHxv5WkVg+H6OKLogAG+b1 pGjU1XRp6oQrGpAfbOKS+l39l7AAz1Kf88OsAD1WesE7Vufaf9rfHzKzmU9EgknF37SC Icyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0XAlcCZy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-64261-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64261-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCXXECZB9Y64Y5nkJ4sNnkQrkdAX9xWM5btlbMJ/Hxvp1OL6x/kiK799Iwrft/OVm+TQiow7Oex4p1oAgdkAxHvVvnNFnA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g1-20020a1709061c8100b00a3d32c6a2easi143571ejh.941.2024.02.13.13.09.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:09:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64261-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0XAlcCZy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-64261-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64261-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 687FF1F283C7 for ; Tue, 13 Feb 2024 21:09:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A98065E05; Tue, 13 Feb 2024 21:04:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0XAlcCZy"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="f0vq0FNi" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B27461687 for ; Tue, 13 Feb 2024 21:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707858295; cv=none; b=hmlnYYvUV2ovh6cAI8Z7zNTfwNvYR8kYpFKAQTSCU0Lb2gwjFX4tuPMb9z0DLRBlhxI1u9/fJ2D64UecprID4wubBCYS3QwFaJn7amiYzhGCjua+BlXClW9MX//ncmg2LYn2yaxrJJ9MSY2HKYJG7PGiqYRW3xngSbrAeL2+qFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707858295; c=relaxed/simple; bh=3awkOOoO8G9BJISNINVkNbJtDYkDqRW7NjVuJ0C6ZNA=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=bXrnzjwE1DuUjFerQeyCz9YT0+D+uhtItKNBnaLY40AHgHU0nmBtCxWqqvdwb7sbCz5dSKFDrHHj0DKH5xhBdKctivMERiGZ7SqrT6oshjQymm2YTghW9iY3VPfMRKvxg8WA/B2nCiK9dA7YfUHy6CCoVDovUPgOEomQr8+AtyM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0XAlcCZy; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=f0vq0FNi; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Message-ID: <20240212154638.867699078@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707858292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=p1hwX9LEu/e1+Ot1b5cejKkCoScMTR5JGuQ827RCDFo=; b=0XAlcCZyuOa8v7jWBN/5z2layZSVZc6d0B5W9uHypJJNA+T38IBMxO+qHuIsNcSuEHtG1p 1wj0dHk8lFwt1XyjMGLbuUVWb9ik2wafUp0DQuOnJdUO80Do5S5bEPmpn3382OtwNQ0CB/ XOKfHdeMXgZ2gOJzPdtwoMUAj13qcTOTzrFSt4aVr7mrw10wY07ExpowNPJ/UKozOFfokk yhHDtegU5KGixeY0A5L3hAa3MtpY4k4URgWqbEk34cKsuWSZsJIQYo/vIhwnUA68y9Erzf Lhuogx/yp78O/8HZq+pbjTn5BvAa10AtxRulOvExN6tsNU+GLKacw7qDagvnfA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707858292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=p1hwX9LEu/e1+Ot1b5cejKkCoScMTR5JGuQ827RCDFo=; b=f0vq0FNiLDIk6lHL1E56iHaU8Pzkz7cd0ngfJjidXgooWtThEbtG7rjKaLo3XpENkyEdoH coiugVsjEmBAEwCg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , Huang Rui , Juergen Gross , Dimitri Sivanich , Sohil Mehta , K Prateek Nayak , Kan Liang , Zhang Rui , "Paul E. McKenney" , Feng Tang , Andy Shevchenko , Michael Kelley , "Peter Zijlstra (Intel)" , Andy Shevchenko , Wei Liu Subject: [patch V3 01/22] x86/cpu/topology: Make the APIC mismatch warnings complete References: <20240212154529.402604963@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 13 Feb 2024 22:04:52 +0100 (CET) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790819512124408010 X-GMAIL-MSGID: 1790819512124408010 From: Thomas Gleixner Detect all possible combinations of mismatch right in the CPUID evaluation code. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 5 ++--- arch/x86/kernel/cpu/common.c | 15 ++------------- arch/x86/kernel/cpu/topology_common.c | 12 ++++++++++++ 3 files changed, 16 insertions(+), 16 deletions(-) --- --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -46,16 +46,15 @@ extern void x86_32_probe_apic(void); static inline void x86_32_probe_apic(void) { } #endif -#ifdef CONFIG_X86_LOCAL_APIC +extern u32 cpuid_to_apicid[]; +#ifdef CONFIG_X86_LOCAL_APIC extern int apic_verbosity; extern int local_apic_timer_c2_ok; extern bool apic_is_disabled; extern unsigned int lapic_timer_period; -extern u32 cpuid_to_apicid[]; - extern enum apic_intr_mode_id apic_intr_mode; enum apic_intr_mode_id { APIC_PIC, --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1716,22 +1716,11 @@ static void generic_identify(struct cpui #endif } -/* - * Validate that ACPI/mptables have the same information about the - * effective APIC id and update the package map. - */ -static void validate_apic_and_package_id(struct cpuinfo_x86 *c) +static void update_package_map(struct cpuinfo_x86 *c) { #ifdef CONFIG_SMP unsigned int cpu = smp_processor_id(); - u32 apicid; - apicid = apic->cpu_present_to_apicid(cpu); - - if (apicid != c->topo.apicid) { - pr_err(FW_BUG "CPU%u: APIC id mismatch. Firmware: %x APIC: %x\n", - cpu, apicid, c->topo.initial_apicid); - } BUG_ON(topology_update_package_map(c->topo.pkg_id, cpu)); BUG_ON(topology_update_die_map(c->topo.die_id, cpu)); #else @@ -1923,7 +1912,7 @@ void identify_secondary_cpu(struct cpuin #ifdef CONFIG_X86_32 enable_sep_cpu(); #endif - validate_apic_and_package_id(c); + update_package_map(c); x86_spec_ctrl_setup_ap(); update_srbds_msr(); if (boot_cpu_has_bug(X86_BUG_GDS)) --- a/arch/x86/kernel/cpu/topology_common.c +++ b/arch/x86/kernel/cpu/topology_common.c @@ -177,6 +177,18 @@ void cpu_parse_topology(struct cpuinfo_x parse_topology(&tscan, false); + if (IS_ENABLED(CONFIG_X86_LOCAL_APIC)) { + if (c->topo.initial_apicid != c->topo.apicid) { + pr_err(FW_BUG "CPU%4u: APIC ID mismatch. CPUID: 0x%04x APIC: 0x%04x\n", + cpu, c->topo.initial_apicid, c->topo.apicid); + } + + if (c->topo.apicid != cpuid_to_apicid[cpu]) { + pr_err(FW_BUG "CPU%4u: APIC ID mismatch. Firmware: 0x%04x APIC: 0x%04x\n", + cpu, cpuid_to_apicid[cpu], c->topo.apicid); + } + } + for (dom = TOPO_SMT_DOMAIN; dom < TOPO_MAX_DOMAIN; dom++) { if (tscan.dom_shifts[dom] == x86_topo_system.dom_shifts[dom]) continue;