Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1912414lqe; Tue, 9 Apr 2024 04:32:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXvy6+JydiHnRQCbVmfIepQNbYf6Mdkwdbl1gyzdK4qKUVm2K1ktVh8F14Je/vVyNeFK5MGlS4TfBR3z0lj4dwPbhryKWp+fTQ7vPJRCQ== X-Google-Smtp-Source: AGHT+IFyziEJDkh8/vObadyQ1W57EnAzycSVO7X+bDVAKxlt7Wg+8TT5wf2oQcnfPxQFDQVgs2Pt X-Received: by 2002:a9d:3e49:0:b0:6ea:d2d:d9a2 with SMTP id h9-20020a9d3e49000000b006ea0d2dd9a2mr8240981otg.19.1712662340639; Tue, 09 Apr 2024 04:32:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712662340; cv=pass; d=google.com; s=arc-20160816; b=hrTX69Mv3hmCzFaGaevti337mW6X0bTmNWNCVVM9arP++xwH5fCJTfpjGuArqvKEFG kw8j9GTgtshURYRkOi/yAMqab34FIeQNd2Pw/+nhPuL0SVCglYZdogNRHAHl+DMsaGTR BMq2JvgJFkADo82iOfwklOHAV3ZaSN87Q1SNhNKFNE3af2JO8kfGLf4dBSJ0O6+iF3as 1p0WZahjl7GNca7l4XuG6jwS0JcE38TWsm2GG491xZmD/+ljQ9KjCZQSQU7jslLGoM5R Jzrb75ZVuB4pP5FhZQeX01jLMUN4xj78q2f551lU+NsUf45T4ghrNTudpjY5mFqlyqs5 WVTA== 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=Eh38fXqnXtrXouGbPzvrU4VUOjiB8XOR4Z3pMqAc0EM=; fh=Yw2S7s1ZcF7+jfnU9Zy13ghDfPt/cQWqfRpyK6FQAJQ=; b=xLnWvjTOC8lGVXnCwIqcRq7mP0Wkbid+XP6XUOeuqpyaAMbHoX4+KdO9tdktZ248Gm +8ATcJ401J88mSSOmNzxSICDPNCMFNegCVPLOIu9s9B10pGm+NpdoX3Ri1ePjg1qMnUD mtDB6eWXnI6QDgwPUyaPV8nt1YMjuOfPbIoCLKTgNtsVVeSup6N1SyJ86AVzhWWwWC1x ofYJ3HTr/edRKDoHSJo7q1Vi8W37PhRXrX59bRZfq/dMauXttLKQJJSriolHlpMQJdVe WcR/C2Q/iKNE1kYzKP9CApNK6pscKdR006ZvGDgf+m1eRzwMvApKV4nbGnP/LXMchpLm JlOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BPFpW4zG; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-136757-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136757-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. [147.75.199.223]) by mx.google.com with ESMTPS id ye11-20020a05620a3b8b00b0078d63341705si4983037qkn.679.2024.04.09.04.32.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 04:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136757-linux.lists.archive=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=BPFpW4zG; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-136757-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136757-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 2302E1C23E57 for ; Tue, 9 Apr 2024 11:32:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5F3012F58B; Tue, 9 Apr 2024 11:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BPFpW4zG" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 EBB3A12DDAB for ; Tue, 9 Apr 2024 11:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662233; cv=none; b=AqiKhtQT0FoxXZ1XoPa2HxWkUoAetMp51MMzi8q+6/vyq6yzqjeWVRuDY6ZPUPupyVFqvNzR0CrNbcm4i373VYQunIEkizNymAz5AOE/ogVfp9yrp1onAux7pYxJAVfgWT6qOe3x9LhMQDdK6btJSGeIqcNU1shOQNkYZPrlms0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662233; c=relaxed/simple; bh=hHQ9KRFxDt369JBke8P/ZWEer7oQx7aWq4kGcpCYmms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dtllA4cknNW2EbAhJTwPCwS2dkBKgKpQPFrJKOkC8LqxVziFbM7pud0IaSJZ1W4dK/QeVmgKhwqB1RcGLf+6ZwNZFdc541zvPR7d/asdks20WUtvzHaqq1KK6LFZKMneTE/L57Pci8kc8EMhZ1h3WoPqjd4D5ZybnknxfVf5Dw4= 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=BPFpW4zG; arc=none smtp.client-ip=198.175.65.9 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=1712662233; x=1744198233; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hHQ9KRFxDt369JBke8P/ZWEer7oQx7aWq4kGcpCYmms=; b=BPFpW4zGMCn25SxQqnVifv9PaXPssosxt4DQXqSv/pqWLYX/Tv0G/UhN Lu+cXx8tnCkfgSVTVhQOUrv/xFZ4YViPO3OLIuUNm3XPct0MXqb/XvGsF Gm3lmhWg1SANqQ3b6f/IZwJH0egJakBc8+Mh/Zm3okhK4Q1zLlHLr5Dmj nVlltqMV0DcYx99O/ECY42Z2zpU7jJa/9WXLG9CO+3gojdDcEAD/2hqh1 75hX6TYIBllq9a/prYQJe0B3zBAWjREHTy5/jgcoQSrlpo02Sx7dYYXtl OQDhXliA57roGEjjqyBd2iTfQ2VTuqkjdv+o+JPNr0Bz50WNRDieQyObs Q==; X-CSE-ConnectionGUID: 3j5Bhcd/Qlis5cJUsK3BSg== X-CSE-MsgGUID: x/OJsDemS92l9tAd0L/pCA== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="30460413" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="30460413" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 04:30:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="937093339" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093339" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 04:30:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 312BA1010; Tue, 9 Apr 2024 14:30:18 +0300 (EEST) 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" , Tao Liu Subject: [PATCHv10 14/18] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Tue, 9 Apr 2024 14:30:06 +0300 Message-ID: <20240409113010.465412-15-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240409113010.465412-1-kirill.shutemov@linux.intel.com> References: <20240409113010.465412-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 Reviewed-by: Thomas Gleixner Tested-by: Tao Liu --- 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