From patchwork Fri Dec 22 23:52:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 182823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1395819dyi; Fri, 22 Dec 2023 15:58:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHF1uZjo5PgIJWqI7lOErPfzQE4jaHQL4vULTGtLQv4TK2oubbr0rRQIX0lfTm27B6S8z3I X-Received: by 2002:a05:6a00:80c:b0:6d9:65dc:f591 with SMTP id m12-20020a056a00080c00b006d965dcf591mr2006249pfk.6.1703289520520; Fri, 22 Dec 2023 15:58:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703289520; cv=none; d=google.com; s=arc-20160816; b=cQAHeOBJo8xJeuwjwD7G3WiGzMTIBt3BiiGTVkgaN6GZO5mVtjbTN1MHuNVkqk3o4W JIzZNT1j6ff/UhP+ePukY9LRpvucFHwpQ/eEOQYTs3uxBrZ/DVyetZgkeG8mWHb13m6y ZLCPJ18Ad4d/1/X15FvzLl1+egsmZsg1HPF8QCQ3vKNx2X+au3dtr7+uX6bVITU12Pb3 dghaXh2AgL0v/LFKfDzwL1bj5LyJ9aX4MbRUDzmWInD+BIdQ8HSCCrz7ggjJNchF88o2 A03/hL/aBtTeWUhamoRVvBMvfFDimvzu1MFN544njpyyFEcfTlNfU3mst5qKtnbfRtw0 JFPg== ARC-Message-Signature: i=1; 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=V999tJw0xnhNLWgVqs0ctQODpqgYerLgkk4FVHL2O68=; fh=OvJRnOqsMTm9XoNmEwebcqh9Ud7yh1CTeKAP84ols98=; b=kqTMg/RDsdUvOBPdXGN+UvpaWoLIiC0G3uM6a74HtPnG96CLcobGjR3GGdYPytizfP 034eRVfCviucPBRXpnOnYQePHAISm0Xxz7k0OV4/UEPoyAcELQJhu2PyVkbVfGf6Ca+R ulNzEzKcEkP1AH+GGPKqF+Lsg5iZhJLsDqLHhmYP35oLQmfgeVKHJnB7qdw0T8Fa70Ak aK4LeVCv1WINFWnByUaKTgnHNftpD0EN9er/MpS+XhRpu4VUt8AIQak8GUAmy3vmqOUW H/8b1a9eWUfTWEMWclDevtdHi2pS4+EfxW1CRfAjePI7OSGF9zEuhGNHYEKtxdwfgQ8b dCCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ZGY/77xH"; spf=pass (google.com: domain of linux-kernel+bounces-10140-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10140-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id c10-20020aa78c0a000000b006d98d12490esi1472913pfd.350.2023.12.22.15.58.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 15:58:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10140-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ZGY/77xH"; spf=pass (google.com: domain of linux-kernel+bounces-10140-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10140-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 142AEB223A4 for ; Fri, 22 Dec 2023 23:56:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF2AB4CB58; Fri, 22 Dec 2023 23:52:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZGY/77xH" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 EA0FF487BA for ; Fri, 22 Dec 2023 23:52:31 +0000 (UTC) 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.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703289151; x=1734825151; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YDQMXN0iVpU2YQf4aT9bqVrRqYEHM1UhuZnW8RhMhQ0=; b=ZGY/77xHyIgun13RT30RPGI6THMYQLMRaOla0YHlYDZop27HqK6Fm+zV 1chnGzYFUly2/LpR0WTfwmDJYoBXdh9KrMXZfY5dK904bVTGPTIEmqLMw 0idEyjXuEFDU0sA8d9G8eRqJdQU7Uoer8Sn+DuX2z3U+BwxgA0jwBeh6V TwbcmDYBOhsWGmz17mBKFARvVbsOKF/qIGl/lqND6bv+ljHPaMY03YVBg PaJ7AL8rXsNbNMogSDq9f63WrV8Ck9P1Fmnr3oA3NdXrqWu7ZH2GdifvB X2QNvWgf82VvMbsovH7PYXFp1VFgVtsOpT8CB5azxZMlncHgED0RtOSX2 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10932"; a="395063340" X-IronPort-AV: E=Sophos;i="6.04,297,1695711600"; d="scan'208";a="395063340" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2023 15:52:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10932"; a="900623013" X-IronPort-AV: E=Sophos;i="6.04,297,1695711600"; d="scan'208";a="900623013" Received: from jeroenke-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.35.180]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2023 15:52:22 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id 5EFCC10A4DF; Sat, 23 Dec 2023 02:52:12 +0300 (+03) 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: [PATCHv5 13/16] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Sat, 23 Dec 2023 02:52:05 +0300 Message-ID: <20231222235209.32143-14-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231222235209.32143-1-kirill.shutemov@linux.intel.com> References: <20231222235209.32143-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: 1786028511914046906 X-GMAIL-MSGID: 1786028511914046906 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 --- 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);