Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp793050lqs; Fri, 14 Jun 2024 06:04:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXuWE2MTm9XPUCyKwEAYMWoDUhg4doDyK8vvoO8hY2IqxqEcqWDPb1slUcg7ThR5XIzGgMuv6ceakZ76lkwtwdWiSlXYikquQZtuF12GA== X-Google-Smtp-Source: AGHT+IGjKTZ4DZ5KLIUx03fKQg8X2Saup11x+f7ThfD4nVg8VO5VfXtMEp/4GtI0Rs7x33/bM3B7 X-Received: by 2002:a17:903:2312:b0:1f7:3e19:6d9f with SMTP id d9443c01a7336-1f8626d2481mr30720675ad.19.1718370256220; Fri, 14 Jun 2024 06:04:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718370256; cv=pass; d=google.com; s=arc-20160816; b=mE4LWhznt5+9CYTXWxyUZNs0r5MpFw15A7P34qLEtGpz+GuCkZq+tnfg55fGTaCNQ0 66dmcGvhvp3OOnVz6ra9QEGYP/MPF4g4zd+TR3RuPmYTmMFyTR+5Wh12MCbSdbj1Fw2z 4pEJvK5ovQ3DLxtaJK3DE6hewaKlhxwWRuoXG/0jmggg8UdOAZbAAT8Ko3ZRSSmmQDx8 IqfsN5Dv77D1zYpNwV07oU4rRAOAsPP9igUX9lLbBi9RGG/PSFKGI+3lO52wx1X+IkDt 0BA4MZRDCrV0BHfwCQKdwzvsP98+VJP2A2+z03jGmHO8lmEKxiZSMAUDebVY6YAhCDzp 2/+A== 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=vo6BwGKMbn0aNeuG+cJ7ViO7MUjkCTvXZQ3Pnx/NPEA=; fh=jKzY+IJTxktZ685R93VhJUbGF0rvTl3iTwtLazyIugI=; b=Lcun77qfwxdOl0Lp++uHGk6cgdkU1dLnZ7CKfQ+S/gK9WsL030kuBr+hXHWMQ2U1X+ xQMkDNI6RofS13U6RdepXFjAxX27t9Cjc9JjgtaOYMqhNYmqCdL7oKEv4a2+ekjh9s60 w9HndDBT724PC1G/z3CcQ9wEvYsaGQf3jTAEX26WcbF2xGzNZb8qk/l7qQM7/X6+s2FP TwJkFtCJxszREHHp5MZki5o8Uo8St2rjvOaSUoA4dB9K3YUqi2s879hhjgAvVEsmwvYk fg5o3JU1Og5NWUBqSRPT+z11a8CGr7G0SBRNEDX4wuLxkDlJkuxqVzBtRwAJmMMPUww2 aJBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ffcO+MOM; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-214720-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214720-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f855ee4f56si34560175ad.403.2024.06.14.06.04.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 06:04:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214720-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ffcO+MOM; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-214720-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214720-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C4194B25588 for ; Fri, 14 Jun 2024 10:04:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27F7A19DF5A; Fri, 14 Jun 2024 09:59:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ffcO+MOM" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 44D3E19B580; Fri, 14 Jun 2024 09:59:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718359171; cv=none; b=RnZ2YkT+7BReNYUsQ3svRlzqNR/8jXx+CZkE1TvFjcyGGxJ4gTApAuCDRz0WKhmB13Zp7KEGVMD3pXiJHOp8nu9sID5njNdofjMqvDyEBgmAFelZWxFF2xuRWB6sxDml7hhrFhdRBvpBm5DT9kM1higpRnOMrBLiJ1uVCfSVJWc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718359171; c=relaxed/simple; bh=9vhYdxi0S8qujCAi6MDx/KbyKlcMikSIOmV4M3XKOeo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jhdEBSEXsIrzNloVwdgR6DpfPriNW/L1q9YskRJh9rg8Jpi70oMl9EXMXXv5NfQOmzJWMhi8KMSc4po7ey+0cm4YhUaanj4Yxnvjrqa+TNSy3WP3ARB65NE4WLLZWf9hKcLSMxl5P+N8r1kToarocmI4vLXicE13Ns51LzS/QSs= 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=ffcO+MOM; arc=none smtp.client-ip=192.198.163.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=1718359170; x=1749895170; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9vhYdxi0S8qujCAi6MDx/KbyKlcMikSIOmV4M3XKOeo=; b=ffcO+MOMImo1xvHOQm3p703QGVE9m/PWbMdXCKxIu4XumHE/R18Iysna E35xmKTCWzDRFpgEdzqY6jasLAazUYrZfxF//CCkBorsv7cVcX1qcoYBV Ax9sTSeXi+pt2iAzzxRTK4Rsro7xgNhYxyKyLhbyNuEBhO4kMN14Kuwd/ 9fbnxuLs05aS3GsKLejClTbnWTlkJLAbq3OmxZYt1H2gdUthjdvQtcl/L +MtYRHScUpgItnxwOJcW39Soc++2PpKiEPv3DkdfE9fen4CQx80Ovy67Y eOxySmZbStRi/V1U0F1RW7kuZ5MYpG6L4r2FZ+nqvx5tiw74rZ4j9ums8 g==; X-CSE-ConnectionGUID: CuRuUGh+Rlm15xJJQqIm4w== X-CSE-MsgGUID: QRlmPp9ETau+T9sa9k2PMQ== X-IronPort-AV: E=McAfee;i="6700,10204,11102"; a="12072456" X-IronPort-AV: E=Sophos;i="6.08,237,1712646000"; d="scan'208";a="12072456" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2024 02:59:29 -0700 X-CSE-ConnectionGUID: GSw/siUMQveJZstD2MXDHg== X-CSE-MsgGUID: /HWnI9WBSBG29VhDnobarw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,237,1712646000"; d="scan'208";a="44995897" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa004.fm.intel.com with ESMTP; 14 Jun 2024 02:59:22 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 4D5162B56; Fri, 14 Jun 2024 12:59:09 +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: [PATCHv12 16/19] x86/smp: Add smp_ops.stop_this_cpu() callback Date: Fri, 14 Jun 2024 12:59:01 +0300 Message-ID: <20240614095904.1345461-17-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240614095904.1345461-1-kirill.shutemov@linux.intel.com> References: <20240614095904.1345461-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 0c63035d8164..1b3d417cd6c4 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -832,6 +832,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 bb7a44af7efd..0e0a4cf6b5eb 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