From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C4F2C19F5C for ; Fri, 20 Oct 2023 15:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JjZl4POSbZoSJ2Qb/Al8OUFDJCQ0lUGnnQirCdlXilI=; b=4zUfqFbyR5wCwR DThkvp7LXLXz+iY0pNgxhc6gUwQOw8BSTMy1xetdIpLJvGGJZcoanWUYaAS2+G9bdTZL6/RyvR7Kb IClB2Zr+HEXNP6ZPQC2jfs1dfpSJ3fvv2Gle/aCc6TlJCvPa17YTsWAb3GzBFvDcJv0SbkJfVMbL0 c9azNIHtA3pjfR/jQb6ZEP6tIE5h5Znz4ojoJXKuSanWRlp9zNUs9vbKDw5G7Dxdjc096+vRPYdWA 5FIvfo7B73sag9/mbjDA01liZMgrJ1d+zXfezPPCy6e7DP8vK0Jd1GNOloxd2+r9u5KkAhmcYRJJZ X5mKjB4ypOv1cqhuvANA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qtrBY-002Zn9-3A; Fri, 20 Oct 2023 15:13:12 +0000 Received: from mgamail.intel.com ([134.134.136.20]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qtrBT-002Zcr-2E for kexec@lists.infradead.org; Fri, 20 Oct 2023 15:13:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697814787; x=1729350787; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OLVOdxFnd1PuTcNaoWBVdKJvyZnZKOsxD6fGknmiUv0=; b=ajXNHoBo5LBzh4d3eYr/FCGxrVmoQMGRiF6K7gkZ9g/PH/ys8nCShgTB xRZBR4xsCt6mWVPIkByQJFhz2j8A1RQOthsJv4U5+uqx+3E37hD57Ie3p Wk/IvNSWX9dw5JXpwGdXTteKTUvRWAz2Ofnyi7sR9dnu412RdN2H+ZX5X YOWd2DkL8lPXSOihdH/Fg/fyIl9B4gu9vOeOrlnuNYotYgrTpRgpskPVx d67F6/j4+v67Txok6ctKElfUnp+53OD9JA4XsGytz/caPV0pBvcsQaLLX xGWQkRGH/jMGhBuT6mA/ERs+q8n0KlszbtdUS3BNCP8KDITUmTBt/gXG2 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="376893681" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="376893681" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 08:13:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="761080288" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="761080288" Received: from dgutows1-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.39.237]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 08:12:56 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 5C61110A29D; Fri, 20 Oct 2023 18:12:45 +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: [PATCHv2 11/13] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Fri, 20 Oct 2023 18:12:40 +0300 Message-ID: <20231020151242.1814-12-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231020151242.1814-1-kirill.shutemov@linux.intel.com> References: <20231020151242.1814-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231020_081307_906218_846D7345 X-CRM114-Status: GOOD ( 16.84 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org ACPI MADT doesn't allow to offline CPU after it got woke up. It limits kexec: the second kernel won't be able to use more than one CPU. Now acpi_mp_wake_mailbox_paddr already has the mailbox address. The acpi_wakeup_cpu() will use it to bring up secondary cpus. Zero out mailbox address in the ACPI MADT wakeup structure to indicate that the mailbox is not usable. This prevents the kexec()-ed kernel from reading a vaild mailbox, which in turn makes the kexec()-ed kernel only be able to use the boot CPU. This is Linux-specific protocol and not reflected in ACPI spec. Booting the second kernel with signle CPU is enough to cover the most common case for kexec -- kdump. Signed-off-by: Kirill A. Shutemov --- arch/x86/kernel/acpi/madt_wakeup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b/arch/x86/kernel/acpi/madt_wakeup.c index 4bc1d5106afd..9bbe829737e7 100644 --- a/arch/x86/kernel/acpi/madt_wakeup.c +++ b/arch/x86/kernel/acpi/madt_wakeup.c @@ -13,6 +13,11 @@ static struct acpi_madt_multiproc_wakeup_mailbox *acpi_mp_wake_mailbox; static int acpi_wakeup_cpu(int 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(). * @@ -78,6 +83,23 @@ int __init acpi_parse_mp_wake(union acpi_subtable_headers *header, cpu_hotplug_disable_offlining(); + /* + * ACPI MADT doesn't allow to offline CPU after it got woke up. + * It limits kexec: the second kernel won't be able to use more than + * one CPU. + * + * Now acpi_mp_wake_mailbox_paddr already has the mailbox address. + * The acpi_wakeup_cpu() will use it to bring up secondary cpus. + * + * Zero out mailbox address in the ACPI MADT wakeup structure to + * indicate that the mailbox is not usable. This prevents the + * kexec()-ed kernel from reading a vaild mailbox, which in turn + * makes the kexec()-ed kernel only be able to use the boot CPU. + * + * This is Linux-specific protocol and not reflected in ACPI spec. + */ + mp_wake->base_address = 0; + apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); return 0; -- 2.41.0 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec