Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1096333rdb; Wed, 24 Jan 2024 05:00:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHO7lBgLyXReHGuMKt3+CgXTkvo3DCpupW1Uu++N/1Mw4JSrX+JJSLZ5OU4I66DjKuio3IK X-Received: by 2002:a17:906:474c:b0:a23:57a1:d85b with SMTP id j12-20020a170906474c00b00a2357a1d85bmr919350ejs.74.1706101211184; Wed, 24 Jan 2024 05:00:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706101211; cv=pass; d=google.com; s=arc-20160816; b=wLGL35on7ALVJz8vlUGVs3EGCkoLmqylxJC7ezIoWptfUbsAWRbV4zHTXr8D+OJsJh ZhiwqyGLX+WMBpEan5qCUxPocIih/bGgGwuP50i8cMoQGZeLYPYxpAVjEQfjE0TOtRmF +gbDtm+sFiPjhUV0KpsWTmcW+SZsPPGBxn5axBJni3n3DT24ZFwfn3X3k+4fRX/9aQ4a yYe0RTnEKkzwRpJH8VBgITOd3ZiupIzjNPHqrqsZ36a3ALPMt3LLOj3yiiQPI9I4ueTX 1vCb/LU0g5hQ8G2jHevCPYTJksN8ZnutQYsX5vNjt5YYl1epKrlNHk82jb2PajndbPUt 0Obw== 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=uUwKCPpS3rWhYaj/Bz1jxeNUFv4P+9IPCpw+Jxi9dLI=; fh=OvJRnOqsMTm9XoNmEwebcqh9Ud7yh1CTeKAP84ols98=; b=sJZSs5/1+pFD5xUBJTi9d1Qrv3zOiTU1IGmx7tzFOsC4g0IRtp06Vl7EpgQTBVTBed phvMAW/8UuSk5VeqWcpYkGf+gDQbqY3JMHQzfl5z8w0l1fOXLU1szT+ovrShIwaI+0zU NfCiT4C5W8Ric0yYT1mVqwjpwj2aezdXIz1jB9Z7LjmCosshAOriAHOOk+OaPwhjj9cD X1+6BLEcdkYMnAg59YXQgxEYs4eV4WoqsxT0ZGX6OZQgzVJmIgkVGmTI3IprH4rzP+qN +LvwPyKj4/d4Z0RFBKjdBTUFdnTmSDvkG1wrqpxtJwPTmCeD2Qmy6RDwgOmryWRxEiqk BbzQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eiFUuutV; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-37036-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t20-20020a170906269400b00a30d6035f6dsi1590153ejc.995.2024.01.24.05.00.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 05:00:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37036-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eiFUuutV; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-37036-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37036-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E74141F29FB6 for ; Wed, 24 Jan 2024 13:00:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7D4C77F08; Wed, 24 Jan 2024 12:57:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eiFUuutV" 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 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: 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 --- 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