RE: [PATCH v2 3/3] ACPI: RIMT: validate mapping references and ID arithmetic
From: Gary Beihl
Date: Thu Dec 03 2026 - 13:46:28 EST
On Thu, Aug 13, 2026, Pengpeng Hou wrote:
> Treat num_ids as the number of IDs, use subtraction for source-range
> membership, and reject destination-ID addition overflow.
This also fixes a real failure, not only a malformed-table case.
RIMT v1.0 Table 6 defines Number of IDs as a count ("Number of IDs in
the range"), but rimt_id_map() in mainline treats it as an inclusive
bound, so each mapping range accepts one ID past its end. With a PCIe
IOMMU at 00:02.0 (RID 0x10) and root complex mappings that skip the
IOMMU's own RID:
Source ID Base 0x0000, Number of IDs 0x0010 -> IOMMU
Source ID Base 0x0011, Number of IDs 0xffef -> IOMMU
the first range also matches RID 0x10, the IOMMU is configured as
sitting behind itself, its probe never completes, and the NVMe behind
it never probes.
Tested on QEMU 11 virt (rva23s64, 4 harts, -device riscv-iommu-pci,
NVMe at 00:01.0) with EDK2 DynamicTablesPkg firmware that emits the
RIMT with the spec's count, on v7.4-rc5:
- v7.4-rc5 as is: riscv-iommu-pci and nvme both stay unbound, no
/dev/nvme0n1.
- v7.4-rc5 + this series (1-3): iommu_pci binds 00:02.0, 00:00.0 and
00:01.0 are added to IOMMU groups, nvme probes and the disk reads
back correctly.
Tested-by: Gary Beihl <garybeihl@xxxxxxxxxxxxx>
Thanks,
Gary