From nobody Sun Feb 8 04:23:13 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 26E26187332; Fri, 17 Oct 2025 02:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669331; cv=none; b=p106G71RoiccaTtBLBkPNj4pLx9Jtyit2cbH6ZtGmr4LtSxA4dfTCxI7hvW8RZMaHahgJz9mag4oS9JsFIweje0UhiGFWh1uK2yiTUfinQa1k8957efSRD/2hLiiCEcfKIe1XkO/0kKcOcJPMuF8aSFO3CzUsFniomp7XV9Yrwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669331; c=relaxed/simple; bh=LIqUV6VOVMcoYUSWfWyv8zoYNppCVbs3oUzzRQpEXEg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AGtJGMAHaaAX9zjiHV/4NbR0/nTMX6smFOFnH5hOiOHYkRO1DMzuuHrlySfSH1wbaMTviaeFylKS8CMlMxgjh63KL3vssXnRU6adtvQLvDpy47MJTqnMAkDOn421ywUuNlHSFPTXOqozQqThbOZflewSDuXLaRsF3R0FLoEWpoU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=T/nPod4+; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="T/nPod4+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669330; x=1792205330; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=LIqUV6VOVMcoYUSWfWyv8zoYNppCVbs3oUzzRQpEXEg=; b=T/nPod4+MsuIJPkraaSxA9tb+BLI9pxcaBArtzJ5XrrChgZNbKwxMc2P B0C12NTqHjRNc4CxPtxzgzRu3uq/UiHjAJrxCeAMhvDlgsSk9/mD0IETB jnmOdZeVcA3xBJzcfYWNnA0lxx1W9b8YGVbDeLJcKVvJOBHtm1v8TQArt lHOJ2TZ8rKBVIzTVlea/cJxqz9hv3gUW5DwIFSOmvbweDXFud6AgXshhV 6bJVA4sAUw20joIrKVgSYN/KdYZYiER2GQ5bUGHNsHytGPinFMRUIpp7y tdb8uF9CFrLW07Hsoaq1iW6oQYkYjVrkK5R2uARnpUKn6rUguq00Sr5N2 w==; X-CSE-ConnectionGUID: +moL93ZpSVOaPEMTNgnLNw== X-CSE-MsgGUID: VgYWD3JsToWUtgo5/vsQ3Q== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321894" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321894" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:48 -0700 X-CSE-ConnectionGUID: gdYNjOJRSKKgN8E2Uinm6Q== X-CSE-MsgGUID: F/5yH4ydS+aUmw5e+aQz6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776543" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:47 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:23 -0700 Subject: [PATCH v6 01/10] x86/acpi: Add helper functions to setup and access the wakeup mailbox Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-1-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , "Rafael J. Wysocki" , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=4248; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=LIqUV6VOVMcoYUSWfWyv8zoYNppCVbs3oUzzRQpEXEg=; b=qy4W3Ui4SabjPrVoIccHWHv3fyFCugOxl9VAGFCq62NxCXwgqYna+EdYAKn9VuPgyPXSrORuw ubpVWxpR+enB3qGLWHRkm/8JOABuCnHv/fTdVEdZ3fWFWGIyI29cpf0 X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= In preparation to move the functionality to wake secondary CPUs up from the ACPI code, add two helper functions. The function acpi_setup_mp_wakeup_mailbox() stores the physical address of the mailbox and updates the wakeup_secondary_cpu_64() APIC callback. There is a slight change in behavior: now the APIC callback is updated before configuring CPU hotplug offline behavior. This is fine as the APIC callback continues to be updated unconditionally, regardless of the restriction on CPU offlining. The function acpi_madt_multiproc_wakeup_mailbox() returns a pointer to the mailbox. Use this helper function only in the portions of the code for which the variable acpi_mp_wake_mailbox will be out of scope once it is relocated out of the ACPI directory. The wakeup mailbox is only supported for CONFIG_X86_64 and needed only with CONFIG_SMP=3Dy. Reviewed-by: Dexuan Cui Acked-by: Rafael J. Wysocki Signed-off-by: Ricardo Neri Acked-by: Rafael J. Wysocki (Intel) --- Changes since v5: - Fixed grammar error in the subject of the patch. (Rafael) - Added Acked-by tag from Rafael. Thanks! - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - None Changes since v3: - Squashed the two first patches of the series into one, both introduce helper functions. (Rafael) - Renamed setup_mp_wakeup_mailbox() as acpi_setup_mp_wakeup_mailbox(). (Rafael) - Dropped the function prototype for !CONFIG_X86_64. (Rafael) Changes since v2: - Introduced this patch. Changes since v1: - N/A --- arch/x86/include/asm/smp.h | 3 +++ arch/x86/kernel/acpi/madt_wakeup.c | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index 22bfebe6776d..47ac4381a805 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -149,6 +149,9 @@ static inline struct cpumask *cpu_l2c_shared_mask(int c= pu) return per_cpu(cpu_l2c_shared_map, cpu); } =20 +void acpi_setup_mp_wakeup_mailbox(u64 addr); +struct acpi_madt_multiproc_wakeup_mailbox *acpi_get_mp_wakeup_mailbox(void= ); + #else /* !CONFIG_SMP */ #define wbinvd_on_cpu(cpu) wbinvd() static inline void wbinvd_on_all_cpus(void) diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b/arch/x86/kernel/acpi/madt= _wakeup.c index 6d7603511f52..c3ac5ecf3e7d 100644 --- a/arch/x86/kernel/acpi/madt_wakeup.c +++ b/arch/x86/kernel/acpi/madt_wakeup.c @@ -37,6 +37,7 @@ static void acpi_mp_play_dead(void) =20 static void acpi_mp_cpu_die(unsigned int cpu) { + struct acpi_madt_multiproc_wakeup_mailbox *mailbox =3D acpi_get_mp_wakeup= _mailbox(); u32 apicid =3D per_cpu(x86_cpu_to_apicid, cpu); unsigned long timeout; =20 @@ -46,13 +47,13 @@ static void acpi_mp_cpu_die(unsigned int cpu) * * BIOS has to clear 'command' field of the mailbox. */ - acpi_mp_wake_mailbox->apic_id =3D apicid; - smp_store_release(&acpi_mp_wake_mailbox->command, + mailbox->apic_id =3D apicid; + smp_store_release(&mailbox->command, ACPI_MP_WAKE_COMMAND_TEST); =20 /* Don't wait longer than a second. */ timeout =3D USEC_PER_SEC; - while (READ_ONCE(acpi_mp_wake_mailbox->command) && --timeout) + while (READ_ONCE(mailbox->command) && --timeout) udelay(1); =20 if (!timeout) @@ -227,7 +228,7 @@ int __init acpi_parse_mp_wake(union acpi_subtable_heade= rs *header, =20 acpi_table_print_madt_entry(&header->common); =20 - acpi_mp_wake_mailbox_paddr =3D mp_wake->mailbox_address; + acpi_setup_mp_wakeup_mailbox(mp_wake->mailbox_address); =20 if (mp_wake->version >=3D ACPI_MADT_MP_WAKEUP_VERSION_V1 && mp_wake->header.length >=3D ACPI_MADT_MP_WAKEUP_SIZE_V1) { @@ -243,7 +244,16 @@ int __init acpi_parse_mp_wake(union acpi_subtable_head= ers *header, acpi_mp_disable_offlining(mp_wake); } =20 + return 0; +} + +void __init acpi_setup_mp_wakeup_mailbox(u64 mailbox_paddr) +{ + acpi_mp_wake_mailbox_paddr =3D mailbox_paddr; apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); +} =20 - return 0; +struct acpi_madt_multiproc_wakeup_mailbox *acpi_get_mp_wakeup_mailbox(void) +{ + return acpi_mp_wake_mailbox; } --=20 2.43.0 From nobody Sun Feb 8 04:23:13 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 7EF101B424F; Fri, 17 Oct 2025 02:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669332; cv=none; b=OBKBAdmWZi4U4+jks2YScqVW/ESg2c9ZHTKlHzzTthiWqh7xtpCu6d1qdH86WtGa6Zs2VeseIQulcp0vXqLapOn/cnWkKwmFyqGcHI7aqDRJecFZHA/pwc8dlGbJ/4KOLJGIjCfG4qYnaYKiZNW9ASpEf0Rhj9vFOUvXm5rct9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669332; c=relaxed/simple; bh=yy8wYdbt9kakgXaxoWtnz9ydjfY97cM1sePEpjOv73o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SS0uiZecoX2wXMzS7TDRVT+K9+kH+WhuDTcRAAIUt9Ki24krtKgadifzufH7vxEs6NaZMV4uTpNBZywlCZRG5H9pvEJvn5ggAv5bJok9yD+Z1Fv9cBglT/0jDnsU/AkL9rUvNa2Nmio9PzXSK0kyOtfzO5wVUZ7zHaR669gn+Uk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XUHArk9Z; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XUHArk9Z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669331; x=1792205331; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=yy8wYdbt9kakgXaxoWtnz9ydjfY97cM1sePEpjOv73o=; b=XUHArk9ZZMu4N1u700rFgHtdc1PK5cDjAYmPWJd3uafcZk34Lpi/aL1B NxDwUeUfrI4NqVBGACWQV8FEZbi/+C78ir224qppveITpWp+ZCxKYBFUR M3jbQ3jPj3rlHzDdWE/oBjoSmkE+1NNXwtrkBTiZd7cGxULAtbB6Bgr94 tTpyZ6m1RgWPzLKF2MTReiEz6WjVqcCVYUY747zNeQ098mCNlEiK/5z/A c7Pcc51cyKDIfXV2I4Eexm+RZDKpd0v7YGJSIhdcX0fDJp4xHcJYeKcXA P/2NM1S1FQBA+LWRwkjWSKAx1I2/xW2Inq+KtYP6PTeBwL5K/tgleXiyw w==; X-CSE-ConnectionGUID: bNgvcg6AQ6CSq05JBRISBQ== X-CSE-MsgGUID: WSjgmA3OS0mRNFdq8SVuoQ== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321899" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321899" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:49 -0700 X-CSE-ConnectionGUID: h0+G6mV7QCahHB/mCFN4IA== X-CSE-MsgGUID: tT/BvW3oRRyDGVSfzbUgKw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776547" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:48 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:24 -0700 Subject: [PATCH v6 02/10] x86/acpi: Move acpi_wakeup_cpu() and helpers to smpwakeup.c Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-2-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , "Rafael J. Wysocki" , Yunhong Jiang , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=9884; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=yy8wYdbt9kakgXaxoWtnz9ydjfY97cM1sePEpjOv73o=; b=wEFZNVJnjhsLlVPvFsCnUmZagCentzfOsu+9MFEc6nC6SZsqy+Z30RMqqzdLRo/0fcLzgF5WZ rA/rx1CdnZWDRgKyBJoP2aLaHljEOUWYSrVbnrDgP18B+RWwT5GFSxm X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= The bootstrap processor uses acpi_wakeup_cpu() to indicate to firmware that it wants to boot a secondary CPU using a mailbox as described in the Multiprocessor Wakeup Structure of the ACPI specification. The platform firmware may implement the mailbox as described in the ACPI specification but enumerate it using a DeviceTree graph. An example of this is the OpenHCL paravisor. Move the code used to setup and use the mailbox for CPU wakeup out of the ACPI directory into a new smpwakeup.c file that can be used by both ACPI and DeviceTree. No functional changes are intended. Reviewed-by: Dexuan Cui Acked-by: Rafael J. Wysocki Co-developed-by: Yunhong Jiang Signed-off-by: Yunhong Jiang Signed-off-by: Ricardo Neri --- Changes since v5: - Minor change to the changelog. (Rafael) - Added Acked-by tag from Rafael. Thanks! - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - Removed dependency on CONFIG_OF. It will be added in a later patch. (Rafael) - Rebased on v6.16-rc3. Changes since v3: - Create a new file smpwakeup.c instead of relocating it to smpboot.c. (Rafael) Changes since v2: - Only move to smpboot.c the portions of the code that configure and use the mailbox. This also resolved the compile warnings about unused functions that Michael Kelley reported. - Edited the commit message for clarity. Changes since v1: - None. --- arch/x86/Kconfig | 7 ++++ arch/x86/kernel/Makefile | 1 + arch/x86/kernel/acpi/madt_wakeup.c | 76 ---------------------------------- arch/x86/kernel/smpwakeup.c | 83 ++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 91 insertions(+), 76 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index fa3b616af03a..f57192a34a87 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1108,6 +1108,13 @@ config X86_LOCAL_APIC depends on X86_64 || SMP || X86_UP_APIC || PCI_MSI select IRQ_DOMAIN_HIERARCHY =20 +config X86_MAILBOX_WAKEUP + def_bool y + depends on ACPI_MADT_WAKEUP + depends on X86_64 + depends on SMP + depends on X86_LOCAL_APIC + config ACPI_MADT_WAKEUP def_bool y depends on X86_64 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index bc184dd38d99..a9a1fbc798fb 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -94,6 +94,7 @@ apm-y :=3D apm_32.o obj-$(CONFIG_APM) +=3D apm.o obj-$(CONFIG_SMP) +=3D smp.o obj-$(CONFIG_SMP) +=3D smpboot.o +obj-$(CONFIG_X86_MAILBOX_WAKEUP) +=3D smpwakeup.o obj-$(CONFIG_X86_TSC) +=3D tsc_sync.o obj-$(CONFIG_SMP) +=3D setup_percpu.o obj-$(CONFIG_X86_MPPARSE) +=3D mpparse.o diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b/arch/x86/kernel/acpi/madt= _wakeup.c index c3ac5ecf3e7d..a7e0158269b0 100644 --- a/arch/x86/kernel/acpi/madt_wakeup.c +++ b/arch/x86/kernel/acpi/madt_wakeup.c @@ -2,12 +2,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include @@ -15,12 +13,6 @@ #include #include =20 -/* Physical address of the Multiprocessor Wakeup Structure mailbox */ -static u64 acpi_mp_wake_mailbox_paddr __ro_after_init; - -/* Virtual address of the Multiprocessor Wakeup Structure mailbox */ -static struct acpi_madt_multiproc_wakeup_mailbox *acpi_mp_wake_mailbox; - static u64 acpi_mp_pgd __ro_after_init; static u64 acpi_mp_reset_vector_paddr __ro_after_init; =20 @@ -127,63 +119,6 @@ static int __init acpi_mp_setup_reset(u64 reset_vector) return 0; } =20 -static int acpi_wakeup_cpu(u32 apicid, unsigned long start_ip, unsigned in= t cpu) -{ - if (!acpi_mp_wake_mailbox_paddr) { - pr_warn_once("No MADT mailbox: cannot bringup secondary CPUs. Booting wi= th kexec?\n"); - return -EOPNOTSUPP; - } - - /* - * Remap mailbox memory only for the first call to acpi_wakeup_cpu(). - * - * Wakeup of secondary CPUs is fully serialized in the core code. - * No need to protect acpi_mp_wake_mailbox from concurrent accesses. - */ - if (!acpi_mp_wake_mailbox) { - acpi_mp_wake_mailbox =3D memremap(acpi_mp_wake_mailbox_paddr, - sizeof(*acpi_mp_wake_mailbox), - MEMREMAP_WB); - } - - /* - * Mailbox memory is shared between the firmware and OS. Firmware will - * listen on mailbox command address, and once it receives the wakeup - * command, the CPU associated with the given apicid will be booted. - * - * The value of 'apic_id' and 'wakeup_vector' must be visible to the - * firmware before the wakeup command is visible. smp_store_release() - * ensures ordering and visibility. - */ - acpi_mp_wake_mailbox->apic_id =3D apicid; - acpi_mp_wake_mailbox->wakeup_vector =3D start_ip; - smp_store_release(&acpi_mp_wake_mailbox->command, - ACPI_MP_WAKE_COMMAND_WAKEUP); - - /* - * Wait for the CPU to wake up. - * - * The CPU being woken up is essentially in a spin loop waiting to be - * woken up. It should not take long for it wake up and acknowledge by - * zeroing out ->command. - * - * ACPI specification doesn't provide any guidance on how long kernel - * has to wait for a wake up acknowledgment. It also doesn't provide - * a way to cancel a wake up request if it takes too long. - * - * In TDX environment, the VMM has control over how long it takes to - * wake up secondary. It can postpone scheduling secondary vCPU - * indefinitely. Giving up on wake up request and reporting error opens - * possible attack vector for VMM: it can wake up a secondary CPU when - * kernel doesn't expect it. Wait until positive result of the wake up - * request. - */ - while (READ_ONCE(acpi_mp_wake_mailbox->command)) - cpu_relax(); - - return 0; -} - static void acpi_mp_disable_offlining(struct acpi_madt_multiproc_wakeup *m= p_wake) { cpu_hotplug_disable_offlining(); @@ -246,14 +181,3 @@ int __init acpi_parse_mp_wake(union acpi_subtable_head= ers *header, =20 return 0; } - -void __init acpi_setup_mp_wakeup_mailbox(u64 mailbox_paddr) -{ - acpi_mp_wake_mailbox_paddr =3D mailbox_paddr; - apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); -} - -struct acpi_madt_multiproc_wakeup_mailbox *acpi_get_mp_wakeup_mailbox(void) -{ - return acpi_mp_wake_mailbox; -} diff --git a/arch/x86/kernel/smpwakeup.c b/arch/x86/kernel/smpwakeup.c new file mode 100644 index 000000000000..5089bcda615d --- /dev/null +++ b/arch/x86/kernel/smpwakeup.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include +#include + +/* Physical address of the Multiprocessor Wakeup Structure mailbox */ +static u64 acpi_mp_wake_mailbox_paddr __ro_after_init; + +/* Virtual address of the Multiprocessor Wakeup Structure mailbox */ +static struct acpi_madt_multiproc_wakeup_mailbox *acpi_mp_wake_mailbox; + +static int acpi_wakeup_cpu(u32 apicid, unsigned long start_ip, unsigned in= t cpu) +{ + if (!acpi_mp_wake_mailbox_paddr) { + pr_warn_once("No MADT mailbox: cannot bringup secondary CPUs. Booting wi= th kexec?\n"); + return -EOPNOTSUPP; + } + + /* + * Remap mailbox memory only for the first call to acpi_wakeup_cpu(). + * + * Wakeup of secondary CPUs is fully serialized in the core code. + * No need to protect acpi_mp_wake_mailbox from concurrent accesses. + */ + if (!acpi_mp_wake_mailbox) { + acpi_mp_wake_mailbox =3D memremap(acpi_mp_wake_mailbox_paddr, + sizeof(*acpi_mp_wake_mailbox), + MEMREMAP_WB); + } + + /* + * Mailbox memory is shared between the firmware and OS. Firmware will + * listen on mailbox command address, and once it receives the wakeup + * command, the CPU associated with the given apicid will be booted. + * + * The value of 'apic_id' and 'wakeup_vector' must be visible to the + * firmware before the wakeup command is visible. smp_store_release() + * ensures ordering and visibility. + */ + acpi_mp_wake_mailbox->apic_id =3D apicid; + acpi_mp_wake_mailbox->wakeup_vector =3D start_ip; + smp_store_release(&acpi_mp_wake_mailbox->command, + ACPI_MP_WAKE_COMMAND_WAKEUP); + + /* + * Wait for the CPU to wake up. + * + * The CPU being woken up is essentially in a spin loop waiting to be + * woken up. It should not take long for it wake up and acknowledge by + * zeroing out ->command. + * + * ACPI specification doesn't provide any guidance on how long kernel + * has to wait for a wake up acknowledgment. It also doesn't provide + * a way to cancel a wake up request if it takes too long. + * + * In TDX environment, the VMM has control over how long it takes to + * wake up secondary. It can postpone scheduling secondary vCPU + * indefinitely. Giving up on wake up request and reporting error opens + * possible attack vector for VMM: it can wake up a secondary CPU when + * kernel doesn't expect it. Wait until positive result of the wake up + * request. + */ + while (READ_ONCE(acpi_mp_wake_mailbox->command)) + cpu_relax(); + + return 0; +} + +void __init acpi_setup_mp_wakeup_mailbox(u64 mailbox_paddr) +{ + acpi_mp_wake_mailbox_paddr =3D mailbox_paddr; + apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); +} + +struct acpi_madt_multiproc_wakeup_mailbox *acpi_get_mp_wakeup_mailbox(void) +{ + return acpi_mp_wake_mailbox; +} --=20 2.43.0 From nobody Sun Feb 8 04:23:13 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 0500B23C513; Fri, 17 Oct 2025 02:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669332; cv=none; b=ZXuJohNTPpSHZ4DdmuXI6Yg1aQ0Ejv5lYPRb/5txefryNVb0EVR/MjVDjvAqgL3uU2oEx4q1vnO1mmRRjXyB8a6mc4Ti6i+XCPsdf5tfDsKzt9og1ZOKUWYDgwJle9i+K0I+uw4fMHN1PXuH4KOheKeaoJ+jG1YKTfEIMV7NRu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669332; c=relaxed/simple; bh=oLg5R7JbaS7IswvOghRDP1lfAnfABVgOe/7DTtyNGok=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a91+eGXGLI7LPt6f9LMJPHTVNuke2PAl9avg3jUFk6ZqfNdUTkmqw9c3DQ+P/639EmHDTg885is8GRnlypf2yxgOTD73XrjWf8hTd9QJGvXTJSF8lSM1drAPKmA1hhyDzi3AVZzkg7Ag6BKgjNqUXPX9FYFzaC5yx/4OuPyjDPM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NCL9u+vQ; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NCL9u+vQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669331; x=1792205331; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=oLg5R7JbaS7IswvOghRDP1lfAnfABVgOe/7DTtyNGok=; b=NCL9u+vQ4RPwGrmbn7tlr7oGmRRI4pyHktDup4NoC/7DdvGiBt2Nndim JMiW+kacGSR/cSOpIchUFzOPyj6gbK9xe7UFqw+oXUBnCWfe0xdleJBNv XvsNy3+XjoUwIV7ieqvd8mLuDsZXsJLSzgnykoLPRep3CYlA3bdyJlh8+ F4Z1L9Ai4lwmC+xB19GoXB2kESpKwnzpbb/WDfk3aDt/ux1jAueE4FqWY wwW/U/+6RX3nNXNNA4l1WEbpIWtdroDeZQLg1dbBQUp+rfTpnJJQ+CpWE 08fEvRHZew3V5OOp9YvRlQiDgR4+89tiEeanOVJXWPwbohHmQCPT7AQfv g==; X-CSE-ConnectionGUID: hH9BGodpRWOqM7zKGh82SA== X-CSE-MsgGUID: 4JZRJ2p5Rv20aoTlNiqo4w== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321904" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321904" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:49 -0700 X-CSE-ConnectionGUID: qyNL6wq2QliefQYQ1sEBEw== X-CSE-MsgGUID: KCiAEd+eTqqVvucit5K1WA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776552" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:48 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:25 -0700 Subject: [PATCH v6 03/10] dt-bindings: reserved-memory: Wakeup Mailbox for Intel processors Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-3-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , "Rafael J. Wysocki" , Yunhong Jiang , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=5084; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=oLg5R7JbaS7IswvOghRDP1lfAnfABVgOe/7DTtyNGok=; b=CI7wjInJve2S/liRXvszC3keOnFGYoDjantzRfogHbfd6i/q5hmH3jGhCk18xquLT29Dwplpd k1G8ZdZ7aOpA1Ld7XxRzlQ/kXkJumDUKqk3T6BY4iKr2UmpSWwfjfg9 X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= Add DeviceTree bindings to enumerate the wakeup mailbox used in platform firmware for Intel processors. x86 platforms commonly boot secondary CPUs using an INIT assert, de-assert followed by Start-Up IPI messages. The wakeup mailbox can be used when this mechanism is unavailable. The wakeup mailbox offers more control to the operating system to boot secondary CPUs than a spin-table. It allows the reuse of the same wakeup vector for all CPUs while maintaining control over which CPUs to boot and when. While it is possible to achieve the same level of control using a spin-table, it would require specifying a separate `cpu-release-addr` for each secondary CPU. The operation and structure of the mailbox are described in the Multiprocessor Wakeup Structure defined in the ACPI specification. Note that this structure does not specify how to publish the mailbox to the operating system (ACPI-based platform firmware uses a separate table). No ACPI table is needed in DeviceTree-based firmware to enumerate the mailbox. Nodes that want to refer to the reserved memory usually define a `memory-region` property. /cpus/cpu* nodes would want to refer to the mailbox, but they do not have such property defined in the DeviceTree specification. Moreover, it would imply that there is a memory region per CPU. Instead, add a `compatible` property that the operating system can use to discover the mailbox. Reviewed-by: Dexuan Cui Reviewed-by: Rob Herring (Arm) Acked-by: Rafael J. Wysocki Co-developed-by: Yunhong Jiang Signed-off-by: Yunhong Jiang Signed-off-by: Ricardo Neri --- Changes since v5: - Reworded the changelog for clarity. - Added Acked-by tag from Rafael. Thanks! - Added Reviewed-by tag from Rob. Thanks! - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - Specified the version and section of the ACPI spec in which the wakeup mailbox is defined. (Rafael) - Fixed a warning from yamllint about line lengths of URLs. Changes since v3: - Removed redefinitions of the mailbox and instead referred to ACPI specification as per discussion on LKML. - Clarified that DeviceTree-based firmware do not require the use of ACPI tables to enumerate the mailbox. (Rob) - Described the need of using a `compatible` property. - Dropped the `alignment` property. (Krzysztof, Rafael) - Used a real address for the mailbox node. (Krzysztof) Changes since v2: - Implemented the mailbox as a reserved-memory node. Add to it a `compatible` property. (Krzysztof) - Explained the relationship between the mailbox and the `enable-mehod` property of the CPU nodes. - Expanded the documentation of the binding. Changes since v1: - Added more details to the description of the binding. - Added requirement a new requirement for cpu@N nodes to add an `enable-method`. --- .../reserved-memory/intel,wakeup-mailbox.yaml | 50 ++++++++++++++++++= ++++ 1 file changed, 50 insertions(+) diff --git a/Documentation/devicetree/bindings/reserved-memory/intel,wakeup= -mailbox.yaml b/Documentation/devicetree/bindings/reserved-memory/intel,wak= eup-mailbox.yaml new file mode 100644 index 000000000000..a80d3bac44c2 --- /dev/null +++ b/Documentation/devicetree/bindings/reserved-memory/intel,wakeup-mailbo= x.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/reserved-memory/intel,wakeup-mailbox.ya= ml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Wakeup Mailbox for Intel processors + +description: | + The Wakeup Mailbox provides a mechanism for the operating system to wake= up + secondary CPUs on Intel processors. It is an alternative to the INIT-!IN= IT- + SIPI sequence used on most x86 systems. + + The structure and operation of the mailbox is described in the Multiproc= essor + Wakeup Structure of the ACPI specification version 6.6 section 5.2.12.19= [1]. + + The implementation of the mailbox in platform firmware is described in t= he + Intel TDX Virtual Firmware Design Guide section 4.3.5 [2]. + + 1: https://uefi.org/specs/ACPI/6.6/05_ACPI_Software_Programming_Model.ht= ml#multiprocessor-wakeup-structure + 2: https://www.intel.com/content/www/us/en/content-details/733585/intel-= tdx-virtual-firmware-design-guide.html + + +maintainers: + - Ricardo Neri + +allOf: + - $ref: reserved-memory.yaml + +properties: + compatible: + const: intel,wakeup-mailbox + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + reserved-memory { + #address-cells =3D <2>; + #size-cells =3D <1>; + + wakeup-mailbox@ffff0000 { + compatible =3D "intel,wakeup-mailbox"; + reg =3D <0x0 0xffff0000 0x1000>; + }; + }; --=20 2.43.0 From nobody Sun Feb 8 04:23:13 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 2E5DA247295; Fri, 17 Oct 2025 02:48:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669333; cv=none; b=uCGd/vTKfV/svo9jezOiHkK538aiPooCeP9SFDxebNCJEjn591WaAVkKD/CC2HTE3Ci5+fqZFPhM+pjCmiULKX8Ti/OSIrIbOeO+5uYkx+EiGtZvdP3mZt4JSMTgYcDvPfb8NoqS0LWlwPH6enMmzQBJbAcBY0MyTas3eZyMTOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669333; c=relaxed/simple; bh=oXWsd28ZYIu8vxK+MbiTx/39CzqDc6qRRX5JmOANHeA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dGydU1PKUgEKHItxq23wIVxCzOYXNFHS+xXtVDtkhpRdxqs6LZ2pJ6mk7iaqAraCo19RhxYf1qzG0y+iZxHvcjTTSoWcyXCEeEALiib5scxP21ykXlp8sTXwMObjBul7N8i5aDFbrIfj4E8TyXud1Ot7VhbwM3LSYVbY/FcBa8o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lkZYUkvl; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lkZYUkvl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669332; x=1792205332; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=oXWsd28ZYIu8vxK+MbiTx/39CzqDc6qRRX5JmOANHeA=; b=lkZYUkvlIYkrcPnDdtEhQQL6UGcvJZhd6q13Ws/1FG9SEWw5sCjyKmp5 FxAShEUHtZNccrhO3FwXEoBT7/1di4ad+49qs/DIVnkHGbYyPuSraPwsj xvusHgP/g4eKbAB9/xBd16lqgs3u02imlwclAJCfH0SwVjxCHldnKYPKg tF5yBuxM0rLqf3eAsBuS2A61DICaGWXd5ZqXfT0LhB9h1aghztnQhCqAc V8UX3KQ+LugiMqEGXBWfSMBF/0I6tdgtMSAA8aewEXmRFEG55W/gFS3cT 7ZvXQmGziKt5x2iSdFtZuZDN+YbqZi2VVyriqbaKhH6nj/IhDEnMPpzPh w==; X-CSE-ConnectionGUID: BQEeQE35QVKqsS4YCDYgFg== X-CSE-MsgGUID: yQP8MIZFRfen9lz091Evsg== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321909" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321909" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:49 -0700 X-CSE-ConnectionGUID: rY0CYWSzTDmG6s6HC60+gw== X-CSE-MsgGUID: bGxa3S8oRE+jTvvlLT7DYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776557" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:48 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:26 -0700 Subject: [PATCH v6 04/10] x86/dt: Parse the Wakeup Mailbox for Intel processors Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-4-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Yunhong Jiang , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=4755; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=oXWsd28ZYIu8vxK+MbiTx/39CzqDc6qRRX5JmOANHeA=; b=uvwOXP6ZwXDqHgpG6xU1JjmRkOdzIemqxEhf3DWHVE/wIB0jldo5fzXjvnP8TxLAjrB3WSDZJ uFvCfQOLn+yDjZp2XuxuEwukc3ACjC2BihEjQiUsNs1D2PcMG4lrD6E X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= The Wakeup Mailbox is a mechanism to boot secondary CPUs on systems that do not want or cannot use the INIT + StartUp IPI messages. The platform firmware is expected to implement the mailbox as described in the Multiprocessor Wakeup Structure of the ACPI specification. It is also expected to publish the mailbox to the operating system as described in the corresponding DeviceTree schema that accompanies the documentation of the Linux kernel. Reuse the existing functionality to set the memory location of the mailbox and update the wakeup_secondary_cpu_64() APIC callback. Make this functionality available to DeviceTree-based systems by making CONFIG_X86_ MAILBOX_WAKEUP depend on either CONFIG_OF or CONFIG_ACPI_MADT_WAKEUP. do_boot_cpu() uses wakeup_secondary_cpu_64() when set. It will be set if a wakeup mailbox is enumerated via an ACPI table or a DeviceTree node. For cases in which this behavior is not desired, this APIC callback can be updated later during boot using platform-specific hooks. Reviewed-by: Dexuan Cui Co-developed-by: Yunhong Jiang Signed-off-by: Yunhong Jiang Signed-off-by: Ricardo Neri --- Changes since v5: - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - Made CONFIG_X86_MAILBOX_WAKEUP depend on CONFIG_OF or CONFIG_ACPI_ MADT_WAKEUP. Changes since v3: - Look for the wakeup mailbox unconditionally, regardless of whether cpu@N nodes have an `enable-method` property. - Add a reference to the ACPI specification. (Rafael) Changes since v2: - Added extra sanity checks when parsing the mailbox node. - Probe the mailbox using its `compatible` property - Setup the Wakeup Mailbox if the `enable-method` is found in the CPU nodes. - Cleaned up unneeded ifdeffery. - Clarified the mechanisms used to override the wakeup_secondary_64() callback to not use the mailbox when not desired. (Michael) - Edited the commit message for clarity. Changes since v1: - Disabled CPU offlining. - Modified dtb_parse_mp_wake() to return the address of the mailbox. --- arch/x86/Kconfig | 2 +- arch/x86/kernel/devicetree.c | 47 ++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index f57192a34a87..5a9d0b2d5174 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1110,7 +1110,7 @@ config X86_LOCAL_APIC =20 config X86_MAILBOX_WAKEUP def_bool y - depends on ACPI_MADT_WAKEUP + depends on OF || ACPI_MADT_WAKEUP depends on X86_64 depends on SMP depends on X86_LOCAL_APIC diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index dd8748c45529..494a560614a8 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -17,6 +17,7 @@ #include #include #include +#include =20 #include #include @@ -125,6 +126,51 @@ static void __init dtb_setup_hpet(void) #endif } =20 +#if defined(CONFIG_X86_64) && defined(CONFIG_SMP) + +#define WAKEUP_MAILBOX_SIZE 0x1000 +#define WAKEUP_MAILBOX_ALIGN 0x1000 + +/** dtb_wakeup_mailbox_setup() - Parse the wakeup mailbox from the device = tree + * + * Look for the presence of a wakeup mailbox in the DeviceTree. The mailbo= x is + * expected to follow the structure and operation described in the Multipr= ocessor + * Wakeup Structure of the ACPI specification. + */ +static void __init dtb_wakeup_mailbox_setup(void) +{ + struct device_node *node; + struct resource res; + + node =3D of_find_compatible_node(NULL, NULL, "intel,wakeup-mailbox"); + if (!node) + return; + + if (of_address_to_resource(node, 0, &res)) + goto done; + + /* The mailbox is a 4KB-aligned region.*/ + if (res.start & (WAKEUP_MAILBOX_ALIGN - 1)) + goto done; + + /* The mailbox has a size of 4KB. */ + if (res.end - res.start + 1 !=3D WAKEUP_MAILBOX_SIZE) + goto done; + + /* Not supported when the mailbox is used. */ + cpu_hotplug_disable_offlining(); + + acpi_setup_mp_wakeup_mailbox(res.start); +done: + of_node_put(node); +} +#else /* !CONFIG_X86_64 || !CONFIG_SMP */ +static inline int dtb_wakeup_mailbox_setup(void) +{ + return -EOPNOTSUPP; +} +#endif /* CONFIG_X86_64 && CONFIG_SMP */ + #ifdef CONFIG_X86_LOCAL_APIC =20 static void __init dtb_cpu_setup(void) @@ -287,6 +333,7 @@ static void __init x86_dtb_parse_smp_config(void) =20 dtb_setup_hpet(); dtb_apic_setup(); + dtb_wakeup_mailbox_setup(); } =20 void __init x86_flattree_get_config(void) --=20 2.43.0 From nobody Sun Feb 8 04:23:13 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 D7CE8256C9F; Fri, 17 Oct 2025 02:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669334; cv=none; b=nPzCsZN7+Uto7IKw2/y0gZsyF2xMOU2g2XrDnDwCjJCRktddDrggQkpqVN3o2EUnBAc4WJh/9c5HBlKk+wih4GKeIfcGm910/kTMOS6iIsLhMKwgwkikK1QcRnjXy58WH6YRsu+J++3XT38x0dgLEwkV1dcpp0iUUmYS12+mg3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669334; c=relaxed/simple; bh=5Wu0tzssz437M/fmfvFLdYEnIKI1oai+QjRSnwiVOd0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ed3h10ns27DvekrB2iPDaKW4cS0jNDdd2V3sMPmuTpPRXEoeF9ysc3X87XC5eiv1P21qikq9sBVbhpW9hvBtKbnj0bTSBWda39874e5oq0ZmujzoyY/01w7OcipWmR1h8Elvu/4rbWN2upyYp+tvj/Uu3TSv6pDSAOlMT2R0D34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EG6TXahp; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EG6TXahp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669333; x=1792205333; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=5Wu0tzssz437M/fmfvFLdYEnIKI1oai+QjRSnwiVOd0=; b=EG6TXahpLxnXOmCYOdlQ/sh3lNtX77Wvg7nPiK+X82uZlKK1bjPDG+q/ khLZnrH1n+6TDTf83J2qfGosNb4QkhSiKp5pVLC3jysFxekXFk/cTl+ZW 7s156A9n3Fpo5Q51dgPOrbhDIr5ywbq1ggTnYVI7NDt7RYyDPB21Q+IAQ /im+jr4JycbOfMtei+P/kctAZjUunVEYNx/cUWVU0dtweOxqMrhBMxDF1 m2kz06j/DnghMhXBWxXVjOS4kvjh7wbLZZUpbhQfidu9Z4uohsVrpb8hw xuV33GrVjtWkTESB/8iRwjxbTZ14Z3uuV6aTpLn00GIBlWV3mrGI2PrY7 Q==; X-CSE-ConnectionGUID: b9FpctpoQsOnU2e3mw3uyg== X-CSE-MsgGUID: +Rw5TLAASc62YVZ1xm9EQw== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321914" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321914" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:50 -0700 X-CSE-ConnectionGUID: ir92dcntTsm74lgP1PjvCQ== X-CSE-MsgGUID: 4KJuRnLnTM2zMGFrRPm/hg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776562" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:49 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:27 -0700 Subject: [PATCH v6 05/10] x86/hyperv/vtl: Set real_mode_header in hv_vtl_init_platform() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-5-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Yunhong Jiang , Thomas Gleixner , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=2298; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=+ekowMZ1bCY7lZxoOjoxO9xS7f2Jb/d6BCLxpG5SNTE=; b=wzpZ2fPjnkT/LQyMH1bOrbn2ElLnB4YN40/bw9t4nR13nY5qdZ4dQpASdYhzCMHF41db5Xkh8 HXv6CUz8k8lCGQpziWsrjieqMOk+yR9rFu5JbX73dTzoNX1zX1PzPuT X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= From: Yunhong Jiang Hyper-V VTL clears x86_platform.realmode_{init(), reserve()} in hv_vtl_init_platform() whereas it sets real_mode_header later in hv_vtl_early_init(). There is no need to deal with the settings of real mode memory in two places. Also, both functions are called much earlier than x86_platform.realmode_init() (via an early_initcall), where the real_mode_header is needed. Set real_mode_header in hv_vtl_init_platform() to keep all code dealing with memory for the real mode trampoline in one place. Besides making the code more readable, it prepares it for a subsequent changeset in which the behavior needs to change to support Hyper-V VTL guests in TDX a environment. Reviewed-by: Dexuan Cui Reviewed-by: Michael Kelley Suggested-by: Thomas Gleixner Signed-off-by: Yunhong Jiang Signed-off-by: Ricardo Neri --- Changes since v5: - Corrected reference to hv_vtl_init_platform() in the changelog. (Dexuan) - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - None Changes since v3: - Added Reviewed-by tag from Michael. Thanks! Changes since v2: - Edited the commit message for clarity. Changes since v1: - Introduced this patch. --- arch/x86/hyperv/hv_vtl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/hyperv/hv_vtl.c b/arch/x86/hyperv/hv_vtl.c index 042e8712d8de..e10b63b7a49f 100644 --- a/arch/x86/hyperv/hv_vtl.c +++ b/arch/x86/hyperv/hv_vtl.c @@ -65,6 +65,7 @@ void __init hv_vtl_init_platform(void) =20 x86_platform.realmode_reserve =3D x86_init_noop; x86_platform.realmode_init =3D x86_init_noop; + real_mode_header =3D &hv_vtl_real_mode_header; x86_init.irqs.pre_vector_init =3D x86_init_noop; x86_init.timers.timer_init =3D x86_init_noop; x86_init.resources.probe_roms =3D x86_init_noop; @@ -244,7 +245,6 @@ int __init hv_vtl_early_init(void) panic("XSAVE has to be disabled as it is not supported by this module.\n" "Please add 'noxsave' to the kernel command line.\n"); =20 - real_mode_header =3D &hv_vtl_real_mode_header; apic_update_callback(wakeup_secondary_cpu_64, hv_vtl_wakeup_secondary_cpu= ); =20 return 0; --=20 2.43.0 From nobody Sun Feb 8 04:23:13 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 0EB592580F3; Fri, 17 Oct 2025 02:48:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669335; cv=none; b=oiW0r6ZK3K80iLyXAYXejrZbJu4qjT1TW1p93tXXVQvhIlY7fts5TJ/aJPScHZcOaTXHw9LDB4tmMeKfRmaMHhLzxiF3EkU22r9dX2cVf7dy4/tg1sbw1MzzaxsU48gdgj93nLK9otinh/noQ6LxX6+USr319Yd0iP1xKwutZHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669335; c=relaxed/simple; bh=DeJzn/2MLyfQfhOYgPps5Tvmb93NuC81Q2Ua9386CMI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KjsRvF8dp1VBsGVRQw7g268kweZDuWi+tLYze3VsK4+aeN2phM08liihrjx03xHZ7NWzHy/7trViRUGd1LsoBlDBY6GA4wYaEhBCP7yMpeojdPrYQnMNv9vftgM6ilyneEwN2mbQrXYqmAFOyfTHXXFlVbU8aBvMeC/EPIVIwo0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=JB6H5wgt; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JB6H5wgt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669334; x=1792205334; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=DeJzn/2MLyfQfhOYgPps5Tvmb93NuC81Q2Ua9386CMI=; b=JB6H5wgtaR0MEpek4PoJYEYgZYF0NzGd3NE9LQbykFf3YkdRlN+RfN1k Tk6fPASUVkhn2Epm9i6Ud5/RNBAGJ14W4ScdOsI/sEFwDeVcZfml5tlzK IDcpeasGxUm5MMDRiU1LWNC5T+S7mXfoLS6P/dfy++Bo+JSW+Uwn56irU R7AcXZJ/vbFXN2G7P1UbmMWPTxEs4gkgXHnrS5zBotPtIpDKwOlIW1Qqh UD9jjkGIt473ToBTuD0LQhf9YBmIBXqHU4wlZRe5NR19oz472IxS2YtB2 W99AyUe+OYjELyGbXho1w31wcXRFlDPcDlIDKKowKBLQbIKF/jm+54Q+q w==; X-CSE-ConnectionGUID: Bal3VBUPQHejUySIl93XQQ== X-CSE-MsgGUID: lOpanzbOSIyPi5FxjqAcsw== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321921" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321921" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:50 -0700 X-CSE-ConnectionGUID: VJj+24f7RLiwKgo5DBzSQg== X-CSE-MsgGUID: sjyNK5HBS0SPLx+rYCJGLA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776567" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:49 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:28 -0700 Subject: [PATCH v6 06/10] x86/realmode: Make the location of the trampoline configurable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-6-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Yunhong Jiang , Thomas Gleixner , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=3954; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=oL1YhWY/xGIk9t6USOhIG8l08ECXRGdJqyRJsOKl2CY=; b=qKhMO51qHmMJ+tfxM0h06tffd16MXjS6/Ug3OnES7XvGAbvGYRXbCG07YaWwZjz83J6h+CV/h 9ygeo7A9VeGAwoIDiRsQUiZgqO9pRv9jtZK0hWiXktj0/rWV4SEOscr X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= From: Yunhong Jiang x86 CPUs boot in real mode. This mode uses a 1MB address space. The trampoline must reside below this 1MB memory boundary. There are platforms in which the firmware boots the secondary CPUs, switches them to long mode and transfers control to the kernel. An example of such a mechanism is the ACPI Multiprocessor Wakeup Structure. In this scenario there is no restriction on locating the trampoline under 1MB memory. Moreover, certain platforms (for example, Hyper-V VTL guests) may not have memory available for allocation below 1MB. Add a new member to struct x86_init_resources to specify the upper bound for the location of the trampoline memory. Preserve the default upper bound of 1MB to conserve the current behavior. Reviewed-by: Dexuan Cui Reviewed-by: Michael Kelley Originally-by: Thomas Gleixner Signed-off-by: Yunhong Jiang Signed-off-by: Ricardo Neri --- Changes since v5: - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - None Changes since v3: - Added Reviewed-by tag from Michael. Thanks! Changes since v2: - Edited the commit message for clarity. - Minor tweaks to comments. - Removed the option to not reserve the first 1MB of memory as it is not needed. Changes since v1: - Added this patch using code that Thomas suggested: https://lore.kernel.org/lkml/87a5ho2q6x.ffs@tglx/ --- arch/x86/include/asm/x86_init.h | 3 +++ arch/x86/kernel/x86_init.c | 3 +++ arch/x86/realmode/init.c | 7 +++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_ini= t.h index 36698cc9fb44..e770ce507a87 100644 --- a/arch/x86/include/asm/x86_init.h +++ b/arch/x86/include/asm/x86_init.h @@ -31,12 +31,15 @@ struct x86_init_mpparse { * platform * @memory_setup: platform specific memory setup * @dmi_setup: platform specific DMI setup + * @realmode_limit: platform specific address limit for the real mode tra= mpoline + * (default 1M) */ struct x86_init_resources { void (*probe_roms)(void); void (*reserve_resources)(void); char *(*memory_setup)(void); void (*dmi_setup)(void); + unsigned long realmode_limit; }; =20 /** diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index 0a2bbd674a6d..a25fd7282811 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c @@ -9,6 +9,7 @@ #include #include #include +#include =20 #include #include @@ -69,6 +70,8 @@ struct x86_init_ops x86_init __initdata =3D { .reserve_resources =3D reserve_standard_io_resources, .memory_setup =3D e820__memory_setup_default, .dmi_setup =3D dmi_setup, + /* Has to be under 1M so we can execute real-mode AP code. */ + .realmode_limit =3D SZ_1M, }, =20 .mpparse =3D { diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c index 88be32026768..694d80a5c68e 100644 --- a/arch/x86/realmode/init.c +++ b/arch/x86/realmode/init.c @@ -46,7 +46,7 @@ void load_trampoline_pgtable(void) =20 void __init reserve_real_mode(void) { - phys_addr_t mem; + phys_addr_t mem, limit =3D x86_init.resources.realmode_limit; size_t size =3D real_mode_size_needed(); =20 if (!size) @@ -54,10 +54,9 @@ void __init reserve_real_mode(void) =20 WARN_ON(slab_is_available()); =20 - /* Has to be under 1M so we can execute real-mode AP code. */ - mem =3D memblock_phys_alloc_range(size, PAGE_SIZE, 0, 1<<20); + mem =3D memblock_phys_alloc_range(size, PAGE_SIZE, 0, limit); if (!mem) - pr_info("No sub-1M memory is available for the trampoline\n"); + pr_info("No memory below %pa for the real-mode trampoline\n", &limit); else set_real_mode_mem(mem); =20 --=20 2.43.0 From nobody Sun Feb 8 04:23:13 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 4070425A320; Fri, 17 Oct 2025 02:48:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669335; cv=none; b=oTfKJsNkB6l75MvqUVlwTrofZRvQ/ViqrjNShYdxHpizN3qJIiPTRzS5zhjaL8mG2qbeYv33cLJG+EXdUMHXelK+zzkO40oB59lcayGf3kiOVyv1d42eJr+jobVR0mINSjkXgeQn3zd5V/9fVI5XasCXQhHCB9tus4zpwto4DTI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669335; c=relaxed/simple; bh=xiKk6PO3Wpl8posmb05B0wVCazkFXgFrrqCFTGy0Tv4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VVucGo+f3SXCJ3UbcYcUdhHKiQ0MRqF1vX0IBXuXDUc0rUNT7pmfX5m73SC8mSOKA07FCWcL/mOKIEvJaLFDfBTxH4EeE2vqIn0WtqKMDzVjdZ9QW77c2H31YFtc9Ua0OSScsfRf37IFiQBPqnghjfiyPEEYAwwrECsJoK/G6i0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Hk7SIsqO; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Hk7SIsqO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669334; x=1792205334; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=xiKk6PO3Wpl8posmb05B0wVCazkFXgFrrqCFTGy0Tv4=; b=Hk7SIsqOCQnp5H0BW3+0s8ha/q4P1jlKyt/T56JSVCjE/6K//EXMfZL8 Y3PXrVE94z/uboY3dm9SxFRi3Ns/hgX+hEnbpjeAY4NKbhnQFKWu67Lra sRWMYrNWDbyNryB45/S9BssHEbYp19HyXLrJw/LrvlmKgYVLo985MhmQC obRbMfAytNJIT6758rJJYxcdGX/4jHZT/jxsSVXC/GGTe6CXaC5lnbCQE AffOdO+1Me2m0I1QV6yznB/yVWz8oDeS/HpDqOHrfhUJVLNRqBT4omng4 i4Grteg4rUnx+YwJauxjVC1BI94hgxab/orpD6yv8nIYBSMVkKzTZAM4j A==; X-CSE-ConnectionGUID: UhehunfsRDyuVp5+RWmBKg== X-CSE-MsgGUID: siuSAB/cQwu5+mOoT5CtUQ== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321927" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321927" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:51 -0700 X-CSE-ConnectionGUID: 2V3QgfLHQ6m1/C+i/ZNj+g== X-CSE-MsgGUID: wagtWPxbSBOMo8cn5jyL9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776571" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:50 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:29 -0700 Subject: [PATCH v6 07/10] x86/hyperv/vtl: Setup the 64-bit trampoline for TDX guests Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-7-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Yunhong Jiang , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=2679; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=MBLpaX0bjtX22TSisCsj/ncNkao4eO5cxcCqH/6INlg=; b=IDF/ylbPdJDayXs+OHBmUFyPJDtuqLGBBk34ZMwIRKaEzUeJNmwBL4iwjSPKXP+giVZhEQSJb FxOJwqBO0DYD7HIP5eLGk1njXSAe8/OPGMd70N/VxsTQ4DPD1a0TRtY X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= From: Yunhong Jiang The hypervisor is an untrusted entity for TDX guests. It cannot be used to boot secondary CPUs - neither via hypercalls nor the INIT assert, de-assert, plus Start-Up IPI messages. Instead, the platform virtual firmware boots the secondary CPUs and puts them in a state to transfer control to the kernel. This mechanism uses the wakeup mailbox described in the Multiprocessor Wakeup Structure of the ACPI specification. The entry point to the kernel is trampoline_start64. Allocate and setup the trampoline using the default x86_platform callbacks. The platform firmware configures the secondary CPUs in long mode. It is no longer necessary to locate the trampoline under 1MB memory. After handoff from firmware, the trampoline code switches briefly to 32-bit addressing mode, which has an addressing limit of 4GB. Set the upper bound of the trampoline memory accordingly. Reviewed-by: Dexuan Cui Reviewed-by: Michael Kelley Signed-off-by: Yunhong Jiang Signed-off-by: Ricardo Neri --- Changes since v5: - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - None Changes since v3: - Added Reviewed-by tag from Michael. Thanks! Changes since v2: - Added a note regarding there is no need to check for a present paravisor. - Edited commit message for clarity. Changes since v1: - Dropped the function hv_reserve_real_mode(). Instead, used the new members realmode_limit and reserve_bios members of x86_init to set the upper bound of the trampoline memory. (Thomas) --- arch/x86/hyperv/hv_vtl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/hyperv/hv_vtl.c b/arch/x86/hyperv/hv_vtl.c index e10b63b7a49f..ca0d23206e67 100644 --- a/arch/x86/hyperv/hv_vtl.c +++ b/arch/x86/hyperv/hv_vtl.c @@ -63,9 +63,14 @@ void __init hv_vtl_init_platform(void) */ pr_info("Linux runs in Hyper-V Virtual Trust Level %d\n", ms_hyperv.vtl); =20 - x86_platform.realmode_reserve =3D x86_init_noop; - x86_platform.realmode_init =3D x86_init_noop; - real_mode_header =3D &hv_vtl_real_mode_header; + /* There is no paravisor present if we are here. */ + if (hv_isolation_type_tdx()) { + x86_init.resources.realmode_limit =3D SZ_4G; + } else { + x86_platform.realmode_reserve =3D x86_init_noop; + x86_platform.realmode_init =3D x86_init_noop; + real_mode_header =3D &hv_vtl_real_mode_header; + } x86_init.irqs.pre_vector_init =3D x86_init_noop; x86_init.timers.timer_init =3D x86_init_noop; x86_init.resources.probe_roms =3D x86_init_noop; --=20 2.43.0 From nobody Sun Feb 8 04:23:13 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 E964726FDBF; Fri, 17 Oct 2025 02:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669336; cv=none; b=hubuNCREpAHg4pGAcH8Eq2wA+FPgmaGj18Qg8GF/OIfJ//SUodtDumq11pIfMwP4S6oEBntgX2+tYM+MjyKExJ7XjVud6NBZ977DJbNZWN8SI6W/ihA3AOewUoQiZrNfPOe/eaLMDY6q46zcyH7+4sNyNmKcZA19JiOKtCaUyb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669336; c=relaxed/simple; bh=K/5U2Qk8R/cIAFnRILyVEin1gfN+/w6yMlS9Y9x1rfw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=icrclZMOJ4BqWFlJWCBbO/D0h2glU7ue/fII+BQe3FDUmJgcgkV+tYHWyOHKLJHCn8KN1N1Q7ywEx8DYolSuV1Lf0rjU+a2A6MbbNLpJ91StWCeZsu9rbwuHvI8wX7oKJCbA53lsYec6QLRmmKUnaYicrQzT+hcbbbsBJfiLhPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GOXd/PhW; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GOXd/PhW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669335; x=1792205335; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=K/5U2Qk8R/cIAFnRILyVEin1gfN+/w6yMlS9Y9x1rfw=; b=GOXd/PhWAC3srKPUFKVECJGxTVAye7QP3v6fsqjHALIcrAbJWdQWiOXU gqKo+CGDiD8Zd0JXB8Zp4gFZXsDVoc5RbtIgLILah8TDaSK2CaDAh/ugu Rv/KNayk8njQvrNXshCbEi/d3xKLvi9N0vylCjQ7SmmPnbctJNDZxXIAi +pWQrz7YfYtb/DfPg5IVns2qOdI9t6QE0JmAYDweAg4QXNXI6+piJZw3T jJh6RdQZ0SPLfQtx/eTXPgZhJsK2eEGqbAIehnuOvKr191jO3eSpCXSwm 1g5U735t/KTjVmaA7ZLXEoOihsxP+8yCDdcC9JqbTNWO9kzWfLno1BIa/ w==; X-CSE-ConnectionGUID: WnIfTquTTDSHCXGGG4LpMA== X-CSE-MsgGUID: QXw8e+C5S/+OaEXJYdyR5Q== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321932" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321932" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:51 -0700 X-CSE-ConnectionGUID: 7qWtohq3T8K7TA5tHC14hA== X-CSE-MsgGUID: jkpZZNQ9TCaZdtJdtnseKw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776575" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:50 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:30 -0700 Subject: [PATCH v6 08/10] x86/smpwakeup: Add a helper get the address of the wakeup mailbox Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-8-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=1835; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=K/5U2Qk8R/cIAFnRILyVEin1gfN+/w6yMlS9Y9x1rfw=; b=JeXwHHzKBw2NIblS/o5uV7qNHOeHVrmvG2V4Lp2RQoYAProTTAbanpIgZWA7Gko05pahnUmrx AtaJGjTHQhHDfI4A3tapBgPCxYUMpOjK4/jn7mPpzn0Yw4F+UG+feYc X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= A Hyper-V VTL level 2 guest in a TDX environment needs to map the physical page of the ACPI Multiprocessor Wakeup Structure as private (encrypted). It needs to know the physical address of this structure. Add a helper function to retrieve the address. Reviewed-by: Dexuan Cui Reviewed-by: Michael Kelley Suggested-by: Michael Kelley Signed-off-by: Ricardo Neri --- Changes since v5: - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - None Changes since v3: - Renamed function to acpi_get_mp_wakeup_mailbox_paddr(). - Added Reviewed-by tag from Michael. Thanks! Changes since v2: - Introduced this patch Changes since v1: - N/A --- arch/x86/include/asm/smp.h | 1 + arch/x86/kernel/smpwakeup.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index 47ac4381a805..71de1963f984 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -151,6 +151,7 @@ static inline struct cpumask *cpu_l2c_shared_mask(int c= pu) =20 void acpi_setup_mp_wakeup_mailbox(u64 addr); struct acpi_madt_multiproc_wakeup_mailbox *acpi_get_mp_wakeup_mailbox(void= ); +u64 acpi_get_mp_wakeup_mailbox_paddr(void); =20 #else /* !CONFIG_SMP */ #define wbinvd_on_cpu(cpu) wbinvd() diff --git a/arch/x86/kernel/smpwakeup.c b/arch/x86/kernel/smpwakeup.c index 5089bcda615d..f730a66b6fc8 100644 --- a/arch/x86/kernel/smpwakeup.c +++ b/arch/x86/kernel/smpwakeup.c @@ -81,3 +81,8 @@ struct acpi_madt_multiproc_wakeup_mailbox *acpi_get_mp_wa= keup_mailbox(void) { return acpi_mp_wake_mailbox; } + +u64 acpi_get_mp_wakeup_mailbox_paddr(void) +{ + return acpi_mp_wake_mailbox_paddr; +} --=20 2.43.0 From nobody Sun Feb 8 04:23:13 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 2B8212750E6; Fri, 17 Oct 2025 02:48:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669337; cv=none; b=UDEN6fSvbHGzWJfMkX2NFpTfMwTKUm1siVb5usTK+DCuGMbNaoInFqcKV/WHa1G2Qc9UiGUe02uJFQAMTBa7ljOH1cmR8kkEknYl5bLzmgCcUmQcZXelWRl9+shAt/uNJU1Jxeppy3T9LbjK/zctV4gidGl6W0fRwRA2gpMAIJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669337; c=relaxed/simple; bh=rfgYQakiB6rXGq79UY0s3nHmlF8j120ioeVCexCocIQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LIki5KaCejwsF8iCeyiYbzxjB8rpO30Nn4DBGGkfzyNCSxtHg58tSnFGMj6D8AY03p4752pEvnlrXJMk0W//bTpVeSD9P9TyljTt9nF5jdIf9IxvpeVhNKlo4L0bj8IPT/vi/jCp2rFqFF1/a2M2VDJweu9wx7K1+o3BzTcW1gE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XaoHHw2V; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XaoHHw2V" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669336; x=1792205336; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=rfgYQakiB6rXGq79UY0s3nHmlF8j120ioeVCexCocIQ=; b=XaoHHw2VCVHWqh45/WshKf4Ej8awk8Gn7o5kDrF69V2tHexunE6jHN+A Ux5gFGTS5nNVd8gYewqoYvhC/jqD5FL8ELbnea1xRbBnR2bnHHorFHoJl X6IPZYnSN0UyARgJHmpSU6VJXWB0jz0QlDxdkAq1gWXT72OjO0UOKAzyY FRKS7NDCAogSAA9hCJg9dXOxoHJ0QsXmZg+7PQ6DJFlsyZdpLjDzUZz+h UDRGHCfYG5H9g/6pivb1XBBG1Ox3U27jiUYdVZCW11OsArwKxVB7XZQkf tJtPzEKbCuADMAV76yWWCPWsLPt8Ls1mcPTM4pGe9CdSkK7pVD+YtcEsD g==; X-CSE-ConnectionGUID: GeipHbbxSvCUSi/Vx+AUgA== X-CSE-MsgGUID: MAbifTXKQhicm3cAMNM0xA== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321937" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321937" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:51 -0700 X-CSE-ConnectionGUID: 7TaZSx59SB+i2ybbWi2e2w== X-CSE-MsgGUID: kNyEf4tZQIiupUCdv1q0sg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776580" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:50 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:31 -0700 Subject: [PATCH v6 09/10] x86/hyperv/vtl: Mark the wakeup mailbox page as private Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-9-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Yunhong Jiang , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=2530; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=sCXBCSStHR5KXeSPe/oKcOxoQ5zJM21CUHF9SXzLUIw=; b=oVA33jRldgvUCBMVyH+M5hYlIlAsU81WPVMCWJ6+IabcR7rouVOHUeInnhC0d50XUhEMl0iYU js/p7DUtOOgCQAlTg5s1fBfrrK+jXDtmGJwKzpFNGFvVI8eYjgsC1Pr X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= From: Yunhong Jiang The current code maps MMIO devices as shared (decrypted) by default in a confidential computing VM. In a TDX environment, secondary CPUs are booted using the Multiprocessor Wakeup Structure defined in the ACPI specification. The virtual firmware and the operating system function in the guest context, without intervention from the VMM. Map the physical memory of the mailbox as private. Use the is_private_mmio() callback. Reviewed-by: Dexuan Cui Reviewed-by: Michael Kelley Signed-off-by: Yunhong Jiang Signed-off-by: Ricardo Neri --- Changes since v5: - Fixed a compile error with !CONFIG_X86_MAILBOX_WAKEUP. - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - None Changes since v3: - Updated to use the renamed function acpi_get_mp_wakeup_mailbox_paddr(). - Added Reviewed-by tag from Michael. Thanks! Changes since v2: - Use the new helper function get_mp_wakeup_mailbox_paddr(). - Edited the commit message for clarity. Changes since v1: - Added the helper function within_page() to improve readability - Override the is_private_mmio() callback when detecting a TDX environment. The address of the mailbox is checked in hv_is_private_mmio_tdx(). --- arch/x86/hyperv/hv_vtl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/x86/hyperv/hv_vtl.c b/arch/x86/hyperv/hv_vtl.c index ca0d23206e67..4a15de4d5ec2 100644 --- a/arch/x86/hyperv/hv_vtl.c +++ b/arch/x86/hyperv/hv_vtl.c @@ -54,6 +54,22 @@ static void __noreturn hv_vtl_restart(char __maybe_unus= ed *cmd) hv_vtl_emergency_restart(); } =20 +static inline bool within_page(u64 addr, u64 start) +{ + return addr >=3D start && addr < (start + PAGE_SIZE); +} + +static bool hv_vtl_is_private_mmio_tdx(u64 addr) +{ + if (IS_ENABLED(CONFIG_X86_MAILBOX_WAKEUP)) { + u64 mb_addr =3D acpi_get_mp_wakeup_mailbox_paddr(); + + return mb_addr && within_page(addr, mb_addr); + } + + return false; +} + void __init hv_vtl_init_platform(void) { /* @@ -66,6 +82,8 @@ void __init hv_vtl_init_platform(void) /* There is no paravisor present if we are here. */ if (hv_isolation_type_tdx()) { x86_init.resources.realmode_limit =3D SZ_4G; + x86_platform.hyper.is_private_mmio =3D hv_vtl_is_private_mmio_tdx; + } else { x86_platform.realmode_reserve =3D x86_init_noop; x86_platform.realmode_init =3D x86_init_noop; --=20 2.43.0 From nobody Sun Feb 8 04:23:13 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 38FEE2765DF; Fri, 17 Oct 2025 02:48:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669337; cv=none; b=uzZ4d9TEKvce04d4nFLmr03tNgvr77Vu5mHq//9iN9zzoUiFauISz1VMI8qwHT4bSBtUZR0ryKltiky4V7whgkLZBppiTPGGaQ19kMN5a0r2x0b1nsQeq7tIY1EdyRie0LBlMiLpn8514gglMto3aU7I5XhjOV1y5HuvacnjtEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669337; c=relaxed/simple; bh=+KpwtyxJeSfj6pWERQrqIeuq+GTH4DEu4+tOmXkA/Mk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P5vV67V9fGdUEsYX7lhz9RqTLkCd1QuYViqbz8LNx9xNktggM1dwXn0Fii2IDeTz5IK7JlKqUibpuCLUOSPuC347a+qexiysajOEHMc3IeHJ9X0gLqLHhS0ywe+xVBZ5zGTa9rMT1L0x5gcBhqpy0GsW1vgW0MZNnkC3gLagXJM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=csZCCPVi; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="csZCCPVi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669336; x=1792205336; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=+KpwtyxJeSfj6pWERQrqIeuq+GTH4DEu4+tOmXkA/Mk=; b=csZCCPVi9mxmYXpGC48Fv50QwIdkt4a0+CaioDZMFHG6J1D2yY067KVo InMtG1PCRG4qmfiGmsUt3xvE1S9st5RzvaKpjjb8czgp87bR3bMc3NUKc Lf/9smVCZPY2wQHIJLT8/9loOhljYiH7lFMHB9tQ1Xh0rQ+LPrsxUsEXj v+chiimd7vBcN2+V4Y25h4J1turDov3sNpSyE5VUYGEfIiGzYn2g07q5A H6wP7A3MKyB/UXbZvTtiMT537Pu3qgqb/TvoEmYlQB2vI6a7UxhiLO+Yg DWkkR5AlNfPasqJ2pZwqN0SXlSivbPy2qpAPGvWPZrvzb6Tvy5/KiOITW A==; X-CSE-ConnectionGUID: ndk+8wwwQs61g9ph58McQQ== X-CSE-MsgGUID: 3UoOmu/cT3qKXU6oxKaDMA== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321943" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321943" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:52 -0700 X-CSE-ConnectionGUID: 82sa8zURT06iVZCaD2ZeVg== X-CSE-MsgGUID: zg8ovszQRze/jYnxfxqwOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776587" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:51 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:32 -0700 Subject: [PATCH v6 10/10] x86/hyperv/vtl: Use the wakeup mailbox to boot secondary CPUs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-10-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=1993; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=+KpwtyxJeSfj6pWERQrqIeuq+GTH4DEu4+tOmXkA/Mk=; b=hwZ7BhzWn6VmkFX9QjrX58N7CABFCsTIXACm3eKIoC2mXPqWoS1xEGE5bxiJJTDwC3aL85ivn q7ZIekMtslUAIICV5TsuR41eTapQ+O+sHdogpHuTCHyTJCvH1dM20sf X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= The hypervisor is an untrusted entity for TDX guests. It cannot be used to boot secondary CPUs. The function hv_vtl_wakeup_secondary_cpu() cannot be used. Instead, the virtual firmware boots the secondary CPUs and places them in a state to transfer control to the kernel using the wakeup mailbox. The firmware enumerates the mailbox via either an ACPI table or a DeviceTree node. If the wakeup mailbox is present, the kernel updates the APIC callback wakeup_secondary_cpu_64() to use it. Reviewed-by: Dexuan Cui Reviewed-by: Michael Kelley Signed-off-by: Ricardo Neri --- Changes since v5: - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - None Changes since v3: - Added Reviewed-by tag from Michael. Thanks! Changes since v2: - Unconditionally use the wakeup mailbox in a TDX confidential VM. (Michael). - Edited the commit message for clarity. Changes since v1: - None --- arch/x86/hyperv/hv_vtl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/hyperv/hv_vtl.c b/arch/x86/hyperv/hv_vtl.c index 4a15de4d5ec2..e866e643b66c 100644 --- a/arch/x86/hyperv/hv_vtl.c +++ b/arch/x86/hyperv/hv_vtl.c @@ -268,7 +268,15 @@ int __init hv_vtl_early_init(void) panic("XSAVE has to be disabled as it is not supported by this module.\n" "Please add 'noxsave' to the kernel command line.\n"); =20 - apic_update_callback(wakeup_secondary_cpu_64, hv_vtl_wakeup_secondary_cpu= ); + /* + * TDX confidential VMs do not trust the hypervisor and cannot use it to + * boot secondary CPUs. Instead, they will be booted using the wakeup + * mailbox if detected during boot. See setup_arch(). + * + * There is no paravisor present if we are here. + */ + if (!hv_isolation_type_tdx()) + apic_update_callback(wakeup_secondary_cpu_64, hv_vtl_wakeup_secondary_cp= u); =20 return 0; } --=20 2.43.0