Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2142396lqe; Tue, 9 Apr 2024 10:36:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX/4o6uHurWgUcFzA+djpv/TiPmqM5LJuCSLzkc9h+7W+KsjH50+JSrXvmCLhvGzO3VifyP9O194u6kQV+OvZ7cGJXWH/p+qchaAu4PWg== X-Google-Smtp-Source: AGHT+IGBpFdBK6Nd42v40LIzhv45oJNmN7H+49rXxllS1153oaD26k7TcMgrByDUYXNBLJHrT0Ot X-Received: by 2002:a05:6870:1804:b0:22e:d572:271b with SMTP id t4-20020a056870180400b0022ed572271bmr194146oaf.58.1712684199141; Tue, 09 Apr 2024 10:36:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712684199; cv=pass; d=google.com; s=arc-20160816; b=jXCBV7B7miULfur7ZhQk1R0UEoqGm9FBjwITFTWqsR/cUgsE92ALyyK79bMqijJDxH 7GiseKp75NQA+XASI6TSg4cWmkHdDnoaCad+llmLXdrm8neXD0bK5Fi445w4r0+0DzHU STug5puPATEO+QZVUatbZdKX5deAl4ixu+IEFBfSp4VwvutiazW5948miAM6My9JDQd+ ABzP3L23kGAc9D9ZOJzUM3D4ay2GS7OOu9JkKD8LeNO2NlGWKBmIVdr003Rma7Up11/u LtfYG19L2P6CTZ4Qrz3kJD4YkEWlpQybsx85OxKgAsIPsKChpHclDHwUW9wJxYlrRlVY vPnQ== 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=PeswkiroEvlBr5X3yZkDg3yfLuRYvUt0IrEg7GBUEEk=; fh=Yw2S7s1ZcF7+jfnU9Zy13ghDfPt/cQWqfRpyK6FQAJQ=; b=xWxuIU5pPFGha9cOOMDLuhof7l2CrQcvxqUNx/Da41YVntI+w0B2DxqDBzEtCQ2wNZ 1LAlseUEkhTdZprzfUv8zxlxkUa9g/Say3qszUqgNzidBZd/RS1fppVp4E8s+FBF9Ou/ d2EX0qQRHUxP8AanS42zT9sz22rgyH4jh1N1HtMY3rZpRY9PJ1XH5UTiCaJtk5qOBj7v n/5YuA9X+fZYs+IBilScfn4llae8aRmw3mSd1ToqxCNKpY2pJKS0kZNh1EUHbN48syfd LdnAFK/qoR+OuaXoPcuX/AGLv5RGzu3LUrE6ol0alb22TbDb1FC+NlzscM3Ncnx73oai 3wkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TiXzvowx; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-136762-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136762-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 p2-20020a639502000000b005f3e5edcbdasi9047700pgd.368.2024.04.09.10.36.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 10:36:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136762-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=TiXzvowx; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-136762-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136762-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 64D8F28830D for ; Tue, 9 Apr 2024 11:33:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA71913049F; Tue, 9 Apr 2024 11:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TiXzvowx" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 DF22C12F586 for ; Tue, 9 Apr 2024 11:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662236; cv=none; b=UX7sOEWwI4ODxbZi7JQgOC52Q32fv2ghKK3W2b+sCe5PuvJ3KFmgA9Qi25d9XJbXjd4LwXrhO4bmFVpOsakf81t8U/xypzv60l8w4B1N3JoxdOxd/azdWRlTULp9WEi8iMA6//KKhBcCtn9rbvRij0EzF4R0XHb0RGJv9cRORJQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662236; c=relaxed/simple; bh=H/0XoETYjiBwKYOVVwyFe+gG1mMRMbLkWrG5a87I6pg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pSqi0tjITCMosNhNfEDnFujCCJa0EGBj9inXcxDPN9SmCtU3qlKR77RpyUcrSUcXTDbS5VF/HAqqm96Nf+sautVy9Bb6jGMQR/XVaMimDnNpqbsljPRwV4htnAPJT3OYWmvZ6PDSWNAQ0gSHgGQV0fuDy7aRIZe0vQNcJ5PKOFA= 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=TiXzvowx; arc=none smtp.client-ip=198.175.65.9 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=1712662235; x=1744198235; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=H/0XoETYjiBwKYOVVwyFe+gG1mMRMbLkWrG5a87I6pg=; b=TiXzvowxLtWe3x1LScse8D0NTCRHoMSUr9gQW0OYyEJV5kGgZ1GrFPU3 +rzpTdmi18E9NCOohbdk4ISh3yiHUjICwgm9vpzIBB1Tntfvip21rzK/Z Qtotk2R1sdzkL7jZ20Wz5EhAH39S2lkq87SkYWpVkSU6Q8ztVnLP0TR3f sBxFTyhcTulKYgRfx5G53NxKP0HCVM60PBs29YehoKi7SsTrt2IjIdKlr Nx54fndsDYePJRM20dmF24JF6s9dG1u33hP4FY3GHdq1Ap4VER+8KKAqA 9N18lsVfclBFQJIPcCf21IcVpxqcFYaJgrQYDTns73ikbIGvKFDg8l1tn Q==; X-CSE-ConnectionGUID: U+sUfOG9Rzm+PJ998NmoMg== X-CSE-MsgGUID: dlVko5BvSbKA+gl7rGeAOg== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="30460461" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="30460461" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 04:30:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="937093351" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093351" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 04:30:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 3D2FA1090; Tue, 9 Apr 2024 14:30:18 +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" , Baoquan He , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Tao Liu Subject: [PATCHv10 15/18] x86/smp: Add smp_ops.stop_this_cpu() callback Date: Tue, 9 Apr 2024 14:30:07 +0300 Message-ID: <20240409113010.465412-16-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240409113010.465412-1-kirill.shutemov@linux.intel.com> References: <20240409113010.465412-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 1ec478f40963..293ded05a4b0 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