Message ID | 20240212104448.2589568-15-kirill.shutemov@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-61363-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2432343dyd; Mon, 12 Feb 2024 05:40:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVY4tA9E/WLULzMsBvqVGxdoa9nRRHOLLAoF46/dxUm7gq4vQ/vEoHyJXmNRvklHpq9XrmqdUa9jBjfzegcYJTUIcs/Nw== X-Google-Smtp-Source: AGHT+IE32DWLiVIqWNZtuAmbhfsTm5zoyGK7YmDJ7yq5RMKZSgv+Sp6PLPFIup/9ONVOCwcHKV7b X-Received: by 2002:ae9:e517:0:b0:786:c1d1:ba6a with SMTP id w23-20020ae9e517000000b00786c1d1ba6amr655434qkf.25.1707745211567; Mon, 12 Feb 2024 05:40:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707745211; cv=pass; d=google.com; s=arc-20160816; b=Mug+1xfE3xgWqwaP26JPj3399pYuR/th0nJ7GEV6VEHG5Hok4kj4FX8bLyWuErrUED kf+cI7neM4HcK4OA0RuR2na9+I3alO1S0rPp6laa3vA/K0OGiRVyKwQ2fna8ik2OmzkB UWrUxgsR7LoQXXTkWyhL7B5/etRChYiTXC2JYPKA+UMHuo4kEa/RRTrP6uh3vla8M/uk B7oRW6EyCP5PQcLJdqKkR7gLDYYlzlkcdr7Gao0YMI8L++ZKZXo9Spj6NGFHkm7wC5q2 vOg71mfSidLkrKgcPKM1zItC84CYJhwD5Fti5OCd7bXLuKvn9k5Lfp0uieqL7VdLqBue mmTA== 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=OhSe+Z01wtsNPO2DlJRg/XljcMsm9Jtupl3TZ04Lwgk=; fh=nOUXiq+nuaGXdtxFa8Q7eYVCH+mfoPHgtaIlIFRh5jw=; b=UK9BnmXT9IROrcGzZikvQFg6jHKbzU4V5Bh+WV5LC86wSHuVsKXMmkFG31zssE7Mq6 f9p/VybqR8GBwIAxAxgUtxUfEgngbXEPSivP/jn1Erf7xlmaHhb84jPXZZSCkyOnjDsg LNs5DJLhmnEeK06EXC0XfuIkH9VB+yREhpGqT8LMy489GzrlB5t7PD2TpI8oRqwS2hfQ 7tUCjgs+NOCsVS9/3e9FR3qGHhOS7+qK1eUDFrtfpQSG/ROJEpVRxcDQD4F+mA//GeNE ps4s2ncLlb7j9krKNTjls9OBK5PEYBvzrnGj5aKJGSzlC1CCxoi92wegeFZYcHQD5Y04 JLTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YYYCuHzB; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61363-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61363-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCUnKuOIRgTv5auC0r+fU1EklUQCBHqK3KOHyYD1q22n0wrMBMUbWdRMUW4TdycUjtYyIH1ko0bJ1OcwQ6xao+jFrfOu7Q== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x19-20020a05620a449300b0078553a07226si6432776qkp.570.2024.02.12.05.40.11 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:40:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61363-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YYYCuHzB; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61363-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61363-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4C89A1C230C2 for <ouuuleilei@gmail.com>; Mon, 12 Feb 2024 10:50:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94B3F3D54D; Mon, 12 Feb 2024 10:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YYYCuHzB" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 B903C3C488 for <linux-kernel@vger.kernel.org>; Mon, 12 Feb 2024 10:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707734714; cv=none; b=U0y5rLr0HmRqcBhHi+wzz3LK6lpvw1wsCVVeG7UUgQwynKRQOpLFSuc6sqrG84BoBXD65xfsgjo5nZQsyEn9EIAmjplgyuZSpdEbYvlZysAniDRstvaSxRUoHTVfS5Mk29EJObz/RoFxWzAsAZAe+7FFFDlip09rXz+iSgV+8JE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707734714; c=relaxed/simple; bh=urUcJtKDz0udsDAvAz2j1S+q/fX/vhzTd+7x3OIZGzI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HgV1Rh5atDl8gxuy2+VfZ2sliTgevmVKnf/9gDDX9L7mqrSc35rI7F7NzlhbDqfjHcr6b1/Bv/F/SH+3PaDUjlyvyok4zT9gIyviOKIKFsH+dDYNnw3a30/MVrh8cwYGERgmyajSNHl4MciYc4LwawL2Nlp/fm/znJUKL+FuPN0= 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=YYYCuHzB; arc=none smtp.client-ip=192.198.163.17 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=1707734712; x=1739270712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=urUcJtKDz0udsDAvAz2j1S+q/fX/vhzTd+7x3OIZGzI=; b=YYYCuHzBS8toj7MqQIOJJzhMjBKHROIraddvg2fYI8QyVMxdFpr88ahZ EAKs+cC65yzdmSvlPjYaWM0DRC8AOIpJoZu/+xERR6A8Sizydqw3q/tCl skHdPmfCwGgLg+QCpIGpHzRKEESvvRrlVPbP8K5YjcwE2GQUQpsFRIsU7 XKqRASmQsyj6fwAr89Ig9LVW3uko8OLhlE9wwY1v6EIaj2t1BExP1oUbn eQO/70jax5LGwgIyVvI5nme7EqzvZUGlc7tOml7vm+H52A5b+Ka98RMOD zbKVX0ooikBCZJIqr2HI5TNr1UQQ0dZ1WCo6VxBdDuUnp+PQ5cVhJObNs w==; X-IronPort-AV: E=McAfee;i="6600,9927,10981"; a="1585110" X-IronPort-AV: E=Sophos;i="6.05,263,1701158400"; d="scan'208";a="1585110" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 02:45:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10981"; a="935035612" X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="935035612" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 02:45:00 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id A2F9B6B1; Mon, 12 Feb 2024 12:44:53 +0200 (EET) From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org Cc: "Rafael J. Wysocki" <rafael@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Adrian Hunter <adrian.hunter@intel.com>, Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>, Elena Reshetova <elena.reshetova@intel.com>, Jun Nakajima <jun.nakajima@intel.com>, Rick Edgecombe <rick.p.edgecombe@intel.com>, Tom Lendacky <thomas.lendacky@amd.com>, "Kalra, Ashish" <ashish.kalra@amd.com>, Sean Christopherson <seanjc@google.com>, "Huang, Kai" <kai.huang@intel.com>, Baoquan He <bhe@redhat.com>, kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Subject: [PATCHv7 14/16] x86/smp: Add smp_ops.stop_this_cpu() callback Date: Mon, 12 Feb 2024 12:44:46 +0200 Message-ID: <20240212104448.2589568-15-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212104448.2589568-1-kirill.shutemov@linux.intel.com> References: <20240212104448.2589568-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790700643130963274 X-GMAIL-MSGID: 1790700643130963274 |
Series |
x86/tdx: Add kexec support
|
|
Commit Message
Kirill A. Shutemov
Feb. 12, 2024, 10:44 a.m. UTC
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 <kirill.shutemov@linux.intel.com> Acked-by: Kai Huang <kai.huang@intel.com> --- arch/x86/include/asm/smp.h | 1 + arch/x86/kernel/process.c | 7 +++++++ arch/x86/kernel/reboot.c | 6 ++++++ 3 files changed, 14 insertions(+)
Comments
On Mon, Feb 12 2024 at 12:44, Kirill A. Shutemov wrote: > 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 <kirill.shutemov@linux.intel.com> > Acked-by: Kai Huang <kai.huang@intel.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
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 (;;)