From patchwork Tue Feb 27 21:24:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 207551 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3050778dyb; Tue, 27 Feb 2024 16:31:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVrPVJULybzdPWtk6xLeuItUPI9vQMhiy4gk4B9gmxXLg2lzZwRQ66jbi9vP7NqktvCZoNkUdAOc/ZS3CsUC2cGZxByPw== X-Google-Smtp-Source: AGHT+IH3uYzJgGOC1WvIe3Ae28A44oTCxZKYHp37vl5yr2da85jz2MIH5BlqvAa25kzLcL3CiZzO X-Received: by 2002:a05:622a:1aa7:b0:42e:7e3d:747f with SMTP id s39-20020a05622a1aa700b0042e7e3d747fmr10978400qtc.16.1709080261605; Tue, 27 Feb 2024 16:31:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709080261; cv=pass; d=google.com; s=arc-20160816; b=tYfu/qfrE/r2B/nj8qV4PFE+8gq7rwRhauS8fatPUmTHjxEsAkiOZmej904K+g5u0i 14cNft/aKHYZEyjSIa979R0pfYdyQ2GUUfx5BYe4ACB2nZsynSzTjIdXHa3lNNkADSaK U8gyFsXZlXCbsW7c9Bgns8uYhzHAUc8weXMcIvLbmCpAD6oY2W7J6RejRnk5Fj/dzHvW Pl4Tor2pCHL1k2dGyjBOz3jPMwuMRmVlLvaTfsECOJ72+6tYg820mC6MnAWAlrBxHr2K 3KMrxpAt6Ci4lj7p/CmElPsRTXWdctzUKMC2nuB2fSBPFw7oC4lFaAhZoff+8S2kG8Sv y6rQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84042-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c11-20020ac86e8b000000b0042e770d48dfsi8170756qtv.35.2024.02.27.16.31.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 16:31:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84042-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84042-ouuuleilei=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 3F0231C278F6 for ; Tue, 27 Feb 2024 21:28:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1ED6115AAA6; Tue, 27 Feb 2024 21:25:21 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792100544213497794 X-GMAIL-MSGID: 1792100544213497794 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);