Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2532569lqb; Tue, 28 May 2024 02:58:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWg5bXYPsdAPZ8S9jJYjutYRtC2yyU3oKH2wbKshfzTDdreGpUsH6BPV/2TUSbGbw7n2UEttGRYC7Hil/aHeeyaHnSnJRdi6FPEVPwjNg== X-Google-Smtp-Source: AGHT+IGOY6FOhr58g3wpOrhI8GaMfSsoymhwm3hPk0p5vp8PqQYWQBmnDosKpeTq80b0RS9FYm7N X-Received: by 2002:ac8:7fd4:0:b0:43d:f7df:b9ff with SMTP id d75a77b69052e-43fb0e512a5mr115639741cf.6.1716890303395; Tue, 28 May 2024 02:58:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716890303; cv=pass; d=google.com; s=arc-20160816; b=f/fAmBytK4Fog5fyyRo5poxqukdSDx+AWLuGu9zMdt0e85mUEN53gG/F8/HtDP78Jd crPXD+6sCsJ+FNCK1lKDSON4o7r+gZmw5oYIPawV/sf8EglIg36QhdtoPVrLSBW2yzl4 CGehLvPYjlx38Scs+FqxUY9iN2F6QQMquBfhgnkdrrJkh55tj1RE5V/ThBxvCVO/xK2I 2mrcxhm8HQ2DsizghT1fKRccuZ9X+AT4nOHRp76zQemQAXlZ2hVDq4IozzI6CEIMP3Pa 385o5urMMAhDC9oUXwqkuIjbejOgDLgJUgKc+pzJyqASNgySbJHmxSL8HDW/8Th4Nq84 LfBg== 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=jKzY+IJTxktZ685R93VhJUbGF0rvTl3iTwtLazyIugI=; b=qOzCmxQJ0zoY7mVF1ChHSiQI8NB9QQiER2k3kvrQe6oAqXOoL8R+UYuyRNOrbTxRiQ 7f0N/cSEKWjdMZLGNkSgOolbU9LPC60+FZ94XiJMYJN1MzgwOap/EMG6UbDib64W6Hb1 qEUMVTQKkI85M1vIA7CGAZOhTdFfXgUDhaY1+dkj2xLYFIV8KNw0l2rBmiAbVDefnrRC JeEVqCvPhWicBMKZR1tprj2GmQo40SXgicSzqalhLk8AgRpJqEAsVPhJuuH+Mv7hAXBq 7Rynn1IfOnvF2wOum6PpzPIWUk1mmfXiyIXlpVL1fi4dFQaItFbhoF75sU5U3GgcUad2 5SpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BlGyOql1; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-192048-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192048-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 d75a77b69052e-43fb18ede3csi112506051cf.761.2024.05.28.02.58.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 02:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192048-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=BlGyOql1; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-192048-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192048-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 7F8221C23B33 for ; Tue, 28 May 2024 09:58:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F23B016D9C3; Tue, 28 May 2024 09:55:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BlGyOql1" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 B001416B725; Tue, 28 May 2024 09:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716890154; cv=none; b=RXMo3yxxUYNCh+v9zhlyEj5VxRK0M4lMdlBUZMgsH8+SKYVlsZT5eH0EYYmPKVNCgrTyWQezdlD26T9IxZ/ZOd7kRgql3otNz3xXwkSWdbpGc6cIgqtKWj3g5n+MdkSgNVajAg78tKCVb67t+f9OYaG5yqNNqUv53EXFGcHYcbE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716890154; c=relaxed/simple; bh=hHQ9KRFxDt369JBke8P/ZWEer7oQx7aWq4kGcpCYmms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rx8EAPnA1sF8jBvkdH7qJDdRlXPNRbIamIJtETGOf438/FKk5lkRjLdrtv3zi0J0poI+tiu9iqgqQ4wzWTGAHLm5Z8lx4h6IEY4FrSFTgxVSp21O97i4SmwhOw7Kl/xFwxbl96YOTEZTEo+UYbFVHhe14UL3+oOEpc+DjTsrQLU= 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=BlGyOql1; arc=none smtp.client-ip=192.198.163.17 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=1716890153; x=1748426153; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hHQ9KRFxDt369JBke8P/ZWEer7oQx7aWq4kGcpCYmms=; b=BlGyOql1eARWLn8LukvKtbmNSo/l0cLnpC2Opt1Z7MUP60t3/0QirubT /uc7EHxtvGhPthhe9+QYbdGAxbt/WJ3PzX+16Acb/DOQ2lB+T6qA1BmRb ls7+FUjkokUPp1i8y+ryrPYHUvtbayzbut64YdIdSmMqOAtgSfYqX0DbA c6iKlA34jS8hgsuYN31x0EIp9kf9Z0u3YtE0Lp7FEnw2nmla+P8+Q4p7/ jNiHLKIjVRZh5tN7QCHM2ypTa8vYLYgIU8jphTRbNDLWFODoLfZUBsg6T Sy4ioI9fy+Y2GN2Am5M45OGpaJbBw8/sIH2rv9SCZ1OlkYFX0cAzLfbrX A==; X-CSE-ConnectionGUID: XGMqmFV6RcqGsOBWYRP8GQ== X-CSE-MsgGUID: ZJjt3uijRjOUXfM9xb5vJw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13097808" X-IronPort-AV: E=Sophos;i="6.08,194,1712646000"; d="scan'208";a="13097808" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 02:55:47 -0700 X-CSE-ConnectionGUID: 7XKH460fSwm5D/IsirCqgA== X-CSE-MsgGUID: m26kk0SmSh69XFK2ZB689A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,194,1712646000"; d="scan'208";a="34951819" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 02:55:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 0AA91A19; Tue, 28 May 2024 12:55:27 +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" , Ard Biesheuvel , Baoquan He , "H. Peter Anvin" , "Kirill A. Shutemov" , "K. Y. Srinivasan" , Haiyang Zhang , kexec@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-acpi@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Tao Liu Subject: [PATCHv11 15/19] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Tue, 28 May 2024 12:55:18 +0300 Message-ID: <20240528095522.509667-16-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240528095522.509667-1-kirill.shutemov@linux.intel.com> References: <20240528095522.509667-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