From patchwork Wed Jan 24 12:55:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 191581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp1015575dyi; Wed, 24 Jan 2024 06:15:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEb0QzXX1Vr2ZR+lFOw+Mn3tl54Vh1kpxrUqh0AiYmwMA2M83xk1osozkpv4ltj/2AVwxvK X-Received: by 2002:a05:620a:f06:b0:783:24ec:a2c3 with SMTP id v6-20020a05620a0f0600b0078324eca2c3mr10285949qkl.81.1706105706006; Wed, 24 Jan 2024 06:15:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706105705; cv=pass; d=google.com; s=arc-20160816; b=Boq9GcrLXEUvm7qF8EneAKITpMGJFG/watMmjzOFKqOiaJK83h3bNj5Yh8SVYJtIao NMyW9gEn7YX2wFvSv55WvqLHzHQbGasaBgd3vs4dlcJCllPlOooXMYH2K9lHYvU9G7sZ HefrDDcHCpNQnTXxpXW3VaEX7JBz3CyjUuEKmv2whJs8SZc5aKfwppCAloVoizLo622F eAfIjoW14aHAI53jDjpeDjcl5f6vLwKVoSCFu3oVHPBINZyrSsGlCZ69eM+EZuc/enm5 xGN2eVrg028tCGzYoS0plpHIme93jY1UpRpaz4sQ1nGoan8c5/FwpdMFE0YRGKCfAHnM FdUA== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37034-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id oo25-20020a05620a531900b0078355a0afe5si9907854qkn.416.2024.01.24.06.15.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 06:15:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37034-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37034-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9C1761C25CF0 for ; Wed, 24 Jan 2024 12:59:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 552C17E760; Wed, 24 Jan 2024 12:57:07 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788981496803213734 X-GMAIL-MSGID: 1788981496803213734 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);