Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2183658rbb; Tue, 27 Feb 2024 13:27:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU6CH2vWr1DgKzSr8VAzYO8Yu3xcgLvnbndHL61g+seqygTo9qYyVjZopTQYkYSUMFCbsjsNbiIOGaRoH2dK70y8SStifRI6BCgFtE5JQ== X-Google-Smtp-Source: AGHT+IHo+OlF49o5jP2+OXLGspt2sNqcrxZoVezcGicntiP2opWe/CRjRglmRGTGlNhipDSYqpXR X-Received: by 2002:a05:6a00:d55:b0:6e4:d868:7f43 with SMTP id n21-20020a056a000d5500b006e4d8687f43mr11233813pfv.5.1709069229009; Tue, 27 Feb 2024 13:27:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709069228; cv=pass; d=google.com; s=arc-20160816; b=lO7ruLmwBO8OO93EYUpiHrqzHBTLGiYa51LR74orMYhd8+m9MY04lONF9mxEzZQ59M D186jnNoNW0kCL4AbwTBKCNxW/Ob/UPLIo4KksDj6LJU4KAE6B32hU7SwZ7qRxu7kzZm wVhytcBDZRTdgc3geubgNR/5H8WmKIcLPI17pGJBtdTugQUperdHOknCFWHVhhZ6nRGu LHpTnsRqzT+0Z/V/8sFVLSWWov+eKS3/zrfZdtUlPqB6D8xwZkbpSCyAVo/2f5KvSvYy iYs90GSd4c7HR+KdbI2EvW0uQJUzk2/xW8Ar8uKoxl/To5gO6vPvOjpNxv+F3Mrnl5RE CWNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1DIayc1K30UV8O/dasJJA9Pj6/H0Vw6+uliUsVfettk=; fh=OvJRnOqsMTm9XoNmEwebcqh9Ud7yh1CTeKAP84ols98=; b=f1ZtOj3aYQDB/UbKID0WgAqCB3H8G7qpEuzFsQOuV1ElfEQNBlxG8I5DrzSFjJaQSw lyyeqT5TQoepM3GBTi42rR/NW+FvLMI+VtyQOdufjRworKC5+Yb4Jx0G0//P24m4xZ9/ tLq+XivIYQYcdhL15tFrm+u344kE/hMzSl0dx+6gRKXgUX9NXqnB4Y9yy9JPtWHE8Bkz VAUeTYMwp+/08kACal8cPOiBmg3yfnQIWWaQ6GzAwfsfhE9vXG85WkOmXNgogUoPs3JM kdabeAO5D+i16c9tlvP7hW436+GxjS7E172S5k93NwmL0oMVf2dGG8U2J+FUQjiCKKI5 jWdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZsWJYbi+; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84040-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z13-20020aa785cd000000b006e37a65f716si5966993pfn.193.2024.02.27.13.27.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 13:27:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZsWJYbi+; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84040-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 74350291201 for ; Tue, 27 Feb 2024 21:27:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AD52158D93; Tue, 27 Feb 2024 21:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZsWJYbi+" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F238158D65 for ; Tue, 27 Feb 2024 21:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709069115; cv=none; b=K4/eNE5BnBwMJ0iHxSnc8zCLIFdedqZ3x7WS8/KhlX8pAfgOVwWE6Bn8ciH14H5azRGub5xTvPwWrJUe/dQ5z3ku/GB1H9OzWTR+LgV1v/CZgkz2mYUX19/ZID08K5oTuzOtrj6vQb72SC5x9rFGqBQ/SwBrC74sLWwIOX5f7YA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709069115; c=relaxed/simple; bh=D4SysnZaXorUFc+XF+aGbS1csNj7xK6JLwiHqGE+3Sk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j8eSUqofGfm5axrLOQk972VPxbAcI/RK1Uz7jbgKkdhb7Fcjy30g1j6oQDrgCAd7nFwvoHApmZ4xHcfR2x73qgRHRYxkiN9nQRdDbFvABVhmM1IinZGYZCsEjnzwAxYeLTLR+eqvUsU3qF9+lqFeknEQ9c336YAO9GbzbKBclig= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZsWJYbi+; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mgamail.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709069115; x=1740605115; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D4SysnZaXorUFc+XF+aGbS1csNj7xK6JLwiHqGE+3Sk=; b=ZsWJYbi+NT1lZjnRH7rmr1RX2o6Shk+rJr2QMexGHQ6rq/Gkgv6cZ2Gp ztCM9m5cQGxLUy27BSQ0z0rsGgjJZiC/Tt6xkK7HYTMUiBRoR1/Y6CzG6 u2QrIwvVpWVZeRlUxE/5ELm3xIAT3Nb9/6qNcNrB+jLGqsOgm9T0XNE+c FJ9Vw6FA91Cd3t+wfPzr5TVr6/cshgFDp/5vBqlVc3Ih24Bbjz0iw/q7f CQme8TOgEI/FK/pvDs2N2FxMf++wMBcO16qkROlvnO4k+YGSsJKGWgfs+ j7nRhpi3xiZHg6RPnPTtOBgSHQMM50RqcYmnNRPjJvH5mvw+QZSxdO6co g==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="3567045" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="3567045" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 13:25:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="937032914" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="937032914" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 27 Feb 2024 13:25:02 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 9E2D31033; Tue, 27 Feb 2024 23:24:56 +0200 (EET) From: "Kirill A. Shutemov" To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , "Huang, Kai" , Baoquan He , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv8 14/17] x86/smp: Add smp_ops.stop_this_cpu() callback Date: Tue, 27 Feb 2024 23:24:49 +0200 Message-ID: <20240227212452.3228893-15-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227212452.3228893-1-kirill.shutemov@linux.intel.com> References: <20240227212452.3228893-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If the helper is defined, it is called instead of halt() to stop the CPU at the end of stop_this_cpu() and on crash CPU shutdown. ACPI MADT will use it to hand over the CPU to BIOS in order to be able to wake it up again after kexec. Signed-off-by: Kirill A. Shutemov Acked-by: Kai Huang Reviewed-by: Thomas Gleixner --- arch/x86/include/asm/smp.h | 1 + arch/x86/kernel/process.c | 7 +++++++ arch/x86/kernel/reboot.c | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index 4fab2ed454f3..390d53fd34f9 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -38,6 +38,7 @@ struct smp_ops { int (*cpu_disable)(void); void (*cpu_die)(unsigned int cpu); void (*play_dead)(void); + void (*stop_this_cpu)(void); void (*send_call_func_ipi)(const struct cpumask *mask); void (*send_call_func_single_ipi)(int cpu); diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index ab49ade31b0d..00c1b957476d 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -835,6 +835,13 @@ void __noreturn stop_this_cpu(void *dummy) */ cpumask_clear_cpu(cpu, &cpus_stop_mask); +#ifdef CONFIG_SMP + if (smp_ops.stop_this_cpu) { + smp_ops.stop_this_cpu(); + unreachable(); + } +#endif + for (;;) { /* * Use native_halt() so that memory contents don't change diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 0574d4ad6b41..0a75efe579c0 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -880,6 +880,12 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs) cpu_emergency_disable_virtualization(); atomic_dec(&waiting_for_crash_ipi); + + if (smp_ops.stop_this_cpu) { + smp_ops.stop_this_cpu(); + unreachable(); + } + /* Assume hlt works */ halt(); for (;;) -- 2.43.0