From nobody Mon Feb 9 14:16:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1699984690392910.2646495082317; Tue, 14 Nov 2023 09:58:10 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.633083.987631 (Exim 4.92) (envelope-from ) id 1r2xfO-0000xT-77; Tue, 14 Nov 2023 17:57:38 +0000 Received: by outflank-mailman (output) from mailman id 633083.987631; Tue, 14 Nov 2023 17:57:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2xfN-0000vq-Rn; Tue, 14 Nov 2023 17:57:37 +0000 Received: by outflank-mailman (input) for mailman id 633083; Tue, 14 Nov 2023 17:50:40 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2xYe-0004mK-HN for xen-devel@lists.xenproject.org; Tue, 14 Nov 2023 17:50:40 +0000 Received: from 15.mo582.mail-out.ovh.net (15.mo582.mail-out.ovh.net [188.165.39.161]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 527d9d79-8316-11ee-98db-6d05b1d4d9a1; Tue, 14 Nov 2023 18:50:39 +0100 (CET) Received: from director8.ghost.mail-out.ovh.net (unknown [10.108.4.8]) by mo582.mail-out.ovh.net (Postfix) with ESMTP id 0D89C28CB6 for ; Tue, 14 Nov 2023 17:50:39 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-x5j2z (unknown [10.110.115.90]) by director8.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 941FD1FD24; Tue, 14 Nov 2023 17:50:38 +0000 (UTC) Received: from 3mdeb.com ([37.59.142.103]) by ghost-submission-6684bf9d7b-x5j2z with ESMTPSA id YKg/IW6zU2V/lwcATVRwWg (envelope-from ); Tue, 14 Nov 2023 17:50:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 527d9d79-8316-11ee-98db-6d05b1d4d9a1 Authentication-Results: garm.ovh; auth=pass (GARM-103G005c5ae1aa5-3e0a-4190-bdc1-8585046cde6c, 1C6EC45AC3E1968723EBE40916FD99D0F8B07574) smtp.auth=krystian.hebel@3mdeb.com X-OVh-ClientIp: 213.192.77.249 From: Krystian Hebel To: xen-devel@lists.xenproject.org Cc: Krystian Hebel , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [XEN PATCH 2/9] x86: don't access x86_cpu_to_apicid[] directly, use cpu_physical_id(cpu) Date: Tue, 14 Nov 2023 18:49:59 +0100 Message-ID: <705574ddb7f18bae9ed3f60ddf2e4bda02c70388.1699982111.git.krystian.hebel@3mdeb.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 12929553056991455600 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrudeffedgudefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhrhihsthhirghnucfjvggsvghluceokhhrhihsthhirghnrdhhvggsvghlseefmhguvggsrdgtohhmqeenucggtffrrghtthgvrhhnpeevtdevieehieeiveekvefhlefftdfhteefueelhfdvhedtjeegkedugfefvdekffenucfkphepuddvjedrtddrtddruddpvddufedrudelvddrjeejrddvgeelpdefjedrheelrddugedvrddutdefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeokhhrhihsthhirghnrdhhvggsvghlseefmhguvggsrdgtohhmqedpnhgspghrtghpthhtohepuddprhgtphhtthhopeigvghnqdguvghvvghlsehlihhsthhsrdigvghnphhrohhjvggtthdrohhrghdpoffvtefjohhsthepmhhoheekvddpmhhouggvpehsmhhtphhouhht X-ZM-MESSAGEID: 1699984691078100016 Content-Type: text/plain; charset="utf-8" This is done in preparation to move data from x86_cpu_to_apicid[] elsewhere. Signed-off-by: Krystian Hebel Reviewed-by: Julien Grall --- xen/arch/x86/acpi/cpu_idle.c | 4 ++-- xen/arch/x86/acpi/lib.c | 2 +- xen/arch/x86/apic.c | 2 +- xen/arch/x86/cpu/mwait-idle.c | 4 ++-- xen/arch/x86/domain.c | 2 +- xen/arch/x86/mpparse.c | 6 +++--- xen/arch/x86/numa.c | 2 +- xen/arch/x86/platform_hypercall.c | 2 +- xen/arch/x86/setup.c | 14 +++++++------- xen/arch/x86/smpboot.c | 4 ++-- xen/arch/x86/spec_ctrl.c | 2 +- xen/arch/x86/sysctl.c | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index cfce4cc0408f..d03e54bcef38 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -1256,7 +1256,7 @@ int get_cpu_id(u32 acpi_id) =20 for ( i =3D 0; i < nr_cpu_ids; i++ ) { - if ( apic_id =3D=3D x86_cpu_to_apicid[i] ) + if ( apic_id =3D=3D cpu_physical_id(i) ) return i; } =20 @@ -1362,7 +1362,7 @@ long set_cx_pminfo(uint32_t acpi_id, struct xen_proce= ssor_power *power) =20 if ( !cpu_online(cpu_id) ) { - uint32_t apic_id =3D x86_cpu_to_apicid[cpu_id]; + uint32_t apic_id =3D cpu_physical_id(cpu_id); =20 /* * If we've just learned of more available C states, wake the CPU = if diff --git a/xen/arch/x86/acpi/lib.c b/xen/arch/x86/acpi/lib.c index 51cb082ca02a..87a1f38f3f5a 100644 --- a/xen/arch/x86/acpi/lib.c +++ b/xen/arch/x86/acpi/lib.c @@ -91,7 +91,7 @@ unsigned int acpi_get_processor_id(unsigned int cpu) { unsigned int acpiid, apicid; =20 - if ((apicid =3D x86_cpu_to_apicid[cpu]) =3D=3D BAD_APICID) + if ((apicid =3D cpu_physical_id(cpu)) =3D=3D BAD_APICID) return INVALID_ACPIID; =20 for (acpiid =3D 0; acpiid < ARRAY_SIZE(x86_acpiid_to_apicid); acpiid++) diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index 6acdd0ec1468..63e18968e54c 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -950,7 +950,7 @@ __next: */ if (boot_cpu_physical_apicid =3D=3D -1U) boot_cpu_physical_apicid =3D get_apic_id(); - x86_cpu_to_apicid[0] =3D get_apic_id(); + cpu_physical_id(0) =3D get_apic_id(); =20 ioapic_init(); } diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c index ff5c808bc952..88168da8a0ca 100644 --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -1202,8 +1202,8 @@ static void __init ivt_idle_state_table_update(void) unsigned int cpu, max_apicid =3D boot_cpu_physical_apicid; =20 for_each_present_cpu(cpu) - if (max_apicid < x86_cpu_to_apicid[cpu]) - max_apicid =3D x86_cpu_to_apicid[cpu]; + if (max_apicid < cpu_physical_id(cpu)) + max_apicid =3D cpu_physical_id(cpu); switch (apicid_to_socket(max_apicid)) { case 0: case 1: /* 1 and 2 socket systems use default ivt_cstates */ diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 3712e36df930..f45437511a46 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1615,7 +1615,7 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUE= ST_HANDLE_PARAM(void) arg) break; =20 cpu_id.phys_id =3D - (uint64_t)x86_cpu_to_apicid[v->vcpu_id] | + (uint64_t)cpu_physical_id(v->vcpu_id) | ((uint64_t)acpi_get_processor_id(v->vcpu_id) << 32); =20 rc =3D -EFAULT; diff --git a/xen/arch/x86/mpparse.c b/xen/arch/x86/mpparse.c index d8ccab2449c6..b8cabebe7bf9 100644 --- a/xen/arch/x86/mpparse.c +++ b/xen/arch/x86/mpparse.c @@ -187,7 +187,7 @@ static int MP_processor_info_x(struct mpc_config_proces= sor *m, " Processor with apicid %i ignored\n", apicid); return cpu; } - x86_cpu_to_apicid[cpu] =3D apicid; + cpu_physical_id(cpu) =3D apicid; cpumask_set_cpu(cpu, &cpu_present_map); } =20 @@ -822,12 +822,12 @@ void mp_unregister_lapic(uint32_t apic_id, uint32_t c= pu) if (!cpu || (apic_id =3D=3D boot_cpu_physical_apicid)) return; =20 - if (x86_cpu_to_apicid[cpu] !=3D apic_id) + if (cpu_physical_id(cpu) !=3D apic_id) return; =20 physid_clear(apic_id, phys_cpu_present_map); =20 - x86_cpu_to_apicid[cpu] =3D BAD_APICID; + cpu_physical_id(cpu) =3D BAD_APICID; cpumask_clear_cpu(cpu, &cpu_present_map); } =20 diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c index 4b0b297c7e09..39e131cb4f35 100644 --- a/xen/arch/x86/numa.c +++ b/xen/arch/x86/numa.c @@ -70,7 +70,7 @@ void __init init_cpu_to_node(void) =20 for ( i =3D 0; i < nr_cpu_ids; i++ ) { - u32 apicid =3D x86_cpu_to_apicid[i]; + u32 apicid =3D cpu_physical_id(i); if ( apicid =3D=3D BAD_APICID ) continue; node =3D apicid < MAX_LOCAL_APIC ? apicid_to_node[apicid] : NUMA_N= O_NODE; diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hype= rcall.c index 9469de9045c7..9a52e048f67c 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -588,7 +588,7 @@ ret_t do_platform_op( } else { - g_info->apic_id =3D x86_cpu_to_apicid[g_info->xen_cpuid]; + g_info->apic_id =3D cpu_physical_id(g_info->xen_cpuid); g_info->acpi_id =3D acpi_get_processor_id(g_info->xen_cpuid); ASSERT(g_info->apic_id !=3D BAD_APICID); g_info->flags =3D 0; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 1285969901e0..a19fe219bbf6 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -319,7 +319,7 @@ static void __init init_idle_domain(void) void srat_detect_node(int cpu) { nodeid_t node; - u32 apicid =3D x86_cpu_to_apicid[cpu]; + u32 apicid =3D cpu_physical_id(cpu); =20 node =3D apicid < MAX_LOCAL_APIC ? apicid_to_node[apicid] : NUMA_NO_NO= DE; if ( node =3D=3D NUMA_NO_NODE ) @@ -346,7 +346,7 @@ static void __init normalise_cpu_order(void) =20 for_each_present_cpu ( i ) { - apicid =3D x86_cpu_to_apicid[i]; + apicid =3D cpu_physical_id(i); min_diff =3D min_cpu =3D ~0u; =20 /* @@ -357,12 +357,12 @@ static void __init normalise_cpu_order(void) j < nr_cpu_ids; j =3D cpumask_next(j, &cpu_present_map) ) { - diff =3D x86_cpu_to_apicid[j] ^ apicid; + diff =3D cpu_physical_id(j) ^ apicid; while ( diff & (diff-1) ) diff &=3D diff-1; if ( (diff < min_diff) || ((diff =3D=3D min_diff) && - (x86_cpu_to_apicid[j] < x86_cpu_to_apicid[min_cpu])) ) + (cpu_physical_id(j) < cpu_physical_id(min_cpu))) ) { min_diff =3D diff; min_cpu =3D j; @@ -378,9 +378,9 @@ static void __init normalise_cpu_order(void) =20 /* Switch the best-matching CPU with the next CPU in logical order= . */ j =3D cpumask_next(i, &cpu_present_map); - apicid =3D x86_cpu_to_apicid[min_cpu]; - x86_cpu_to_apicid[min_cpu] =3D x86_cpu_to_apicid[j]; - x86_cpu_to_apicid[j] =3D apicid; + apicid =3D cpu_physical_id(min_cpu); + cpu_physical_id(min_cpu) =3D cpu_physical_id(j); + cpu_physical_id(j) =3D apicid; } } =20 diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 4c54ecbc91d7..de87c5a41926 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -1154,7 +1154,7 @@ void __init smp_prepare_cpus(void) print_cpu_info(0); =20 boot_cpu_physical_apicid =3D get_apic_id(); - x86_cpu_to_apicid[0] =3D boot_cpu_physical_apicid; + cpu_physical_id(0) =3D boot_cpu_physical_apicid; =20 stack_base[0] =3D (void *)((unsigned long)stack_start & ~(STACK_SIZE -= 1)); =20 @@ -1374,7 +1374,7 @@ int __cpu_up(unsigned int cpu) { int apicid, ret; =20 - if ( (apicid =3D x86_cpu_to_apicid[cpu]) =3D=3D BAD_APICID ) + if ( (apicid =3D cpu_physical_id(cpu)) =3D=3D BAD_APICID ) return -ENODEV; =20 if ( (!x2apic_enabled && apicid >=3D APIC_ALL_CPUS) || diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c index a8d8af22f6d8..d54c8d93cff0 100644 --- a/xen/arch/x86/spec_ctrl.c +++ b/xen/arch/x86/spec_ctrl.c @@ -589,7 +589,7 @@ static bool __init check_smt_enabled(void) * has a non-zero thread id component indicates that SMT is active. */ for_each_present_cpu ( cpu ) - if ( x86_cpu_to_apicid[cpu] & (boot_cpu_data.x86_num_siblings - 1)= ) + if ( cpu_physical_id(cpu) & (boot_cpu_data.x86_num_siblings - 1) ) return true; =20 return false; diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index c107f40c6283..67d8ab3f824a 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -58,7 +58,7 @@ static long cf_check smt_up_down_helper(void *data) for_each_present_cpu ( cpu ) { /* Skip primary siblings (those whose thread id is 0). */ - if ( !(x86_cpu_to_apicid[cpu] & sibling_mask) ) + if ( !(cpu_physical_id(cpu) & sibling_mask) ) continue; =20 if ( !up && core_parking_remove(cpu) ) --=20 2.41.0