From patchwork Wed Nov 15 12:00:43 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: 165314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2486544vqg; Wed, 15 Nov 2023 04:03:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGv2F0EHH54k4U3vWZP0cjxghCIzY1hpyEtD4gk5Zz/UFLXh2/Y7WPGXKFrUpOczt3ChT6 X-Received: by 2002:a17:902:8c96:b0:1cc:87a5:288 with SMTP id t22-20020a1709028c9600b001cc87a50288mr4299499plo.29.1700049797706; Wed, 15 Nov 2023 04:03:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700049797; cv=none; d=google.com; s=arc-20160816; b=uJR7xkUDTO+LRzVLM9czKYT1lrnp0nLQioxtdeTmvbniRz3sbYX6+TfS/gOn0KIW+1 /FJbHXRGUURehi9Th+ZkgqrwhWzA3xLVWTOhJj7YXLiKH2Fk6EU1FDO9e/s01UopVb7C in8hPBvve95CMfUpS1axYHiQ0nbCcvLA7hVspnvbYgGKw6YTcMry5ANp9yXClGb3Apyn U6YRxMIsvhZwTpr6XeGBSKkyosZluDtrneq3CHVwfCMYGWHDmTAHz4FlghtD7hLbV6Ke r+qh3+MIORH3PyFZJjlySVsarbmmE9LprswTyeGVFjteBMidrwKuG5iRec8pgwiFyxl5 GeQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O3FM01b+B8UNbFe3PCoJVh++lYgScc367FgI17Zcimg=; fh=OvJRnOqsMTm9XoNmEwebcqh9Ud7yh1CTeKAP84ols98=; b=CfN2eRz40nogpJETncb0SsRTWvzn51XJKAW9/zXfsA5pQKT3MTxihAYLjr3+L+SfPh ZRyOF9L4O7WhILtx2P1B+1tz7Xel2q3y1XWfhh535CJ2EKqYubsYXog01angCzYC2jje c5G7e90LwRlaRAIJw0s9HDlRn7BCLwhl55awjp2DFdA/5OxOz+GIcaIEkSosndenk2QL XsiMb/I/6R+KcDr1Eyso8j30FabphRPdaqeiEXDRCUe+EFh8ykxytp5cEgzX9H+rf5Er Wi38qxZaCc0N5nk0pprOd2xF2rvvqDQ0QwZpnzvtzsSC+ghcr5kMKP3F5Bj/cM0a9uqv CWhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BT15UUUu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id x21-20020a170902821500b001c755810f80si9496623pln.28.2023.11.15.04.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 04:03:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BT15UUUu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F2D54804E457; Wed, 15 Nov 2023 04:02:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343765AbjKOMBw (ORCPT + 28 others); Wed, 15 Nov 2023 07:01:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343746AbjKOMBb (ORCPT ); Wed, 15 Nov 2023 07:01:31 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 150D5197 for ; Wed, 15 Nov 2023 04:01:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700049688; x=1731585688; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e0MQMElB/uygXlTlVsxOA11smFUTU/lr4xfxYmKibzI=; b=BT15UUUuGStfIuVYJIhuk8rdufxhdXmDNbPi09kZE55ymyZK7AqZ12RA Xija6xgrgn6NZi6vSf3MS+n4UghKbj6ay02pr6sSBjt2FVF8qm16xaYQ+ qthPbz9w+tsQoxrrsrf3r+sms/P1GqHSB7gIpS2HuBJCJ8G2zZiIjQiV7 WuD8XAk8UGQlF+qeUQWZv67Z34NqpXNG0HXwzKBkJscUuJalPq4vfH44U mTV4J12RokArTSZK8s844VD6tz9ClsbcDoRYM1VnDf3Vkws50E+0f2yVp k+WMBQZejEVb/XMchuyPwiXx1cGssUFkNXaHUAfYw05gIZHiAFtmktqw+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="394780454" X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="394780454" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 04:01:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="13160255" Received: from mituomis-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.44.135]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 04:01:21 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id BFED710A327; Wed, 15 Nov 2023 15:01: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: [PATCHv3 13/14] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Wed, 15 Nov 2023 15:00:43 +0300 Message-ID: <20231115120044.8034-14-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231115120044.8034-1-kirill.shutemov@linux.intel.com> References: <20231115120044.8034-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 04:02:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782631417128192952 X-GMAIL-MSGID: 1782631417128192952 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 Reviewed-by: Kai Huang Reviewed-by: Kuppuswamy Sathyanarayanan --- 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 386adbb03094..5d92d12f1042 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 __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(). * @@ -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->mailbox_address = 0; + apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); return 0;