Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2206765rbb; Tue, 27 Feb 2024 14:25:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVlh90/RtflVvasVzKOb1M9p8grKgYVLvPisfd4xu/tmQsvr1LeQgJgNIC+ZZY+6FUN4Bh6jmD95Vn1Jc6ou1XBGSFvXIqIxKeDgSWIQg== X-Google-Smtp-Source: AGHT+IFAZpVrMe/H0j0SDSkp8Y1k99HUm0Rk4YWmQjhOnohqwGClGoqyygdxQzr/uV5Cm18yRKU/ X-Received: by 2002:a05:6358:5e8a:b0:17b:56ad:6b14 with SMTP id z10-20020a0563585e8a00b0017b56ad6b14mr8870062rwn.2.1709072727110; Tue, 27 Feb 2024 14:25:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709072727; cv=pass; d=google.com; s=arc-20160816; b=K4AYssVWgXgKWqwvl+/zkxGLmU0FPZoeKUy+o3cHf1X+miRKsHZngLZ289zNr+t/FJ Tk1fHfjN9n9a8wNkxpw9yyi5AIj4yT68m9PuBE2jOxsMoJ0FmXvp1HDgBRwjzWVQaHFD ZvQW1llJ1wl/Kish1P1A40kF5sRhkJQ24DPXysURsRRCPZ3/nrfOpsU3jg+CWh4qfkvA fGLhQmKifbq/t6lt/Q0dYk8wU4zUk5JjIEU/HtOVxHNXhAj6TtTaZBl6MDQVbgw3CH6S o6V/quZV+NRrVsEEziYG0asSthdwE7TrILom12ziVfXZl2pkAbjs3cwp0zR9yPousGDC WRLQ== 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=xEQ854SfIMEtqFquVnQKsBS0FLMPy6m9rDqQWL/n/gmd35cgRpLi1UBvCOyr5zcJR4 uGBa0yRSg/9lH9OSx8jO9OSETJz6GexwbcmjCefo6WW36nW/0vTtrfA1D001qEwVMBwi suIAgapNITvas1OoZbkFmDSi2r4QHglPDiGX7AuJnjBL+anyd79pPHmzVAXeddOuvviy I8i81YMBIU6IqCrcaU1hDxbRCctct4KLFbH1NlObGUozP6bs1FPqbA71QzCL4bhBcAwH 3S8lDSaEp52sjm9Gc6rPMsYcjidid7VAgoNcbrr04BloQ8YX1nCef+w0bEcwGNB9Ik5a WPEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YaeI+QjV; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84042-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84042-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gg2-20020a056214252200b0068ed85b0d64si8476443qvb.381.2024.02.27.14.25.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 14:25:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84042-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YaeI+QjV; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84042-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84042-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 06AE21C2767A for ; Tue, 27 Feb 2024 21:27:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A992C159590; Tue, 27 Feb 2024 21:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YaeI+QjV" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 78F54158D99 for ; Tue, 27 Feb 2024 21:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709069117; cv=none; b=MNYeErTxQ8ff1AQHsIghf1qGikJXZyST5nsqB3KGV9cLJ7YaUo2rlBkI86CX7lJ8QJ219oo5ty+iW565Y4dmmKNfNX6HLad9AYStqUaAl+hXdpNVVUz6AbB3PBQfLJKyDy5Oey3QQ+xQ4nlI9ngWGoRoxd8T9sklAfN1XSolt/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709069117; c=relaxed/simple; bh=4OahAA5tbkCWt5kWDDzHkciJDRb/0EhPa8AF3hktH9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NpTeHu+PK4Hd7AFPKumM/bdK0qAk62tCa/k3PpGkS5H5oAj3UY+vEW5tgEVKdsWv6itSctDv7aVdS6c7Htr97nASgaKiqS+5IIeMrRAZAprEcmPlf783Km5uFcokc1/qNG+hkPUlHPWB5ZMXmX0ejp6vQDLUdQgLbCAdSgK2+l8= 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=YaeI+QjV; arc=none smtp.client-ip=198.175.65.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=1709069117; x=1740605117; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4OahAA5tbkCWt5kWDDzHkciJDRb/0EhPa8AF3hktH9I=; b=YaeI+QjVzbuMKqzfJYi/0W4Ha0jhhlnDENaJBftPVVOL9G0CmCG/3GsB kjaM+zZNQiEzhttFeSllo1youkNJD0P/DvJNLz/ZZ7SX21kUOW5sNP5IY bC8ViRO/Kx8+LhbY+KQmc8IB4O+CjKwTgKDN2qzGRgPqGpZDEswsbxmA8 95H/blNxGXsCUtElOnl4JB7v9kCwXk8oTdtv012/fkkdAGJub05XiQALf Z1ZOV9ZYw79KLbt+f7u+y0eaEO7xay70qdGBTB6/KgRFiZBxRZ9wAdW7C loRGwy5oBmPI19+WmLehw/CSMffkewl8BJCl8bvUwkI5BnE09tvTKENw1 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="3567067" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="3567067" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 13:25:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="937032918" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="937032918" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 27 Feb 2024 13:25:02 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 90B3BF27; Tue, 27 Feb 2024 23:24:56 +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: [PATCHv8 13/17] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Tue, 27 Feb 2024 23:24:48 +0200 Message-ID: <20240227212452.3228893-14-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227212452.3228893-1-kirill.shutemov@linux.intel.com> References: <20240227212452.3228893-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