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
This commit is contained in:
Colin Percival committed 2026-03-27 22:54:17 -07:00
1 parent d9db6d759d
commit 02f29c1324
1 file changed
+9 -2
+9 -2
View File
@@ -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)
@@ -652,13 +656,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;
}