From nobody Mon Apr 29 09:53:13 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1669358009; cv=none; d=zohomail.com; s=zohoarc; b=HKm1/41QPF+fXt+W/O1aliYPCmzB6vXqy/f+cav4dwBqeRRhIEszLYCpv2+mINobw8m6d29ULjvmWhd7pZFXHnaRo4ez9HMh0RvtMdsCf4OhD2Sk8Xn92Bm8CKs82o5960cnMVW3aVu0P68I1mqFaTNaqAzJU3mxFMnS3UVvx8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669358009; 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=ziIK+rCoFeI7eY+iutr/3xmiOnoDvSfijRGI/bUo88Y=; b=WEwNbaui0wHTAGMVn76bgpv6M2/1V3n7J2wEKXmE+IcP5bHHP9FPiGpDHpg3hgx25PYORLYDrT5Z4LuDtkIxbN36YQ284aDlos+9W8BJ8edR3PvVAK8phgj9dpTQ7LwKfy2hU0MC2kYP3keFV/GdEacqCfecolhZ2prAD7pfyqI= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1669358009981131.10397194431278; Thu, 24 Nov 2022 22:33:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.448072.704912 (Exim 4.92) (envelope-from ) id 1oySGj-0006HE-Ss; Fri, 25 Nov 2022 06:33:01 +0000 Received: by outflank-mailman (output) from mailman id 448072.704912; Fri, 25 Nov 2022 06:33:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oySGj-0006H7-Po; Fri, 25 Nov 2022 06:33:01 +0000 Received: by outflank-mailman (input) for mailman id 448072; Fri, 25 Nov 2022 06:33:01 +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 1oySGj-0006Fz-2P for xen-devel@lists.xenproject.org; Fri, 25 Nov 2022 06:33:01 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [2001:67c:2178:6::1d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ff7fcff1-6c8a-11ed-8fd2-01056ac49cbb; Fri, 25 Nov 2022 07:32:57 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8491D1FD78; Fri, 25 Nov 2022 06:32:56 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4120D13A08; Fri, 25 Nov 2022 06:32:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 7omwDphhgGM2cgAAMHmgww (envelope-from ); Fri, 25 Nov 2022 06:32:56 +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: ff7fcff1-6c8a-11ed-8fd2-01056ac49cbb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1669357976; h=from:from:reply-to: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=ziIK+rCoFeI7eY+iutr/3xmiOnoDvSfijRGI/bUo88Y=; b=E3Fu0Kx3qoRkBQP7xpdpuPfIY0XXiBlnHN2HzddWNJ01CNIBeFOmXue54a24INdZsrAsiU ek/AWAyMzXpzM4tipyL9lbaO5ZvFSpy1VhRiokrYjoEsm71TE+OD/AcGjq3k+9iGnc7p0t XWLO2MwgkHNNWCpTfSFuTbJ3wLM9sFQ= From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , xen-devel@lists.xenproject.org Subject: [PATCH 1/2] x86/xen: don't let xen_pv_play_dead() return Date: Fri, 25 Nov 2022 07:32:47 +0100 Message-Id: <20221125063248.30256-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221125063248.30256-1-jgross@suse.com> References: <20221125063248.30256-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1669358010626100003 Content-Type: text/plain; charset="utf-8" A function called via the paravirt play_dead() hook should not return to the caller. xen_pv_play_dead() has a problem in this regard, as it currently will return in case an offlined cpu is brought to life again. This can be changed only by doing basically a longjmp() to cpu_bringup_and_idle(), as the hypercall for bringing down the cpu will just return when the cpu is coming up again. Just re-initializing the cpu isn't possible, as the Xen hypervisor will deny that operation. So introduce xen_cpu_bringup_again() resetting the stack and calling cpu_bringup_and_idle(), which can be called after HYPERVISOR_vcpu_op() in xen_pv_play_dead(). Signed-off-by: Juergen Gross Acked-by: Peter Zijlstra (Intel) Reviewed-by: Boris Ostrovsky --- arch/x86/xen/smp.h | 2 ++ arch/x86/xen/smp_pv.c | 13 ++----------- arch/x86/xen/xen-head.S | 7 +++++++ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/x86/xen/smp.h b/arch/x86/xen/smp.h index bd02f9d50107..6e90a312067b 100644 --- a/arch/x86/xen/smp.h +++ b/arch/x86/xen/smp.h @@ -21,6 +21,8 @@ void xen_smp_send_reschedule(int cpu); void xen_smp_send_call_function_ipi(const struct cpumask *mask); void xen_smp_send_call_function_single_ipi(int cpu); =20 +void xen_cpu_bringup_again(unsigned long stack); + struct xen_common_irq { int irq; char *name; diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c index 480be82e9b7b..b40b24382fe3 100644 --- a/arch/x86/xen/smp_pv.c +++ b/arch/x86/xen/smp_pv.c @@ -385,17 +385,8 @@ static void xen_pv_play_dead(void) /* used only with H= OTPLUG_CPU */ { play_dead_common(); HYPERVISOR_vcpu_op(VCPUOP_down, xen_vcpu_nr(smp_processor_id()), NULL); - cpu_bringup(); - /* - * commit 4b0c0f294 (tick: Cleanup NOHZ per cpu data on cpu down) - * clears certain data that the cpu_idle loop (which called us - * and that we return from) expects. The only way to get that - * data back is to call: - */ - tick_nohz_idle_enter(); - tick_nohz_idle_stop_tick_protected(); - - cpuhp_online_idle(CPUHP_AP_ONLINE_IDLE); + xen_cpu_bringup_again((unsigned long)task_pt_regs(current)); + BUG(); } =20 #else /* !CONFIG_HOTPLUG_CPU */ diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index ffaa62167f6e..e36ea4268bd2 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -76,6 +76,13 @@ SYM_CODE_START(asm_cpu_bringup_and_idle) =20 call cpu_bringup_and_idle SYM_CODE_END(asm_cpu_bringup_and_idle) + +SYM_CODE_START(xen_cpu_bringup_again) + UNWIND_HINT_FUNC + mov %rdi, %rsp + UNWIND_HINT_REGS + call cpu_bringup_and_idle +SYM_CODE_END(xen_cpu_bringup_again) .popsection #endif #endif --=20 2.35.3 From nobody Mon Apr 29 09:53:13 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1669358008; cv=none; d=zohomail.com; s=zohoarc; b=isyfwhhQEL6ZG04M0APwARRznnsrs1KIDRn/A5TmfAzL2YrpLrFWMRi6P7uvITKcUeoqP24ZDjCbdXnbWHwY0VvBuG3SD+FDR053fQSsaEaHIkECWuKOKHWt0pUnM/k2lFI/m49N1a+dxkerXGHtwV1evsbOTclANO1CPmYiRGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669358008; 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=sjhgFpq3nYstNjfYRzieZLbVirxwSh2gasV8m6EaAKQ=; b=RssFFB0kOgk/nRe2sfpFWv9HpM6j5/TmCchCRwCRVuEfm/rjCAYO3T6eZZFxpAFd02kyozQGMQuVzXS9/bQSvDOB1FF/0Jcahs9hOfDXsWM57AS+OpaWPBBYD+gTeWD6Xb194i0OcZTc6UaCgbHLaKCUnVGN3DKkZ5EbHdIUZQY= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1669358008708206.59175910552904; Thu, 24 Nov 2022 22:33:28 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.448073.704923 (Exim 4.92) (envelope-from ) id 1oySGn-0006YS-4g; Fri, 25 Nov 2022 06:33:05 +0000 Received: by outflank-mailman (output) from mailman id 448073.704923; Fri, 25 Nov 2022 06:33:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oySGn-0006YL-1K; Fri, 25 Nov 2022 06:33:05 +0000 Received: by outflank-mailman (input) for mailman id 448073; Fri, 25 Nov 2022 06:33:03 +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 1oySGl-0006Fz-C8 for xen-devel@lists.xenproject.org; Fri, 25 Nov 2022 06:33:03 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 02f2b2db-6c8b-11ed-8fd2-01056ac49cbb; Fri, 25 Nov 2022 07:33:02 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4FA8421ABF; Fri, 25 Nov 2022 06:33:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E857813A08; Fri, 25 Nov 2022 06:33:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id pwBBN51hgGNAcgAAMHmgww (envelope-from ); Fri, 25 Nov 2022 06:33:01 +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: 02f2b2db-6c8b-11ed-8fd2-01056ac49cbb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1669357982; h=from:from:reply-to: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=sjhgFpq3nYstNjfYRzieZLbVirxwSh2gasV8m6EaAKQ=; b=WDct/+NCNMhDQE3uXaBL1eSMquJ+aAJ6SOdEfs5IVwH8j5P+SVyd/tSR+tBqNwQ3iidDPA qPLL8VKJZ6WUWyuleQ3KgkLtaxQHEHncfn9DIQ4xJeQ4EfmNCi9HqoUZ/c1BxcyVk5gkh2 WQGx86OgKF1EFuwnDxgcDw86HtASnuk= From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Josh Poimboeuf , Peter Zijlstra , xen-devel@lists.xenproject.org Subject: [PATCH 2/2] x86/xen: mark xen_pv_play_dead() as __noreturn Date: Fri, 25 Nov 2022 07:32:48 +0100 Message-Id: <20221125063248.30256-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221125063248.30256-1-jgross@suse.com> References: <20221125063248.30256-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1669358010620100001 Content-Type: text/plain; charset="utf-8" Mark xen_pv_play_dead() and related to that xen_cpu_bringup_again() as "__noreturn". Signed-off-by: Juergen Gross Acked-by: Peter Zijlstra (Intel) Reviewed-by: Boris Ostrovsky --- arch/x86/xen/smp.h | 2 +- arch/x86/xen/smp_pv.c | 4 ++-- tools/objtool/check.c | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/xen/smp.h b/arch/x86/xen/smp.h index 6e90a312067b..22fb982ff971 100644 --- a/arch/x86/xen/smp.h +++ b/arch/x86/xen/smp.h @@ -21,7 +21,7 @@ void xen_smp_send_reschedule(int cpu); void xen_smp_send_call_function_ipi(const struct cpumask *mask); void xen_smp_send_call_function_single_ipi(int cpu); =20 -void xen_cpu_bringup_again(unsigned long stack); +void __noreturn xen_cpu_bringup_again(unsigned long stack); =20 struct xen_common_irq { int irq; diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c index b40b24382fe3..5801f93d567c 100644 --- a/arch/x86/xen/smp_pv.c +++ b/arch/x86/xen/smp_pv.c @@ -381,7 +381,7 @@ static void xen_pv_cpu_die(unsigned int cpu) } } =20 -static void xen_pv_play_dead(void) /* used only with HOTPLUG_CPU */ +static void __noreturn xen_pv_play_dead(void) /* used only with HOTPLUG_CP= U */ { play_dead_common(); HYPERVISOR_vcpu_op(VCPUOP_down, xen_vcpu_nr(smp_processor_id()), NULL); @@ -400,7 +400,7 @@ static void xen_pv_cpu_die(unsigned int cpu) BUG(); } =20 -static void xen_pv_play_dead(void) +static void __noreturn xen_pv_play_dead(void) { BUG(); } diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 43ec14c29a60..becdedc2de99 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -189,6 +189,7 @@ static bool __dead_end_function(struct objtool_file *fi= le, struct symbol *func, "snp_abort", "stop_this_cpu", "usercopy_abort", + "xen_cpu_bringup_again", "xen_start_kernel", }; =20 --=20 2.35.3