Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp856705lqs; Fri, 14 Jun 2024 07:38:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXgoFnoNGhTgAwDu46bmzd+pHrY/7eHVV5Hgg2Dlamr2Ro9uJAwCl63Gb84FcRQTQXsYo5QRLjUICHZjaPhkw0iNkLKmZ1H7ZR7WjBvg== X-Google-Smtp-Source: AGHT+IFKedhA2wixdmhRWU7fhBcHucc4Pd49d+MfB77oC8b30uJ8ZJDtw6SgNC0jdwuZ78xIKoBY X-Received: by 2002:a17:907:c80a:b0:a6f:6cde:150a with SMTP id a640c23a62f3a-a6f6cde16bdmr54432966b.15.1718375905016; Fri, 14 Jun 2024 07:38:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718375905; cv=pass; d=google.com; s=arc-20160816; b=OITDubYo4sHXelCK1UXj8A17A7Ngtu7pbxIfgL2TvyzjarByrlGDva2WutGr6heY/e kWkEKEgjbqC+O/KWB47VUoS2CI9zURlT3qZ0Xt5+5INvCAc6EnDYdG15xLEuX3baNPIo 2BBzopxg8ezuWHt68b474uEkygE0E0c4ezGsDl2lIDkNuPqdmZbkhQvlZZbvMJks4cYC xN41EQUdOjjmL+I8yK1cxWNyTgzdcaj5HAvqAuIpjj88n5qFhwzxCHnRrcSbMDPL+/yY v3ZysBleMkH3i/ElLJJdubb0J5uzURMXY6Ma+azdgjCHpds+bYu042wmsgRf4BYmJGZA jhYg== 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=EtqVmmsYkd1LotCTIPGg9/hSZjFv7lTHMJPnyI28GCE=; fh=cPmJNda8c601wC/77Nyp+sUEZAven/FLIGVJKzRwPVw=; b=ej5oN7JmeWtkoGLxV9UBnWgS5pwaPgBSeNhA20LE6V9F3y6rb2dmZFAsvVc7l4xEtu mGEFWbW98AeVT6UZ+xpT/sGo6FWLYWaNaMLCZsxlQal+KJwMeC+AO5wb0PLbljMwAx34 sH7Mqlji2cjPuAoR3Zhp3LNCs47CT7/zoPR/RgFa1iWJyat89X1GGXtlS0p+B/ywAjLT 9AueZUCLWPNivwClznty0vqgNAD6zd/YHDtbsCw4+w7R24+K8OgOaOfe+8r6nZCr/oA/ lpu815HiRkeEfrQ238TUwcjyoqryQDwpq7zPiYtpO7bVA2qfDZBp80D7U3Uy8JKiPHBb 4ZIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mpg9QuT0; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-214719-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214719-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. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56e3b456si184618366b.878.2024.06.14.07.38.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 07:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214719-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mpg9QuT0; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-214719-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214719-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 CE86E1F29665 for ; Fri, 14 Jun 2024 10:04:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9935119DF40; Fri, 14 Jun 2024 09:59:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mpg9QuT0" 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 E278C19ADBB; Fri, 14 Jun 2024 09:59:28 +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=1718359170; cv=none; b=uEdh8vgs7g5M4RGcPOonjfwZO4vbIrmgTPxVryk3nR5jJWexFyis+5QDnwGayhia4dE/5Bh0rrm5xydT/6xqzY/5EU1X2EeCcwPXnTWRigl3EO7HUJxHg/Dy/x2l1xRdshDt4PfPLNp22IOY7oyDw29qZcZujBz7/HA0HzYPQp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718359170; c=relaxed/simple; bh=gHUMnjM2TCXHR+vN3P0gWuptlZ7xjQP3Laf7K7sjiXM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ai+t0On9aAGLxscLjb8PKwzClsslFAoRGGkyNSlBWE+724+ZI2b3sDK+oo5MX5KeBZeFDNnyNP9CooXKsnqIarUr89lS6gt4qXPGWOUiacTstKTm+teGWfNaa9RUtoTMYT7kQ1bU1kc8DpAp3iTVJWfx5DviAluuYtVpn2O8SF4= 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=mpg9QuT0; 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=1718359169; x=1749895169; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gHUMnjM2TCXHR+vN3P0gWuptlZ7xjQP3Laf7K7sjiXM=; b=mpg9QuT0ZolBpGlUrdABSmgDdQuxPOYD1Xg+Sv46Umg+CMwLU62KOXPD LA1zXgSjKFNAy4J+NIZ6GEWJ3Od6s4V99UThP09jDNKhc/GA+ETf8UZ/l qNEb+bAGLhESsh25KsGC4Shd2N/Jy/mF+ZtzGhTWSrx6gfIbUCeOr7SVm wjiKHV+67Pq/0VYHy9SHPldq+kEz1pwuCGfhPWZSan+oORXH9WhAwKduT /4z21Iojl4PMiZ+MRX9/QbhoaQGrEzy8MMGzoN2b3XSAnFDKPd3gOCmal sbrYWtZxCXPr88qArJJj92YoSbFQQg6SP8wV3/+35x+hMy9o0eV60Ze5Q g==; X-CSE-ConnectionGUID: 5j0cmKVHTkOKeLJFEnl+xA== X-CSE-MsgGUID: KbuY6i9qS0amxA7RWmwp/A== X-IronPort-AV: E=McAfee;i="6700,10204,11102"; a="12072439" X-IronPort-AV: E=Sophos;i="6.08,237,1712646000"; d="scan'208";a="12072439" 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: EYW92s2DTg6d+fgPpKE+Bg== X-CSE-MsgGUID: X7DP7moDTSOxlFZIh/FCYA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,237,1712646000"; d="scan'208";a="44995895" 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 42D202B54; 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, "Rafael J . Wysocki" , Tao Liu Subject: [PATCHv12 15/19] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Fri, 14 Jun 2024 12:59:00 +0300 Message-ID: <20240614095904.1345461-16-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 ACPI MADT doesn't allow to offline a CPU after it was onlined. This limits kexec: the second kernel won't be able to use more than one CPU. To prevent a kexec kernel from onlining secondary CPUs invalidate the mailbox address in the ACPI MADT wakeup structure which prevents a kexec kernel to use it. This is safe as the booting kernel has the mailbox address cached already and acpi_wakeup_cpu() uses the cached value to bring up the secondary CPUs. Note: This is a Linux specific convention and not covered by the ACPI specification. Signed-off-by: Kirill A. Shutemov Acked-by: Rafael J. Wysocki Reviewed-by: Kai Huang Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Thomas Gleixner Tested-by: Tao Liu --- arch/x86/kernel/acpi/madt_wakeup.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b/arch/x86/kernel/acpi/madt_wakeup.c index 004801b9b151..30820f9de5af 100644 --- a/arch/x86/kernel/acpi/madt_wakeup.c +++ b/arch/x86/kernel/acpi/madt_wakeup.c @@ -14,6 +14,11 @@ static struct acpi_madt_multiproc_wakeup_mailbox *acpi_mp_wake_mailbox __ro_afte static int acpi_wakeup_cpu(u32 apicid, unsigned long start_ip) { + if (!acpi_mp_wake_mailbox_paddr) { + pr_warn_once("No MADT mailbox: cannot bringup secondary CPUs. Booting with kexec?\n"); + return -EOPNOTSUPP; + } + /* * Remap mailbox memory only for the first call to acpi_wakeup_cpu(). * @@ -64,6 +69,28 @@ static int acpi_wakeup_cpu(u32 apicid, unsigned long start_ip) return 0; } +static void acpi_mp_disable_offlining(struct acpi_madt_multiproc_wakeup *mp_wake) +{ + cpu_hotplug_disable_offlining(); + + /* + * ACPI MADT doesn't allow to offline a CPU after it was onlined. This + * limits kexec: the second kernel won't be able to use more than one CPU. + * + * To prevent a kexec kernel from onlining secondary CPUs invalidate the + * mailbox address in the ACPI MADT wakeup structure which prevents a + * kexec kernel to use it. + * + * This is safe as the booting kernel has the mailbox address cached + * already and acpi_wakeup_cpu() uses the cached value to bring up the + * secondary CPUs. + * + * Note: This is a Linux specific convention and not covered by the + * ACPI specification. + */ + mp_wake->mailbox_address = 0; +} + int __init acpi_parse_mp_wake(union acpi_subtable_headers *header, const unsigned long end) { @@ -77,7 +104,7 @@ int __init acpi_parse_mp_wake(union acpi_subtable_headers *header, acpi_mp_wake_mailbox_paddr = mp_wake->mailbox_address; - cpu_hotplug_disable_offlining(); + acpi_mp_disable_offlining(mp_wake); apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); -- 2.43.0