From patchwork Mon Dec 6 15:20:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12658717 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98457C433EF for ; Mon, 6 Dec 2021 15:21:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.239234.414655 (Exim 4.92) (envelope-from ) id 1muFnR-0004U0-Sc; Mon, 06 Dec 2021 15:20:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 239234.414655; Mon, 06 Dec 2021 15:20:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1muFnR-0004Tt-PP; Mon, 06 Dec 2021 15:20:53 +0000 Received: by outflank-mailman (input) for mailman id 239234; Mon, 06 Dec 2021 15:20:53 +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 1muFnR-0004IB-Au for xen-devel@lists.xenproject.org; Mon, 06 Dec 2021 15:20:53 +0000 Received: from galois.linutronix.de (galois.linutronix.de [193.142.43.55]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 18e9d030-56a8-11ec-a5e1-b9374ead2679; Mon, 06 Dec 2021 16:20:51 +0100 (CET) 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: 18e9d030-56a8-11ec-a5e1-b9374ead2679 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1638804051; 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=CpKf9mvjkPjVBj3xIynQ2IUnpCyITLeKj1fi9KomO3Y=; b=uWwUXVC0WnVC3w1cQSTya5dZeSue12+qWIVuC9ayyFkiDFL9G0Sfv5sgG3Mgji+USmrR3i EWpfPFRxIdEY4IeWA5TWOKrxndqoCjKhwS6Z84fCwmzqI5MqDfCdegIbuQZB9GjhIHEpm9 FJUtBRyeKaSoniNraKma5SZ8iP39mUCHkVgOKy+C16EcbvOsEWo9i5G2eiITHhzNmorRso R1QtcOksTF0JVbuDGxPjJ7j9MocO7Ohie4/A49LY70+rxjBb6jRaD1eLJouksuwvmd3vQZ Rkq3hMTMD3s+vWnN5KKN/KHj6i88h4DUhAnWP0giyBHHvJVKFll4ezdxsGpv4A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1638804051; 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=CpKf9mvjkPjVBj3xIynQ2IUnpCyITLeKj1fi9KomO3Y=; b=O6EsH4ldQp4/tYChtuSnommkfShCw+Bw6sFmYII9N55xtHImCMLD/K/4e4TqkJmdda93r3 FJIAmKHYkC9TGkCw== 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 1/2] x86/xen: Allow to retry if cpu_initialize_context() failed. Date: Mon, 6 Dec 2021 16:20:33 +0100 Message-Id: <20211206152034.2150770-2-bigeasy@linutronix.de> In-Reply-To: <20211206152034.2150770-1-bigeasy@linutronix.de> References: <20211206152034.2150770-1-bigeasy@linutronix.de> MIME-Version: 1.0 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 --- 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 6a8f3b53ab834..86368fcef4667 100644 --- a/arch/x86/xen/smp_pv.c +++ b/arch/x86/xen/smp_pv.c @@ -277,8 +277,11 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle) return 0; ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL); - if (ctxt == NULL) + if (ctxt == NULL) { + cpumask_clear_cpu(cpu, xen_cpu_initialized_map); + cpumask_clear_cpu(cpu, cpu_callout_mask); return -ENOMEM; + } gdt = get_cpu_gdt_rw(cpu);