From patchwork Fri Nov 25 06:32:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 25849 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3807162wrr; Thu, 24 Nov 2022 22:40:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf5K0UQyXnt2vUasDZRf7A2oYf5oO8SXK+T/ebOmPdCzB51KxWg/sJhh35i30kTryoIpjWlg X-Received: by 2002:a63:580a:0:b0:477:12e3:6e1c with SMTP id m10-20020a63580a000000b0047712e36e1cmr17478384pgb.126.1669358455582; Thu, 24 Nov 2022 22:40:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669358455; cv=none; d=google.com; s=arc-20160816; b=dLsy3mJvl59eCJiP7Bp0y1rT3GO6y09M+je0riQzfN8MkFURHFqLzuRORzBY56Tclo J8MUgpD4q6MxPSiMk7548TQBSjylmmOLvWF99DNT0ThMESXIpjo+3Iqwf9SHyPVGZScq qMrX4qrcXhkV84P9m1RlRjPCaAUTXRFusYhl5zxaEqOP2xM/s+ZIk7drSEut61bXum5l bdiY3Snapf5Cwjph3csbNq18rVrpUe6n637fm512ZDH0uY8NGM9GH2Qb/X+P9PVyVSRn 98v53ieRiXO3bUQKqZn2DqHmXIXsvSLcF2gwuBQukBYzSfq6f/LUGW4CzAdvVW0QfZt4 ubOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ziIK+rCoFeI7eY+iutr/3xmiOnoDvSfijRGI/bUo88Y=; b=pJu731xN8Y/2lgFEvjHhA+0Wxw4hHKTRJbTtlFiWSKQxpRGUZJwC9XGzwseiYAM/PG urDfsWr3YXCsbEGWrKk5GXmVOhP8C8QdkWrLeFyRWFYTMILYB+GbSC+yBjTVgW/Qq8u8 UNpQoRYu4Cs2gColPEZcNJU53Ngqe+o85Xx3koFQ9hhm0Rr3vMzYy97lEZqmSJoRhQcY dLxHEO3OzWJgWG4LY047n8Q6+AVmp/V6BXCdSomQQ/VU8X1lqtK3pBPVCPLyJT0suZkM RODUl9PpgJ1PzOPi+Zs83eeY7zpH227zvg+jrTV9fRL2RhCNp3W3/6jyupQrjmMODW42 g5uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=E3Fu0Kx3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lw17-20020a17090b181100b002130c156ee5si2910557pjb.152.2022.11.24.22.40.43; Thu, 24 Nov 2022 22:40:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=E3Fu0Kx3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbiKYGc7 (ORCPT + 99 others); Fri, 25 Nov 2022 01:32:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbiKYGc6 (ORCPT ); Fri, 25 Nov 2022 01:32:58 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C49EB27FF3 for ; Thu, 24 Nov 2022 22:32:57 -0800 (PST) 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) 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= 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 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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750449212127193057?= X-GMAIL-MSGID: =?utf-8?q?1750449212127193057?= 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 --- 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); +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 HOTPLUG_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(); } #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) 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