From patchwork Mon Feb 12 10:44:45 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: 199760 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2421317dyd; Mon, 12 Feb 2024 05:20:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXiOsMHM46hEdwK+0SzjNeRGeOof3VuavT3Kv5oV9IB1UNcllmwbgc9NRnKomz94iMtNjY+VUAOOMclU/X2PlFE8vqL6w== X-Google-Smtp-Source: AGHT+IGjtCnCvulFb1rtR3neaztR8Er5Y3K99f7XJymhgskjSIzknGSF4L63Fbv9mGi+P/RBL4NE X-Received: by 2002:a05:620a:1922:b0:785:db35:937c with SMTP id bj34-20020a05620a192200b00785db35937cmr1732324qkb.37.1707744008888; Mon, 12 Feb 2024 05:20:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707744008; cv=pass; d=google.com; s=arc-20160816; b=QyEG4LIigqj83zjgKBxMsE050X8HJK/MH9CagFgzUCO3HES991XpY+DYZHlFrO2wAL chf+dpTAf7FI7BS527n5IJZxa23faXBicoS5h/bkDt2y8v5RJh0qawmt8/iVkx/UhjMd bHzRpb9G6a2l36vRcCg2Pi4jDr1xh2o23h26qpJKhEjD4oTYIb3TfiJJebKb9K88Q5FP R5xzL1H2VhywUvdkvKbWt21LUTYpW7PhkBwNpJ1YyJCE7o9Dw/tyy+6WmJvvRYXgBOlc VRYWf9GLuPAm/HqWI4ypL698I33f+buPyfR6DU8G5Z49gn+71utgGk856L+Uh3afkPaF LCSA== 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=4aIL7d1VYdjXQjAnBo7Sm4oRnloVcTX8WLpY3Pe+FwQ=; b=EF5ZHv1g8L3Ljm5uWD5/7MoZf+uMVbmj4rmrwGLNVWzHUfdr0ccjFtFPt0fLL8M9Nl Hn8AhHSuxUWhun+D/M21X9p1cCDQQyZdEDqkxMVufMS5kCIhDAFXt4OYpqnFGZvatR5T suq0YCUqb07P2JwK90/38pFzoBLg9dajqKyGAYCvsf7IEl4hegce6feuUMTgcdTyf2GY Ymhm+8gZ9DKMpI6h5RtI0dV71iTVyGnu16GPAd3SAdRuJlEuxWk1rXGmkd4uRYqxCx62 IC7FWnPMOuQLBSDCMrDfs9S8WlUcA6pTFr4ni4PB+y0UZSuIV1yuHNAUgEtjdpNT6bPX hqaw==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61362-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCU1sAxqdfUUIgtH9xjPlsCKiAD6A/HHIgH4TYllp+hm7lWEoXKsFUUR2liWqOHPFktoRykterHoglkKeol03gz3D1hPKg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bs15-20020a05620a470f00b00786d37e82casi549441qkb.137.2024.02.12.05.20.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:20:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61362-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=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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61362-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 907361C230B4 for ; Mon, 12 Feb 2024 10:50:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7B833D556; Mon, 12 Feb 2024 10:45:17 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790699382069829232 X-GMAIL-MSGID: 1790699382069829232 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 --- 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);