Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1095932rdb; Wed, 24 Jan 2024 04:59:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0FBJbldZmJWV9AOViLA9cM1Cfo0FLSEl4Hc5UbJ1iuv2YaVafPbb31YVTqyv9aiiWD51j X-Received: by 2002:a05:620a:147c:b0:77f:38f2:2d99 with SMTP id j28-20020a05620a147c00b0077f38f22d99mr7927895qkl.83.1706101164425; Wed, 24 Jan 2024 04:59:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706101164; cv=pass; d=google.com; s=arc-20160816; b=LNJlQpse/5htcrqS/m1Wc1PmRQ+kWZYsMSHMLb0CwCyXWWtBoURoz3wGaIrxIC+Nd5 N/40PMfsxWLDTWaBVkVebrLbMefOfRcf/Q59fRlT1z9GfXwI6uGohUTc5AL1vnY6rtf9 /QGQaW3s20+tyAUcEX9DM+dyakEylWXFWdxr22Jhr9BWhPXFb6wDwjkQQvFTLNPzwhqk GWEKKD5C11NobZmdOT0Irx6dLgJQNZclAmOTi5SSeSh46+Y1yfG8MQhUNVYO9/nM1lXx b9VfGWdiFZhl85cyyWl3UJPgoj5Dx7PuSeMvVVwkxv6PXggKZBVNiCF78LloS2RzrTvw bjaA== 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=A477xU0NMiPmaRKikOD+AP/rAovKr91FXfBuKHuWsyo=; fh=OvJRnOqsMTm9XoNmEwebcqh9Ud7yh1CTeKAP84ols98=; b=k6k+KqEnwY1pigEdRmy74LsGN4C0IITa243aJrCnXKdQyVyOc2ck0VZKdBLHDgaHke hG5A65TsY7fEO1QmMB+3Q6Naejs8uFsbJgWoItNkYq0KJfSeoRRVnKzlKL1LhHzuH7Y0 zTqT0Jg+4On9i4SfQI48V9rhUixN57v3yAIk7qH5vIDheElIrEYykYMDxcpGnmaCB/gz RAaxZx5KpF92ZXAJlbNdcgNMdxaaeC+INr4jy2Uc2861iK8ZJoiv0x6m6wir0rp89do8 debVn65BDVds8vddf+X/6qftxcACq+idu95XjAQO3WrLCoG5bo3KQAJr8HE37a3eQk+k 31bQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AFNWKeP2; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-37034-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c3-20020a05620a11a300b007839654e7d2si8863277qkk.117.2024.01.24.04.59.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 04:59:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37034-linux.lists.archive=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=AFNWKeP2; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-37034-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37034-linux.lists.archive=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 1D64C1C255E6 for ; Wed, 24 Jan 2024 12:59:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4ED5B7E560; Wed, 24 Jan 2024 12:57:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AFNWKeP2" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) (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 07A867CF03 for ; Wed, 24 Jan 2024 12:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=134.134.136.31 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706101024; cv=none; b=Wu3R2bRpoz65gGmJG2stZfP7+2moCr93lAiNiOrj9ZuUQYhsVkZhfRuqSHAJ6Mg/FQ57F3D2WRiCdIrh+OIvEL12atDjdxwmI7mKe8gcsoFsH3A+Jk++8C2KFFeUkPuGTIKE8n+5AOUQlhTP/TETrBzICyDZKOnkMHV2xPmJBro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706101024; c=relaxed/simple; bh=dL+ZDyNfeHUiVdGS89eu26OHL8+JI0276K2FgncM1Wo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iVCANYGI/D/kh/HC0GAwxYrBx/q5Aok7mD0Ertoc+JQ/dwgdKH34XkW1s+yfOy/iTrYyPAPlQS9eIwYevN3d7p8nCv+sVGeD2FUM10O2j1TdMvXetDGuQKHS8xQhnMxHjF+APxeJ/6ZxcGwcHh00BB3XmGZVGZI280DxVutKQc4= 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=AFNWKeP2; arc=none smtp.client-ip=134.134.136.31 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=1706101023; x=1737637023; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dL+ZDyNfeHUiVdGS89eu26OHL8+JI0276K2FgncM1Wo=; b=AFNWKeP2nROTckEfuPi5GrL1P5Utt/KG99cUxGHd8wXfcvacwOREOcsJ /6DRz9trITQCboBAYxcCZVeKyBSZdy0aI37kJXLTIvqnme4LygwSVKCzD /rFB3Bs1X89oPpHJkbtzgZwjrttrMjex0BQK/HQMIQLdV6RPjPinPwmup phOwislqdStduD65a2zqX4DhYeARSIgt7VtqkZDzFBTgP+TvsXhdVhAf/ x0sdVmfKidYboMx2YFOlpDU/HpJHjcmR6ncWCVnvl7Co2qkrI911qp3nj 0Qf2GzmViRHgHsX16CU9sJwKu3H6F+7lG9uHIJ20LP+sbeljCnkmhJtWw A==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="466110248" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="466110248" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2024 04:56:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="735924100" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="735924100" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 24 Jan 2024 04:56:53 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id BBE84A62; Wed, 24 Jan 2024 14:56:02 +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: [PATCHv6 13/16] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Wed, 24 Jan 2024 14:55:54 +0200 Message-ID: <20240124125557.493675-14-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124125557.493675-1-kirill.shutemov@linux.intel.com> References: <20240124125557.493675-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 Content-Transfer-Encoding: 8bit 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); -- 2.43.0