From nobody Sun Feb 8 14:22:27 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1241C001DE for ; Wed, 9 Aug 2023 20:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234701AbjHIUgw (ORCPT ); Wed, 9 Aug 2023 16:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234590AbjHIUgT (ORCPT ); Wed, 9 Aug 2023 16:36:19 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EA592136; Wed, 9 Aug 2023 13:36:13 -0700 (PDT) Date: Wed, 09 Aug 2023 20:36:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691613371; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XTU/qg25v4UlhYph41w3e0dHIdISUNjuxEGCpq96sM0=; b=d1WouCEY0ugqmsbK4LYXtWCHtesDKHLkKaN4udzXrXBcawXdQrWeuS9c6tU5AoNfqFKMsx 2DBZiaRmMRhyygXabzqoyCspoC7/dvNg49PH8h5w3j2w9sQPyRCsRrS0RPR2PCEVAR7whl ToX/aByGI+orie0RMHPCYFFPXW4y761ATal9MYIvvyPvvFAq/taBVnmVY4oT9jgMC/IHY8 E04nakd53OiBSTdMNMWvmy/BGcMxiMXi15HQt1u4kT1DI4d3Pl85UUDoyvYscpQRbi6zMy FsGXGQYR8/I+QKKAP6leLKFSIQg8jUK/pwyzZsbZi0l7Jc8n0z2xzS8MDBToPg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691613371; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XTU/qg25v4UlhYph41w3e0dHIdISUNjuxEGCpq96sM0=; b=ApqivpTtRDkhZSH1j5hEZEzlrILf8BXcve+3Jdjwh5vaQA6NpH4kmYkdSv9h7y0Fgjb99j OsHlENuQPQkG3pAA== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/apic] x86/apic: Prepare x2APIC for using apic::max_apic_id Cc: Thomas Gleixner , Dave Hansen , "Peter Zijlstra (Intel)" , Michael Kelley , Sohil Mehta , Juergen Gross , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169161337138.27769.11944204974937541880.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/apic branch of tip: Commit-ID: b5a5ce58d3d22ce560305ef9c70a2ec21fb887ba Gitweb: https://git.kernel.org/tip/b5a5ce58d3d22ce560305ef9c70a2ec21= fb887ba Author: Thomas Gleixner AuthorDate: Tue, 08 Aug 2023 15:04:11 -07:00 Committer: Dave Hansen CommitterDate: Wed, 09 Aug 2023 11:58:31 -07:00 x86/apic: Prepare x2APIC for using apic::max_apic_id In order to remove the apic::apic_id_valid() callback and switch to checking apic::max_apic_id, it is required to update apic::max_apic_id when the APIC initialization code overrides it via x2apic_set_max_apicid(). Make the existing booleans a bitfield and add a flag which lets the update function and the core code which switches the driver detect whether the apic instance wants to have that update or not and apply it if required. Signed-off-by: Thomas Gleixner Signed-off-by: Dave Hansen Acked-by: Peter Zijlstra (Intel) Tested-by: Michael Kelley Tested-by: Sohil Mehta Tested-by: Juergen Gross # Xen PV (dom0 and unpriv. guest) --- arch/x86/include/asm/apic.h | 7 ++++--- arch/x86/kernel/apic/local.h | 1 + arch/x86/kernel/apic/probe_64.c | 4 ++++ arch/x86/kernel/apic/x2apic_cluster.c | 1 + arch/x86/kernel/apic/x2apic_phys.c | 5 ++++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index 42d3240..2e79c13 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -266,10 +266,11 @@ struct apic { void (*send_IPI_all)(int vector); void (*send_IPI_self)(int vector); =20 - u32 disable_esr; - enum apic_delivery_modes delivery_mode; - bool dest_mode_logical; + + u32 disable_esr : 1, + dest_mode_logical : 1, + x2apic_set_max_apicid : 1; =20 u32 (*calc_dest_apicid)(unsigned int cpu); =20 diff --git a/arch/x86/kernel/apic/local.h b/arch/x86/kernel/apic/local.h index a250675..e576b3a 100644 --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -23,6 +23,7 @@ int x2apic_phys_pkg_id(int initial_apicid, int index_msb); void x2apic_send_IPI_all(int vector); void x2apic_send_IPI_allbutself(int vector); void x2apic_send_IPI_self(int vector); +extern u32 x2apic_max_apicid; =20 /* IPI */ =20 diff --git a/arch/x86/kernel/apic/probe_64.c b/arch/x86/kernel/apic/probe_6= 4.c index a82bb52..a12a379 100644 --- a/arch/x86/kernel/apic/probe_64.c +++ b/arch/x86/kernel/apic/probe_64.c @@ -19,6 +19,10 @@ static __init void apic_install_driver(struct apic *driv= er) return; =20 apic =3D driver; + + if (IS_ENABLED(CONFIG_X86_X2APIC) && apic->x2apic_set_max_apicid) + apic->max_apic_id =3D x2apic_max_apicid; + pr_info("Switched APIC routing to %s:\n", apic->name); } =20 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x= 2apic_cluster.c index 036dd1c..a164764 100644 --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -240,6 +240,7 @@ static struct apic apic_x2apic_cluster __ro_after_init = =3D { .phys_pkg_id =3D x2apic_phys_pkg_id, =20 .max_apic_id =3D UINT_MAX, + .x2apic_set_max_apicid =3D true, .get_apic_id =3D x2apic_get_apic_id, .set_apic_id =3D x2apic_set_apic_id, =20 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2ap= ic_phys.c index d292ec3..3aabfd3 100644 --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -8,11 +8,13 @@ int x2apic_phys; =20 static struct apic apic_x2apic_phys; -static u32 x2apic_max_apicid __ro_after_init =3D UINT_MAX; +u32 x2apic_max_apicid __ro_after_init =3D UINT_MAX; =20 void __init x2apic_set_max_apicid(u32 apicid) { x2apic_max_apicid =3D apicid; + if (apic->x2apic_set_max_apicid) + apic->max_apic_id =3D apicid; } =20 static int __init set_x2apic_phys_mode(char *arg) @@ -161,6 +163,7 @@ static struct apic apic_x2apic_phys __ro_after_init =3D= { .phys_pkg_id =3D x2apic_phys_pkg_id, =20 .max_apic_id =3D UINT_MAX, + .x2apic_set_max_apicid =3D true, .get_apic_id =3D x2apic_get_apic_id, .set_apic_id =3D x2apic_set_apic_id,