Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2810979lqp; Mon, 25 Mar 2024 09:49:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUJRuID/007+sjuODza1/6PrB4m/XvAH8K5TLpn9HCo9+rlEMmeS8uu3U4yJ2x1hH6lL7j2PksBEYZTgMTOoQ1+1yKaV2iW7TqJovBB9A== X-Google-Smtp-Source: AGHT+IHGQ+AXxeX9349TdYocaIie8iaKrbbC17N8L+ML4+0v3yp3PDObGcdNIfcd3wZmLmnj2ce6 X-Received: by 2002:a05:6359:4106:b0:17f:4bf3:eb10 with SMTP id kh6-20020a056359410600b0017f4bf3eb10mr5463005rwc.25.1711385394098; Mon, 25 Mar 2024 09:49:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711385394; cv=pass; d=google.com; s=arc-20160816; b=eTy1CyQArMHHjfd4nR0UUH6sMUvv4uGl0gEOYwMihJL2+SOfnvk7sUzMSFBh270sBB Td070s79LsthNNBDkIgKiXuVZALe9uiGNd91f84Ot2ksHmZmb6WX5QmCG5b7T9ABZV+U tQi6L2GYQPfGSV98UR1T9WiKxwo0ZXG/3cqeNiNpqF9QMX2HuPiHN/7PtrAXE7F6Sfm/ kWoVakCFuhIB175UG17ULimMQQlzO//k7L1j9R9zwC75GubSD7P71spbj/WFCXCpzCyN +zTJGriOQ8p0/lbdVSQPEKDNBc8fpCj9LmhCC3DO/9VnFCH1qW5ycml4OQpOybT6JjaS bq5g== 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=zFRc5F0OrXPq8GXF7D+lJqxFNo2ctkgLcQtX4R4Kfdw=; fh=OvJRnOqsMTm9XoNmEwebcqh9Ud7yh1CTeKAP84ols98=; b=peCIfpjJCH6nrKXPXd3jDuKDQt+H0dVHKp5X74xkTBBiJ6XM6OKsFhqkh+NY85h3zv /z8cD5nfOOBI8qh/MNcbDfur2FQuj9rFt4yUgSucoO5Wp69dYUeDPDLLT9o5PERK68Vz 3ON0Z1xYJmTHOrmMJ1yaLgYhiieybhl6WFBbx7/P+OLvHFeuVgH1GFFd9NtsubkIMYRh 3vnHowspsZ1WEU/5eezTvb0BjgaCxmUAJqPYUoYBURBklAqzUAzNd0RTJybD+yu/twm/ Y8TZN8UuGIxxjZ7tnaCSifIEF0GT2GsgOJTi8AZ8KbOlI9rSFPPZdfvqgtnyUly5mrEB gLqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X54ZwAxi; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-116862-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116862-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 u15-20020a63470f000000b005dbd4cf445csi7733812pga.35.2024.03.25.09.49.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 09:49:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116862-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=X54ZwAxi; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-116862-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116862-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 E5C4B2E4B41 for ; Mon, 25 Mar 2024 14:29:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1EC81BF21A; Mon, 25 Mar 2024 11:25:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="X54ZwAxi" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 E15DA14D456 for ; Mon, 25 Mar 2024 10:40:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711363225; cv=none; b=gb8P/JBVNSpSh2NoLZtUyyFJIwWsN8odPJbZGoxmF/817RGvJf7HMA2ypceTFy8/QQQ1OPQGbEMQz/A++9p4IkJ7lcKbrohyqHCU1KxnQYGYygO5sYpBRSASFeFkcUutoOGliz02unBKB07/a7z70IVB6ojwzGlymgPdpziLA6Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711363225; c=relaxed/simple; bh=4OahAA5tbkCWt5kWDDzHkciJDRb/0EhPa8AF3hktH9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BPxIVm87xvzdyGDyELpK2mZvnG38fLuddmF2uKjUrBoRpinDtsb1+AxfINdvDofxk8fwzVjzy6uUvNpfcGx8TEN6zM78s9vLwmb9nZ9hsKn7O5fsxvpEGGZKJ/xjJY+L1b2SMJVoyncAXC+SuFcbrHDOAZhCly4Q3ua3HKsYWFY= 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=X54ZwAxi; arc=none smtp.client-ip=192.198.163.14 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=1711363220; x=1742899220; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4OahAA5tbkCWt5kWDDzHkciJDRb/0EhPa8AF3hktH9I=; b=X54ZwAxi2iMQ0RUgHUGbLrYDqVA0TzHe5xf5j2yQ2C7jtjRcr0lnLs+1 sDaKfqXNHBdhzYBUAvspqSrtqwixg87kp3eAl9CFqr54mDMnjWpXDXNPD BC+w1eiKHn9MhE5y1xDBXPt4FyE7SCC0xAMQTsymyXjlIReRoXIl6MGz7 9JmSoJg1Pxs1hGOSQCM/+1+86gPIq1V/W4Rmvh5MVcaz5udyKfWl/J9Mj D4/CrIrhfUuP/VdZBKu4FzrWJSxTKoEJXSHaknIEU7oWh49dcvD9VAKNo rOLLv7snKC3exv6AjD5x4giMyR4CphHhFf3l9E+4n8dJ4bzkUTAQgywFA w==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6561390" X-IronPort-AV: E=Sophos;i="6.07,152,1708416000"; d="scan'208";a="6561390" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 03:40:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="937070155" X-IronPort-AV: E=Sophos;i="6.07,152,1708416000"; d="scan'208";a="937070155" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 25 Mar 2024 03:40:11 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 97035F4F; Mon, 25 Mar 2024 12:40:05 +0200 (EET) 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" Subject: [PATCHv9 13/17] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Mon, 25 Mar 2024 12:39:07 +0200 Message-ID: <20240325103911.2651793-14-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240325103911.2651793-1-kirill.shutemov@linux.intel.com> References: <20240325103911.2651793-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 Reviewed-by: Kai Huang Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Thomas Gleixner --- 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