From nobody Wed Dec 24 20:09:54 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) (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 CD1DF7E76F for ; Wed, 24 Jan 2024 12:57:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.93 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706101065; cv=none; b=QRbswA9GHW5nP57viq4AzQTf/gW3XWbc3gCsYsyO1N/Np1NrVL2dkvQtSPK6UN1kpP+0dtdy3u9uk+r8x5bv7aDXecwSGR9Tr4BPjA+w9gSGr+zqQ5O+Ynj/riEl0IFZ4cDgIjFQxcmGRFSPJIrc/BrlCZ5ddgzHC2/IwjItwAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706101065; c=relaxed/simple; bh=tc3l0nnpCsD+Lhvt4gYpUVgX39QxTGQjtHhfAwFvtwg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uBf1RMyn4535rOQ6hHqVwZNY3zRSgaKGLPeYwamBM8HxOO6BQ6E4fazhY2vYojzgj6BGNrzjiQ/ZtHm0gEXgkBi9nVpXDPlELGIV8Vcjnd5prk2c48nCMCImKHsl2SwydyS3Pf5NQxptnm0vJzJSdgzjk6JeObxedZshhAiZ6F4= 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=eiFUuutV; arc=none smtp.client-ip=192.55.52.93 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eiFUuutV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706101063; x=1737637063; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tc3l0nnpCsD+Lhvt4gYpUVgX39QxTGQjtHhfAwFvtwg=; b=eiFUuutVLnHxtOzV/xeNnPaxSkjWPJgka5xbLkHkH+R0Vhs7RWKA787j HoOBXfnbDiU2XHUaFVRccX9ExsIEan+Pj85EEixJAR4z8AUIZ861XprMG 2XUvOly4LglDebXKJ9eoWzod5E9ltzemrRHQLNQu+IcZY8LZSMzrQiN6/ xssUxPJE4QaCOrWeUALruz+geQDRnFo+qW2CDlqgdUQ1xv2/M0nwHwm9h +stXafFJbDo8UEFlaI4qR3b9U6cQD/GZ2E6CaLPyuwY7OALgU+hbWRyw1 x05ho+ycAhHW2mjtq4h930ZuQHfU69gnzG9XKRaSzr7VtJRsKAH1004jf g==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="398990886" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="398990886" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2024 04:57:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="876685865" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="876685865" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jan 2024 04:57:38 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id CA188ADD; Wed, 24 Jan 2024 14:56:02 +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: [PATCHv6 14/16] x86/smp: Add smp_ops.stop_this_cpu() callback Date: Wed, 24 Jan 2024 14:55:55 +0200 Message-ID: <20240124125557.493675-15-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124125557.493675-1-kirill.shutemov@linux.intel.com> References: <20240124125557.493675-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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); =20 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); =20 +#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(); =20 atomic_dec(&waiting_for_crash_ipi); + + if (smp_ops.stop_this_cpu) { + smp_ops.stop_this_cpu(); + unreachable(); + } + /* Assume hlt works */ halt(); for (;;) --=20 2.43.0