Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2375663rdb; Mon, 12 Feb 2024 02:49:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLFDb51By3JUHqJudiorWTBG10NeKRxVBtjXOz2SPks3YjZsEo/N4PtZ9bI08zwkDrrtQX1i0Rf7Sp7JGX5+DQaf7poZL+yDGfraYMBw== X-Google-Smtp-Source: AGHT+IGn3kWACAAGB7XHeulnnxigJGbMUVTvwpA9yUApNaK0mrwVzQO9v6rJSVyVE21vn/Z0x7GX X-Received: by 2002:a05:6402:1a36:b0:560:590:1044 with SMTP id be22-20020a0564021a3600b0056005901044mr4106509edb.6.1707734980976; Mon, 12 Feb 2024 02:49:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707734980; cv=pass; d=google.com; s=arc-20160816; b=VbAtTi6DqdAmotLONYG+wPHjGV22psVZb09gQYHtLszlSvG10sr1soxUd9pOeGJLpB E6UtoMXmkTP/SPUWNoHRhxBLgwKJmd+4Zo5KavrqI3jH6+O7rIQz8ttpIlgyKeuZsfZi Y7DgnkdrCmbLZ+iLwZG8ytW3eRhFadA9eiJfV97AA13swyHgKxJNTfBz8mlYFjom+NKF 7Mmi7vosdjbzYyeQeHTs/5m+Xcq3i9P3zgqNeZvJDAc2rUaNpVl4yqTllozEaUPI38Uj NIUcZFJZgFIIMQX6rRHdfasK6C3C93AyvybqGooMD0H26cjvLIEFapqOjDvqygXN7ovL q2bQ== 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=9lc4k044MyvnHJYTB8CoXxnw1aYAApxjn5cIir9/UWk=; b=NvYK2drF77bTHvBUbqEUG6NQL0emr7JQMYVdVx/+LeLiIwcH9Yf21mGaAgtFmHm8oP StBaIP4izluCc/zw+MeQdQDl0bp/gfvdu11htfzA4m7IVHh4bPANwUHPqqgQqwE4Wk6a u4SLdP0OCBFxQS8tEC7mStYbLK64QYTLPrVdLQUGHu2+RePjE/WZ6sJvgj6vqRuKjR5a TWY4F8akqqBbuYn2gvZUxInXMTnOlPKRkESFV9A6zT4KDF5Kzc388OP8Y2Xb1iCrQtTM CRiIPqNnxegDFapMuBG3odfS4lt5us4piR8xR633EbWH/at6Y8Av60CcvjgRv89x5ZxY +P8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dkturCqX; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61362-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61362-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCVnG0Rr+sz0BjVlFgRYWn4vVPgvKKVa2BdFutrBkILYyXE1l/hSFwa7OnF0llI724oSYlCWj9DeHTAci3NFNdDu+yfy94Vz+U+e+U1jsg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k2-20020aa7d8c2000000b0055f009a3b1asi2566781eds.627.2024.02.12.02.49.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 02:49:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61362-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dkturCqX; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61362-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61362-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 94EB11F26509 for ; Mon, 12 Feb 2024 10:49:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56AD33CF75; Mon, 12 Feb 2024 10:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dkturCqX" 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 F03E73C08F for ; Mon, 12 Feb 2024 10:45:11 +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=1707734714; cv=none; b=Um79aEayQnEzKPuW1jyQ581FFVPva25/ZFTNSk/1eWb2eMpEgnnUAst6HV2iQ4MRyLB/heRxmoL4l7ApnN7ae6K4OHndmZdoRkC1Y8jx1k5sCRxIa9g2L0SOcn3qtXaKek6wNQHZFbZIfUVFsp1lOnxkdhfZlxWYo0zWkyquTWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707734714; c=relaxed/simple; bh=dL+ZDyNfeHUiVdGS89eu26OHL8+JI0276K2FgncM1Wo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IVWaT8fNRY2o4PaN9xpBCwb4YYOX+IgLGWe878QxQi4jlqLBnjsvBNkqoEerZ5i42Ung626AZ2xOR5oMxb8Afa1ANQxzdUGiEYpsV53zb3sXuj8virlDXMJyMCdLAIeEi5gWnzk0/VOO4JlOrI5nuad85DyrZG6fTyRFVovORnI= 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=dkturCqX; 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=1707734711; x=1739270711; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dL+ZDyNfeHUiVdGS89eu26OHL8+JI0276K2FgncM1Wo=; b=dkturCqXD0O5oGshIpP7YNUl63o2G9HxmfdfohASIqKEP0wZwcMeZbUo Z1XtUcuCo4wSu+9WSZh01sPmN7gyvXInVmYKMDbA0rdcHGfVkLF20mNKH AEnKH0K7Jb56EPXOcKxAFfl54jtJfTu4ip5zDQRdB9bQWageBs2U/HRQK +Fl/Ug1ArRYVs9QDsGRaMNsZxILwkiXFxKV9J8B5cfsxWCYgJ2x2cI0j4 3GCsD0p5+yf55HX4GxP/dochwx+EqU53BWeT1wEbBX4tcBlNSVh3iM5C1 6vCwwMjoSq2BuDgdKzkRwq8ISYRViFSzkH921/CpbvQRqtPShS05OJXJ0 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10981"; a="1585118" X-IronPort-AV: E=Sophos;i="6.05,263,1701158400"; d="scan'208";a="1585118" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 02:45:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10981"; a="935035611" X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="935035611" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2024 02:45:00 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 9629B693; Mon, 12 Feb 2024 12:44:53 +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: [PATCHv7 13/16] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Date: Mon, 12 Feb 2024 12:44:45 +0200 Message-ID: <20240212104448.2589568-14-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212104448.2589568-1-kirill.shutemov@linux.intel.com> References: <20240212104448.2589568-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