Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2620915lqb; Tue, 28 May 2024 05:56:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGSdc0f2M6EYOkLf7sUbQhRbiOVVTM01Ph1si+0fZWP1EhCF3xsAp0R8gx58qf+XnczzA1KtNE0jYoQ4YIRtFwQTMC/RukYwVuEqc2GQ== X-Google-Smtp-Source: AGHT+IFBn21mQCFDTljyb3E5pK0Vb4tsvYoCeRKno3pwll7wvTAfADDib8weO/Q7ZP7Bjayr501F X-Received: by 2002:a17:902:cecd:b0:1f3:266b:ea23 with SMTP id d9443c01a7336-1f4486d1f6amr134886555ad.13.1716900976748; Tue, 28 May 2024 05:56:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716900976; cv=pass; d=google.com; s=arc-20160816; b=AqC/oGkBsvwfiFjnUOubbIgEEKU25TNy+xrqrVC4TihWfcONBNCTca2vA2epvZSHzE ekM4m/L+s55Gd735gJmjHmpevHdn2rLTPRVE21tJYjodzlcvfJAuj8rX26cZHSKN+V68 3XK37o2e71OHKY3Cb4g9rOtEgE2iQz3BA7/7bG0GabUnksUmXZjejNzkSNYo3BpxQlUH 0c/y8bO5BwSvWqiv9c9k5kDwdrR1j4EcI6vt9VY6cjRUYNOEyYRpFFf0cHLkDuWje6vE 10mtd0dAUqj8ytBovQCMklVT18U3NtaddsovXIodTZcMBTC04LLh94bk3zmmiHBs2LmZ Ufdg== 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=6QHbc0siGdR5VDyDKoUVj9BcffFEenlmEldYIta4bv0=; fh=jKzY+IJTxktZ685R93VhJUbGF0rvTl3iTwtLazyIugI=; b=vBSNGCRz8lx6CepI5OTrp4m8ffQNKOf1/ZGJZVvVYVxwYRP4aMDY0nFw4MK1plJok8 IL8CrMFhQ1VoB6sDzsnvl2bIccBZri0HdcMi36I9ZymDE6Gk7CIS0+JWMYwGATc3QMGP m16iG5rmWo0NDYbKpc5w4PpEIQEz4lf21zsb6gPavhdaQICFujYF7Csj7iWAqZwvMyOl ahXGb/qblB8voIYZVQCnsI06xNk3CVcZYL7NpBlhz6Zm6m+tSe98uUlk0zbfl5z/Y79t VRuBu8c3vrm/W9woJCX1okqObUue47Q6CFqY+qxYFEh2qguqoQ3nqP0ZoxmyT2xvnsxv 2MMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kOWb9H92; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-192049-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192049-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. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c9aa1e6si77253935ad.427.2024.05.28.05.56.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 05:56:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192049-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kOWb9H92; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-192049-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192049-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 62D58287B65 for ; Tue, 28 May 2024 09:58:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5215416DEA8; Tue, 28 May 2024 09:55:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kOWb9H92" 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 E33B616D9B3; Tue, 28 May 2024 09:55:53 +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=1716890155; cv=none; b=BrRagzGb7CZZeRS/Nf4J6c29+McT81xYSzwmW7YGaZfmx1x/UvwY47iT3MhLI4kEInX0sii3j+RdGMMe3zemnk4xkahCgvSl5lnZA06q/Hu58Z9bgHmUxO3bOpVPlo85tMz9QzPp/gF8c5Pia5bKTgqiFwoCZeq8DRsmjKQh7n0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716890155; c=relaxed/simple; bh=20gmqRJLZ1DrMXHP1I23O7bcTlns6n1UTqdinHS1U3c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P+hJ1JMt+WwuRyhGuJI3va5JnTgYVkiVNKtYPkUJESUQI3S+a9Eb8BM0UfT/0ssV8KHSYbKSeDfM7Xb7TkEnKl+GDYDFewqEUw1jStt93Wy72wvYyXjf3peyyJQ+wRD4C9R4bJo3TMg3UPPogpvdUVmIOOlYrS1OrZNzrLN72wQ= 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=kOWb9H92; 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=1716890154; x=1748426154; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=20gmqRJLZ1DrMXHP1I23O7bcTlns6n1UTqdinHS1U3c=; b=kOWb9H92jHYQBemG6pD2YIWZSIhcF59mtIfqgIu0cAiA57R6HqYoDN9q KpSzl6MfZGNV8qqCfqSAYC+tJ5NaqFfhuvAa7Ww4dHsp/0NjSc7KzNjGQ diMR/tvvLJ/taLAq3QM2qy4Km1C0mBs3NY7n6dxSsstgfejyiGRWB7MJs ZJn2CtaJXjOMS8uLtfZEpnv0dLKoOcBa8VlrH/IpOPDRDBfNIGijct2Cs SjEgsGNvkGERS3Ev4hLSOvyp8hMvUML47x9sJR5zbHvMD3Q2P20lwbndI e2iunDFvpOBJP945HI9N/X9j1ERxBWgyoBUR0Cun5pHcrEkpHV3z9pqYi g==; X-CSE-ConnectionGUID: k3Iby6kFQVmV8EF0uJZODg== X-CSE-MsgGUID: zfWQXM42TAuZGHwLhitIdg== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13097821" X-IronPort-AV: E=Sophos;i="6.08,194,1712646000"; d="scan'208";a="13097821" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 02:55:47 -0700 X-CSE-ConnectionGUID: DN595e/5TnyhTE3kO5c0KA== X-CSE-MsgGUID: nqm/7/BSQo2t1bnUcgj8+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,194,1712646000"; d="scan'208";a="34951820" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 02:55:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 18C18A56; Tue, 28 May 2024 12:55:27 +0300 (EEST) 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" , Ard Biesheuvel , Baoquan He , "H. Peter Anvin" , "Kirill A. Shutemov" , "K. Y. Srinivasan" , Haiyang Zhang , kexec@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-acpi@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Tao Liu Subject: [PATCHv11 16/19] x86/smp: Add smp_ops.stop_this_cpu() callback Date: Tue, 28 May 2024 12:55:19 +0300 Message-ID: <20240528095522.509667-17-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240528095522.509667-1-kirill.shutemov@linux.intel.com> References: <20240528095522.509667-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 Tested-by: Tao Liu --- 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 a35936b512fe..ca073f40698f 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -35,6 +35,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 b8441147eb5e..f63f8fd00a91 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 097313147ad3..513809b5b27c 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