Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Apr 2026 15:04:27 +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: bba179b0aac1 - stable/15 - msi: Support APIC Extended Destination IDs
Message-ID:  <69e0fa7b.1e7d9.454690e2@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by cperciva:

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

commit bba179b0aac1da000707f0f5d5de8670d0a529a5
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2026-02-22 04:08:59 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-04-16 15:03:59 +0000

    msi: Support APIC Extended Destination IDs
    
    If APIC Extended Destination ID support is enabled, use it in MSIs by
    allowing APIC IDs up to 2^15 - 1 and encoding the high bits into
    Intel "reserved" bits per the standard.
    
    Tested on:      EC2 r8i.96xlarge
    MFC after:      3 weeks
    Sponsored by:   Amazon
    Differential Revision:  https://reviews.freebsd.org/D55426
    
    (cherry picked from commit 02f29c1324cf5193c3aec181cb409917b541f7fe)
---
 sys/x86/x86/msi.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/x86/x86/msi.c b/sys/x86/x86/msi.c
index 9d5a51f9753c..9ecdfca3e01b 100644
--- a/sys/x86/x86/msi.c
+++ b/sys/x86/x86/msi.c
@@ -92,6 +92,10 @@
 #define	INTEL_ADDR(msi)							\
 	(MSI_INTEL_ADDR_BASE | (msi)->msi_cpu << 12 |			\
 	    MSI_INTEL_ADDR_RH_OFF | MSI_INTEL_ADDR_DM_PHYSICAL)
+#define	INTEL_ADDR_EXT(msi)						\
+	(MSI_INTEL_ADDR_BASE | ((msi)->msi_cpu & 0xff) << 12 |		\
+	((msi)->msi_cpu & 0x7f00) >> 3 |				\
+	    MSI_INTEL_ADDR_RH_OFF | MSI_INTEL_ADDR_DM_PHYSICAL)
 #define	INTEL_DATA(msi)							\
 	(MSI_INTEL_DATA_TRGREDG | MSI_INTEL_DATA_DELFIXED | (msi)->msi_vector)
 
@@ -644,13 +648,16 @@ msi_map(int irq, uint64_t *addr, uint32_t *data)
 	mtx_unlock(&msi_lock);
 	error = EOPNOTSUPP;
 #endif
-	if (error == EOPNOTSUPP && msi->msi_cpu > 0xff) {
+	if (error == EOPNOTSUPP &&
+	    (msi->msi_cpu > 0x7fff ||
+	     (msi->msi_cpu > 0xff && apic_ext_dest_id != 1))) {
 		printf("%s: unsupported destination APIC ID %u\n", __func__,
 		    msi->msi_cpu);
 		error = EINVAL;
 	}
 	if (error == EOPNOTSUPP) {
-		*addr = INTEL_ADDR(msi);
+		*addr = (apic_ext_dest_id == 1) ?
+		    INTEL_ADDR_EXT(msi) : INTEL_ADDR(msi);
 		*data = INTEL_DATA(msi);
 		error = 0;
 	}


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e0fa7b.1e7d9.454690e2>