From nobody Mon Feb 9 09:22:24 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 1699984693538326.53617095176503; Tue, 14 Nov 2023 09:58:13 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.633106.987726 (Exim 4.92) (envelope-from ) id 1r2xfX-0003bv-6d; Tue, 14 Nov 2023 17:57:47 +0000 Received: by outflank-mailman (output) from mailman id 633106.987726; Tue, 14 Nov 2023 17:57:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2xfW-0003VY-97; Tue, 14 Nov 2023 17:57:46 +0000 Received: by outflank-mailman (input) for mailman id 633106; Tue, 14 Nov 2023 17:50:47 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2xYl-0004wk-Gi for xen-devel@lists.xenproject.org; Tue, 14 Nov 2023 17:50:47 +0000 Received: from 19.mo582.mail-out.ovh.net (19.mo582.mail-out.ovh.net [188.165.56.177]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 567bcec5-8316-11ee-9b0e-b553b5be7939; Tue, 14 Nov 2023 18:50:46 +0100 (CET) Received: from director8.ghost.mail-out.ovh.net (unknown [10.108.16.176]) by mo582.mail-out.ovh.net (Postfix) with ESMTP id BA50D28A3F for ; Tue, 14 Nov 2023 17:50:45 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-x5j2z (unknown [10.110.115.90]) by director8.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 4F0A71FDF1; Tue, 14 Nov 2023 17:50:45 +0000 (UTC) Received: from 3mdeb.com ([37.59.142.103]) by ghost-submission-6684bf9d7b-x5j2z with ESMTPSA id qLM5EHWzU2V/lwcATVRwWg (envelope-from ); Tue, 14 Nov 2023 17:50:45 +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: 567bcec5-8316-11ee-9b0e-b553b5be7939 Authentication-Results: garm.ovh; auth=pass (GARM-103G0056fce45e0-23cf-4afa-a93e-0729be2d3147, 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 7/9] x86/smp: drop booting_cpu variable Date: Tue, 14 Nov 2023 18:50:10 +0100 Message-ID: <22109ebd7edef1140cb438a6ec5fa1726cdf2c12.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: 12931241905954597232 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrudeffedgudefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhrhihsthhirghnucfjvggsvghluceokhhrhihsthhirghnrdhhvggsvghlseefmhguvggsrdgtohhmqeenucggtffrrghtthgvrhhnpeehleekveevvdfhgeetlefhjedtjefgjedtkeekffeitdffkeffueetkedtgfeiueenucffohhmrghinhepgiekiegpieegrdhssgenucfkphepuddvjedrtddrtddruddpvddufedrudelvddrjeejrddvgeelpdefjedrheelrddugedvrddutdefnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeokhhrhihsthhirghnrdhhvggsvghlseefmhguvggsrdgtohhmqedpnhgspghrtghpthhtohepuddprhgtphhtthhopeigvghnqdguvghvvghlsehlihhsthhsrdigvghnphhrohhjvggtthdrohhrghdpoffvtefjohhsthepmhhoheekvddpmhhouggvpehsmhhtphhouhhtpdgukhhimhepnhhonhgv X-ZM-MESSAGEID: 1699984694876100002 Content-Type: text/plain; charset="utf-8" CPU id is obtained as a side effect of searching for appropriate stack for AP. It can be used as a parameter to start_secondary(). Coincidentally this also makes further work on making AP bring-up code parallel easier. Signed-off-by: Krystian Hebel --- xen/arch/x86/boot/x86_64.S | 13 +++++++++---- xen/arch/x86/smpboot.c | 15 +++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index 8d61f270761f..ad01f20d548d 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -20,20 +20,24 @@ ENTRY(__high_start) jz .L_stack_set =20 /* APs only: get stack base from APIC ID saved in %esp. */ - mov $0, %rax + mov $0, %rbx lea cpu_data(%rip), %rcx /* cpu_data[0] is BSP, skip it. */ 1: - add $1, %rax + add $1, %rbx add $CPUINFO_X86_sizeof, %rcx - cmp $NR_CPUS, %eax + cmp $NR_CPUS, %rbx jb 2f hlt 2: cmp %esp, CPUINFO_X86_apicid(%rcx) jne 1b =20 - /* %rcx is now cpu_data[cpu], read stack base from it. */ + /* + * At this point: + * - %rcx is cpu_data[cpu], read stack base from it, + * - %rbx (callee-save) is Xen cpu number, pass it to start_second= ary(). + */ mov CPUINFO_X86_stack_base(%rcx), %rsp =20 test %rsp,%rsp @@ -101,6 +105,7 @@ ENTRY(__high_start) .L_ap_cet_done: #endif /* CONFIG_XEN_SHSTK || CONFIG_XEN_IBT */ =20 + mov %rbx, %rdi tailcall start_secondary =20 .L_bsp: diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index a3895dafa267..39ffd356dbbc 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -222,8 +222,6 @@ static void smp_callin(void) cpu_relax(); } =20 -static int booting_cpu; - /* CPUs for which sibling maps can be computed. */ static cpumask_t cpu_sibling_setup_map; =20 @@ -311,15 +309,14 @@ static void set_cpu_sibling_map(unsigned int cpu) } } =20 -void start_secondary(void *unused) +void start_secondary(unsigned int cpu) { struct cpu_info *info =3D get_cpu_info(); =20 /* - * Dont put anything before smp_callin(), SMP booting is so fragile th= at we + * Don't put anything before smp_callin(), SMP booting is so fragile t= hat we * want to limit the things done here to the most necessary things. */ - unsigned int cpu =3D booting_cpu; =20 /* Critical region without IDT or TSS. Any fault is deadly! */ =20 @@ -346,9 +343,9 @@ void start_secondary(void *unused) */ spin_debug_disable(); =20 - get_cpu_info()->use_pv_cr3 =3D false; - get_cpu_info()->xen_cr3 =3D 0; - get_cpu_info()->pv_cr3 =3D 0; + info->use_pv_cr3 =3D false; + info->xen_cr3 =3D 0; + info->pv_cr3 =3D 0; =20 /* * BUG_ON() used in load_system_tables() and later code may end up cal= ling @@ -575,8 +572,6 @@ static int do_boot_cpu(int apicid, int cpu) */ mtrr_save_state(); =20 - booting_cpu =3D cpu; - start_eip =3D bootsym_phys(trampoline_realmode_entry); =20 /* start_eip needs be page aligned, and below the 1M boundary. */ --=20 2.41.0