From nobody Wed May 1 17:16:02 2024 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; dmarc=pass(p=none dis=none) header.from=linutronix.de ARC-Seal: i=1; a=rsa-sha256; t=1638804085; cv=none; d=zohomail.com; s=zohoarc; b=kIGvgOFmixLnSF97s6eRxSQDcX1WVgf76rzYxdpSgH1zbCoF0C3sthA565kpBe7gS8tkKhIl8PEwJn5YzhI8B4MoQJOO4JcRJEv1L8Q9rPudXfS/wWdwdCPO5i2eYf2Z2avJzYc88Imrmxqw/HbpYJOGXl1/ziTizqNqGZ67GxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638804085; h=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=CpKf9mvjkPjVBj3xIynQ2IUnpCyITLeKj1fi9KomO3Y=; b=fP1522jrKkM+HpcN8poLF/SLwHfRYmvN8WT8Q/jjDi8fhls8CsZXTf4N9kVx2F+nO2WMsAD6EGmb1GFqw5WOQt9B3EBjKisJmBo/LEXWjjjxLpId1k4KVIH56kh3i8hgu+ssQENoGnL7Bl/aSkXvb8OH4cpbKUSb0UCNeuZSsmk= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1638804085021339.7084878980007; Mon, 6 Dec 2021 07:21:25 -0800 (PST) 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 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-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: 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linutronix.de) X-ZM-MESSAGEID: 1638804110695100007 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 --- 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_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 From nobody Wed May 1 17:16:02 2024 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; dmarc=pass(p=none dis=none) header.from=linutronix.de ARC-Seal: i=1; a=rsa-sha256; t=1638804082; cv=none; d=zohomail.com; s=zohoarc; b=VEiKMW4kc3M151eVfjcactiVKG08pw4fNG4N7Jn3KnUi5rFJmtwliltNbKa4DswuvCfK+rPwJbwfm3ytKEycvULlku9cM0ApnW9HnkXhJcTCSZbNE3Ccv116yKHAaZzE/0RWfrP32i+rb9rIeQofVkheECfJLnnrg3r6MXjA8Nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638804082; h=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=41Yw8yf+7TjYHl20/Q/EDf0gZtvNJ2sbLTnT1+NsteE=; b=fJWETKdZaKs1ZnHMijSPcNrG6Es+UP+HOUQNY/K4PzOIHjRa9RgrxX9a7XO0aLOr5zUYJtN5+rMgYHv1etkqJ1URF1aozBMQOqfzRxLyz5DQwzmXzmStcPoom4zAyEo6D+cHw1MBAYMwJlhylsKrhSq+OgAIY2AVALojRLYU8NM= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1638804082731375.54237027299587; Mon, 6 Dec 2021 07:21:22 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.239235.414667 (Exim 4.92) (envelope-from ) id 1muFnY-0004og-49; Mon, 06 Dec 2021 15:21:00 +0000 Received: by outflank-mailman (output) from mailman id 239235.414667; Mon, 06 Dec 2021 15:21:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1muFnY-0004oX-0x; Mon, 06 Dec 2021 15:21:00 +0000 Received: by outflank-mailman (input) for mailman id 239235; Mon, 06 Dec 2021 15:20:58 +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 1muFnW-0004E4-NN for xen-devel@lists.xenproject.org; Mon, 06 Dec 2021 15:20:58 +0000 Received: from galois.linutronix.de (galois.linutronix.de [193.142.43.55]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1cd615dd-56a8-11ec-8a4d-196798b21f7b; Mon, 06 Dec 2021 16:20:58 +0100 (CET) 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: 1cd615dd-56a8-11ec-8a4d-196798b21f7b From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1638804057; 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=41Yw8yf+7TjYHl20/Q/EDf0gZtvNJ2sbLTnT1+NsteE=; b=LQgKbrKct/We7aHQ0TZFYlFpu0pNkOgrZ0sdarc6GLYKUkQoeNNAReN09czDjhMhsLh9te BX3g529ypr8U7D45FxquyLLsCnFTwa0E8VwTVABJ3Nz8tDiFDmwt9s65LduJcR/MYqdWBf TIlYLOsZZ356mha/P1VdYYQwPYgxszdT1xkJgZqKp7s4Q4jUgb4VTxhB2dRrgJejQ+s6Hu RG2ATWq0wWTu0Hp7ii/kr1uHYB2VoBrrmPiAeKTaaGoYw854rUmH3ZiCOjFfry6OfkAJFM QqoIe6pKucm2KTK3qWnikwFJv8x4UouEHovyaNHMt7s4xGg1BcQDOUnjW0tbtA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1638804057; 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=41Yw8yf+7TjYHl20/Q/EDf0gZtvNJ2sbLTnT1+NsteE=; b=sxMj8+RWZBRXTITuDvoBALBqgfRKj9Zi74fNBcRPtr6Ur/ZuBm1c25eHa7tYX8nSmHpODY 3rlnDKXz8mPQb8Bg== 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" , Sebastian Andrzej Siewior , Dongli Zhang , Henry Wang Subject: [PATCH 2/2] cpu/hotplug: Allow the CPU in CPU_UP_PREPARE state to be brought up again. Date: Mon, 6 Dec 2021 16:20:34 +0100 Message-Id: <20211206152034.2150770-3-bigeasy@linutronix.de> In-Reply-To: <20211206152034.2150770-1-bigeasy@linutronix.de> References: <20211206152034.2150770-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linutronix.de) X-ZM-MESSAGEID: 1638804109150100003 Content-Type: text/plain; charset="utf-8" From: "Longpeng(Mike)" A CPU will not show up in virtualized environment which includes an Enclave. The VM splits its resources into a primary VM and a Enclave VM. While the Enclave is active, the hypervisor will ignore all requests to bring up a CPU and this CPU will remain in CPU_UP_PREPARE state. The kernel will wait up to ten seconds for CPU to show up (do_boot_cpu()) and then rollback the hotplug state back to CPUHP_OFFLINE leaving the CPU state in CPU_UP_PREPARE. The CPU state is set back to CPUHP_TEARDOWN_CPU during the CPU_POST_DEAD stage. After the Enclave VM terminates, the primary VM can bring up the CPU again. Allow to bring up the CPU if it is in the CPU_UP_PREPARE state. [bigeasy: Rewrite commit description.] Signed-off-by: Longpeng(Mike) Signed-off-by: Sebastian Andrzej Siewior Link: https://lore.kernel.org/r/20210901051143.2752-1-longpeng2@huawei.com Reviewed-by: Valentin Schneider Tested-by: Dongli Zhang Reviewed-by: Henry Wang Link: https://lore.kernel.org/r/20211122154714.xaoxok3fpk5bgznz@linutronix.= de --- kernel/smpboot.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/smpboot.c b/kernel/smpboot.c index f6bc0bc8a2aab..b9f54544e7499 100644 --- a/kernel/smpboot.c +++ b/kernel/smpboot.c @@ -392,6 +392,13 @@ int cpu_check_up_prepare(int cpu) */ return -EAGAIN; =20 + case CPU_UP_PREPARE: + /* + * Timeout while waiting for the CPU to show up. Allow to try + * again later. + */ + return 0; + default: =20 /* Should not happen. Famous last words. */ --=20 2.34.1