From nobody Tue Feb 10 11:12:57 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 19966C433F5 for ; Wed, 9 Feb 2022 08:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240377AbiBIICX (ORCPT ); Wed, 9 Feb 2022 03:02:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238194AbiBIICU (ORCPT ); Wed, 9 Feb 2022 03:02:20 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4F2CC05CB81 for ; Wed, 9 Feb 2022 00:02:23 -0800 (PST) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1644393741; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FtIrm50qhttDnvw+t6HEGKMbZATCUZOMdzvBi9MSe90=; b=M+XiBZLvnS4bNyf917WB109HyC2w29CJUrl4+O3s0DgpsdEx7qd9LvVurUJCNhRS15Nnsu cRSfB+3pzT1O13psRd1f1F9RUn9biTeEoiOyQmgimdTbr/vjqZy4deWCmwndr0QD2ufJ+o Sqd0tsdtLPAXbSLtB6Ji4LmVP+iCKv0Wi8A/f7QNPsiv7QL9eRdaHboT0vES0Rkm5q3nVj SpwQ1re3o986jPQhDh5fxadxCmGBF1Vzc3lThDa3bMhOehonLIvbh9MLuv6ROwY5VULVZR 2E4X2eG/cFMezVii0GULTAbaf5XfnGRONCEx1DX7F1mYfNUvbSlZMPFwSeGCFA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1644393741; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FtIrm50qhttDnvw+t6HEGKMbZATCUZOMdzvBi9MSe90=; b=+3CvOrEeIA0hMtHDBMPRo5y999b5GRmR5FqI8tJFmUGxGgnh38jpNfHNPILyt8qyLKUD1R 20dt3aOcmPlVKbDQ== To: linux-kernel@vger.kernel.org, x86@kernel.org, xen-devel@lists.xenproject.org Cc: Thomas Gleixner , Longpeng , Gonglei , Peter Zijlstra , Ingo Molnar , Valentin Schneider , Juergen Gross , Stefano Stabellini , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Boris Ostrovsky , Sebastian Andrzej Siewior Subject: [PATCH REPOST v2 1/2] x86/xen: Allow to retry if cpu_initialize_context() failed. Date: Wed, 9 Feb 2022 09:02:13 +0100 Message-Id: <20220209080214.1439408-2-bigeasy@linutronix.de> In-Reply-To: <20220209080214.1439408-1-bigeasy@linutronix.de> References: <20220209080214.1439408-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Boris Ostrovsky If memory allocation in cpu_initialize_context() fails then it will bring up the VCPU and leave with the corresponding CPU bit set in xen_cpu_initialized_map. The following (presumably successful) CPU bring up will BUG in xen_pv_cpu_up() because nothing for that VCPU would be initialized. Clear the CPU bits, that were set in cpu_initialize_context() in case the memory allocation fails. [ bigeasy: Creating a patch from Boris' email. ] Signed-off-by: Boris Ostrovsky Signed-off-by: Sebastian Andrzej Siewior Link: https://lore.kernel.org/r/20211206152034.2150770-2-bigeasy@linutronix= .de --- arch/x86/xen/smp_pv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c index 4a6019238ee7d..57c3f9332ec94 100644 --- a/arch/x86/xen/smp_pv.c +++ b/arch/x86/xen/smp_pv.c @@ -260,8 +260,11 @@ cpu_initialize_context(unsigned int cpu, struct task_s= truct *idle) return 0; =20 ctxt =3D kzalloc(sizeof(*ctxt), GFP_KERNEL); - if (ctxt =3D=3D NULL) + if (ctxt =3D=3D NULL) { + cpumask_clear_cpu(cpu, xen_cpu_initialized_map); + cpumask_clear_cpu(cpu, cpu_callout_mask); return -ENOMEM; + } =20 gdt =3D get_cpu_gdt_rw(cpu); =20 --=20 2.34.1