Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Apr 2026 15:12:19 +0000
From:      Colin Percival <cperciva@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 70be695384d9 - stable/14 - x86: Add stub for Extended Destination ID support
Message-ID:  <69e0fc53.1e997.2fbdb37b@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=70be695384d917f3ce2645b383fa9db6ccf8b0ca

commit 70be695384d917f3ce2645b383fa9db6ccf8b0ca
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2026-03-16 23:37:04 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-04-16 15:11:54 +0000

    x86: Add stub for Extended Destination ID support
    
    Without an IOMMU, the APIC standard only allows 8 bits of Destination
    ID for MSI messages, limiting us to 256 CPUs.  While IOMMUs can allow
    for more than 256 CPUs to be supported, they are not necessarily
    desirable in virtualized environments.
    
    The Extended Destination ID standard authored by David Woodhouse uses
    7 "Reserved" bits for the high bits of a 15-bit Extended Destination
    ID in order to address this: http://david.woodhou.se/ExtDestId.pdf
    
    Add a loader tunable machdep.apic_ext_dest_id to control the use of
    this feature; the default value (-1) means "autodetect" while 0 and
    1 mean disabled and enabled respectively.
    
    Code to detect host support in Xen, Hyper-V, KVM, and Bhyve will come
    in future commits, as will the code to use this setting in msi_map and
    ioapic_program_intpin.
    
    Tested on:      EC2 r8i.96xlarge
    MFC after:      3 weeks
    Sponsored by:   Amazon
    Differential Revision:  https://reviews.freebsd.org/D55890
    
    (cherry picked from commit d9db6d759dfcf4a4559e66e777599bb3fa8ca14c)
---
 sys/x86/include/apicvar.h |  1 +
 sys/x86/x86/local_apic.c  | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/sys/x86/include/apicvar.h b/sys/x86/include/apicvar.h
index 61c726f150df..bb2986c3bf67 100644
--- a/sys/x86/include/apicvar.h
+++ b/sys/x86/include/apicvar.h
@@ -262,6 +262,7 @@ device_t ioapic_get_dev(u_int apic_id);
 
 extern int x2apic_mode;
 extern int lapic_eoi_suppression;
+extern int apic_ext_dest_id;
 
 #ifdef _SYS_SYSCTL_H_
 SYSCTL_DECL(_hw_apic);
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 2efa0b9b5c1d..063ba0d43686 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -1925,6 +1925,17 @@ apic_setup_local(void *dummy __unused)
 }
 SYSINIT(apic_setup_local, SI_SUB_CPU, SI_ORDER_SECOND, apic_setup_local, NULL);
 
+/* Are we in a VM which supports the Extended Destination ID standard? */
+int apic_ext_dest_id = -1;
+SYSCTL_INT(_machdep, OID_AUTO, apic_ext_dest_id, CTLFLAG_RDTUN, &apic_ext_dest_id, 0,
+    "Use APIC Extended Destination IDs");
+
+/* Detect support for Extended Destination IDs. */
+static void
+detect_extended_dest_id(void)
+{
+}
+
 /*
  * Setup the I/O APICs.
  */
@@ -1936,6 +1947,10 @@ apic_setup_io(void *dummy __unused)
 	if (best_enum == NULL)
 		return;
 
+	/* Check hypervisor support for extended destination IDs. */
+	if (apic_ext_dest_id == -1)
+		detect_extended_dest_id();
+
 	/*
 	 * Local APIC must be registered before other PICs and pseudo PICs
 	 * for proper suspend/resume order.


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e0fc53.1e997.2fbdb37b>