From nobody Tue Feb 10 07:44:09 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; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610544411; cv=none; d=zohomail.com; s=zohoarc; b=NygT0OnoMdFpTkFPPIhCZ83mHASoRe14wDuxFctY2pFROukTZ29RO1/ZFfMXz1PIxhJESBQGyFKvNVYUP54q0aS0MSba4KIUA2L7+iFq4KETyyR4zVnv/tWZRHtAvTcyYk+cwLgOt+GZgP+OopShUGxDxhM75GIHd4aOLSCB4Lk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610544411; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y4zmIg7u/h9MHqeM4gjTkQQySHu05FosItAdEAKmRis=; b=UR22t77tgJJORUAv30rB6NnuIO60LkcpUwtvh0XW7ZNhaeLBA5B2RZk5d1jPWZ0SLEBePAfyzW1acaMSWD5+hV20/KdCmVcwQbUisv2KGAeAbvdAlKJ6FRjTW4RxylxOHArwwV0+UvpTRqI/UfnWyKv5tDM3iGBmdlvf4cMhhWs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1610544411573517.2016204498779; Wed, 13 Jan 2021 05:26:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.66515.118164 (Exim 4.92) (envelope-from ) id 1kzgAL-0002bC-JR; Wed, 13 Jan 2021 13:26:25 +0000 Received: by outflank-mailman (output) from mailman id 66515.118164; Wed, 13 Jan 2021 13:26:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kzgAL-0002b5-GL; Wed, 13 Jan 2021 13:26:25 +0000 Received: by outflank-mailman (input) for mailman id 66515; Wed, 13 Jan 2021 13:26:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kzgAH-0002b0-JS for xen-devel@lists.xenproject.org; Wed, 13 Jan 2021 13:26:24 +0000 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0847f02a-fbde-46bc-a9de-1d961f881292; Wed, 13 Jan 2021 13:26:17 +0000 (UTC) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzgA6-0007Xv-1g; Wed, 13 Jan 2021 13:26:10 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1kzgA4-001m3I-Vn; Wed, 13 Jan 2021 13:26:08 +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 X-Inumbo-ID: 0847f02a-fbde-46bc-a9de-1d961f881292 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description; bh=Y4zmIg7u/h9MHqeM4gjTkQQySHu05FosItAdEAKmRis=; b=RufyiL/GIwWsux2Ru6gogAORBV a65xJVPOwz3qatqWk3zzNwtOYg0i3MKn4wFACQg6qP2D6R/KvTSylaYy74r1r70G87qoVy5p2uE3r w0ic8bkGTB5yJRbdMGspt8U1e/MT+CfXhy0T0q3aIRH0xf7KRrW4DxkD7/s35O94o6kGXcSTDsJFn EoaC19Iz6gcgu+dLZI2cNOEXzDN17I7L/iXV4XLyzzvgW52gcSna0e3051eZ6RZC1kALIuN2aAbV4 vfTxLZuTZcWrbpymZIDADDWbeNVrZLs2cKEWaZesU4DeeWiMzczPjWw2X5d0FfBv+qc2Uqe6h1ha/ 4JXHGvCg==; From: David Woodhouse To: x86@kernel.org Cc: Stefano Stabellini , Boris Ostrovsky , Juergen Gross , Paul Durrant , jgrall@amazon.com, karahmed@amazon.de, xen-devel Subject: [PATCH v4 5/5] x86/xen: Fix xen_hvm_smp_init() when vector callback not available Date: Wed, 13 Jan 2021 13:26:06 +0000 Message-Id: <20210113132606.422794-6-dwmw2@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210113132606.422794-1-dwmw2@infradead.org> References: <20210113132606.422794-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) From: David Woodhouse Only the IPI-related functions in the smp_ops should be conditional on the vector callback being available. The rest should still happen: =E2=80=A2 xen_hvm_smp_prepare_boot_cpu() This function does two things, both of which should still happen if there is no vector callback support. The call to xen_vcpu_setup() for vCPU0 should still happen as it just sets up the vcpu_info for CPU0. That does happen for the secondary vCPUs too, from xen_cpu_up_prepare_hvm(). The second thing it does is call xen_init_spinlocks(), which perhaps counter-intuitively should *also* still be happening in the case without vector callbacks, so that it can clear its local xen_pvspin flag and disable the virt_spin_lock_key accordingly. Checking xen_have_vector_callback in xen_init_spinlocks() itself would affect PV guests, so set the global nopvspin flag in xen_hvm_smp_init() instead, when vector callbacks aren't available. =E2=80=A2 xen_hvm_smp_prepare_cpus() This does some IPI-related setup by calling xen_smp_intr_init() and xen_init_lock_cpu(), which can be made conditional. And it sets the xen_vcpu_id to XEN_VCPU_ID_INVALID for all possible CPUS, which does need to happen. =E2=80=A2 xen_smp_cpus_done() This offlines any vCPUs which doesn't fit in the global shared_info page, if separate vcpu_info placement isn't available. That part also needs to happen regardless of vector callback support. =E2=80=A2 xen_hvm_cpu_die() This doesn't actually do anything other than commin_cpu_die() right right now in the !vector_callback case; all three teardown functions it calls should be no-ops. But to guard against future regressions it's useful to call it anyway, and for it to explicitly check for xen_have_vector_callback before calling those additional functions. Signed-off-by: David Woodhouse Reviewed-by: Boris Ostrovsky --- arch/x86/xen/smp_hvm.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/arch/x86/xen/smp_hvm.c b/arch/x86/xen/smp_hvm.c index f5e7db4f82ab..056430a1080b 100644 --- a/arch/x86/xen/smp_hvm.c +++ b/arch/x86/xen/smp_hvm.c @@ -33,9 +33,11 @@ static void __init xen_hvm_smp_prepare_cpus(unsigned int= max_cpus) int cpu; =20 native_smp_prepare_cpus(max_cpus); - WARN_ON(xen_smp_intr_init(0)); =20 - xen_init_lock_cpu(0); + if (xen_have_vector_callback) { + WARN_ON(xen_smp_intr_init(0)); + xen_init_lock_cpu(0); + } =20 for_each_possible_cpu(cpu) { if (cpu =3D=3D 0) @@ -50,9 +52,11 @@ static void __init xen_hvm_smp_prepare_cpus(unsigned int= max_cpus) static void xen_hvm_cpu_die(unsigned int cpu) { if (common_cpu_die(cpu) =3D=3D 0) { - xen_smp_intr_free(cpu); - xen_uninit_lock_cpu(cpu); - xen_teardown_timer(cpu); + if (xen_have_vector_callback) { + xen_smp_intr_free(cpu); + xen_uninit_lock_cpu(cpu); + xen_teardown_timer(cpu); + } } } #else @@ -64,14 +68,17 @@ static void xen_hvm_cpu_die(unsigned int cpu) =20 void __init xen_hvm_smp_init(void) { - if (!xen_have_vector_callback) + smp_ops.smp_prepare_boot_cpu =3D xen_hvm_smp_prepare_boot_cpu; + smp_ops.smp_prepare_cpus =3D xen_hvm_smp_prepare_cpus; + smp_ops.smp_cpus_done =3D xen_smp_cpus_done; + smp_ops.cpu_die =3D xen_hvm_cpu_die; + + if (!xen_have_vector_callback) { + nopvspin =3D true; return; + } =20 - smp_ops.smp_prepare_cpus =3D xen_hvm_smp_prepare_cpus; smp_ops.smp_send_reschedule =3D xen_smp_send_reschedule; - smp_ops.cpu_die =3D xen_hvm_cpu_die; smp_ops.send_call_func_ipi =3D xen_smp_send_call_function_ipi; smp_ops.send_call_func_single_ipi =3D xen_smp_send_call_function_single_i= pi; - smp_ops.smp_prepare_boot_cpu =3D xen_hvm_smp_prepare_boot_cpu; - smp_ops.smp_cpus_done =3D xen_smp_cpus_done; } --=20 2.29.2