Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp3081066rdb; Mon, 4 Dec 2023 16:46:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIc4MiWft1ThSySduEfDjyOqbbDAHWSNOFF+nTEms04OnYKOUmQQG6vlMDlX96k9HsP11m X-Received: by 2002:a05:6a20:9f48:b0:18f:97c:3860 with SMTP id ml8-20020a056a209f4800b0018f097c3860mr748442pzb.58.1701737213532; Mon, 04 Dec 2023 16:46:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701737213; cv=none; d=google.com; s=arc-20160816; b=ph50DH0u+9aTkrbxj81RdmXO+XXsh0LJaBg3dtbnQgWMZWMlzJJCR6dyP3KvXWFyDI 1Ms6eRXpVrKRCgv51mXye4jLFT1/mLCMphQjtjuMn4LjchY0PlL2nY0cKYVwITDZcHeR 8zBu8xUQd6J951b3HGIchShxOQ76qmJ+7Y11Swe946dSLU2Mx/jHzh/Q7OoljCGbDChz QaDBgNiWZSZ/FyFkcPgVdt84rgwjnWFTbVYs75U3Q90K7tlPQZ+XX3M6cfqzQrOinfkX D0jI0i7iRsaQpXfh1Y+s/nqIXf4Fq02QSVBiWZbt1XT2wvWpLftMpFbScl6nIz/cIsne ufMA== 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=2QApud+Si4fBkF6IRq5Uf9OvVaHBPaEKNYV+SCrlMVg=; fh=OvJRnOqsMTm9XoNmEwebcqh9Ud7yh1CTeKAP84ols98=; b=pgt9OMGrylUYO9zvy6nvbPTAFtQefZSGLfdaBSyROyrQ6hZovPK27QaAMIrg9mu6xm q2pl0k3JWBtrbB9A0+pDSRtqZWJElvS9RSZQ22Y6bIjVEG5ERsG6KIP60lSGMveXIvti W+FxQe37BdQXwLpqaMQpELQPjhb1rYdtGHVUGs/JNWFC5mh+FMfgyfKWgF2GMphXymq3 7LCoh1IVIYa/Ab9MEu5aeV0ZgzKOeisPql1hQtQoon9eXLmC0ottzluSKsNViISPG0kx 30oehePnKVKqdyABD7OmmV6VT7Ni9Fo5RtMexzH/us8HAw5EPuCfKjOSPAMgcdRc6/6b YpyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WKISbf+h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id h11-20020a056a00230b00b006cbb7fdff10si8759808pfh.194.2023.12.04.16.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 16:46:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WKISbf+h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 66DCF804C606; Mon, 4 Dec 2023 16:46:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346362AbjLEAqF (ORCPT + 99 others); Mon, 4 Dec 2023 19:46:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343693AbjLEApa (ORCPT ); Mon, 4 Dec 2023 19:45:30 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37C26A4 for ; Mon, 4 Dec 2023 16:45:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701737136; x=1733273136; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X/WHs4jb2k1fyD6oT320fhQc0wtdLRiTKuUWbSP8aYs=; b=WKISbf+hEU7czwXPrDDeSg/IZZzV/rYH9B9wnom8GiSCzZ6bhRHl/AKL 0pACJNwQTVh1GU5DuFLYpbF7ytqUxypSJknXxrYcBjutH2HmYv9HPTNNO VWpnYt1Fk55raoXEAHXLaGOjPEsK3wkfz2kJ8BlfDOqAe0dXB58ywCH6o 13T70juYR9lEtgSrh908y01g/fu/xpsNR5COAk1juLtek6pUvMqZdmo6T W6F5+fsmGMIjSltBD48b24pCRLYaZE8z65F0mwiND9F5EwheVtjrzDyK2 RiIWIKmpKRwjNUNhz8P6XGI3wXjJR6GuMxEKQWl/uyg2GRHNnHMEY80oi w==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="392688687" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="392688687" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 16:45:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="888704411" X-IronPort-AV: E=Sophos;i="6.04,251,1695711600"; d="scan'208";a="888704411" Received: from abijaz-mobl2.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.61.240]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 16:45:30 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id B75CB10A450; Tue, 5 Dec 2023 03:45:20 +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: [PATCHv4 13/14] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Tue, 5 Dec 2023 03:45:09 +0300 Message-ID: <20231205004510.27164-14-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231205004510.27164-1-kirill.shutemov@linux.intel.com> References: <20231205004510.27164-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Mon, 04 Dec 2023 16:46:39 -0800 (PST) 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; -- 2.41.0