git: d713a8192588 - releng/15.2 - bhyve/riscv: fix PCIe FDT interrupt-map entry stride

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Fri, 20 Nov 2026 00:10:07 UTC
The branch releng/15.2 has been updated by cperciva:

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

commit d713a8192588cb5e467cf4b2ea4507e70cf91635
Author:     Doongar Singh <doonbsd@gmail.com>
AuthorDate: 2026-11-13 12:35:14 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-11-20 00:09:51 +0000

    bhyve/riscv: fix PCIe FDT interrupt-map entry stride
    
    In bhyve arm64, each PCIe interrupt-map entry spans 10 cells because the
    ARM GIC specifies #interrupt-cells = 3. On RISC-V, the APLIC uses
    #interrupt-cells = 2, so each entry spans only 9 cells.
    
    When the PCIe FDT code was originally adapted from arm64, the property
    allocation size and cell assignments were reduced to 9 cells per entry,
    but the loop multiplier retained the 10-cell stride. This caused the
    interrupt-map array to be packed incorrectly with gaps, breaking PCI
    interrupt routing in guest operating systems and overflowing the
    allocation by 16 cells.
    
    Correct the loop stride to 9 cells so the interrupt map is properly
    formed.
    
    Approved by:    re (cperciva)
    Reviewed by:    jrtc27
    Fixes:          7ab1a32cd43c ("bhyve/riscv: Initial import")
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D61473
    
    (cherry picked from commit fabdac3abcbb06551415ca64b69b0e29946834f9)
    (cherry picked from commit d851c68402058bb79b0a03fc76b2951af87d4fcf)
    
    #                                                         72 columns --|
    #
    # Uncomment and complete these metadata fields, as appropriate:
    #
    # PR:           <If and which Problem Report is related.>
    # Reported by:  <If someone else reported the issue.>
    # Reviewed by:  <If someone else reviewed your modification.>
    # Tested by:    <If someone else tested the change.>
    # Approved by:  <If you needed approval for this commit.>
    # Obtained from:        <If the change is from a third party.>
    # Fixes:        <Short hash and title line of commit fixed by this change>
    # MFC after:    <N [day[s]|week[s]|month[s]].  Request a reminder email>
    # MFH:          <Ports tree branch name.  Request approval for merge.>
    # Relnotes:     <Set to 'yes' for mention in release notes.>
    # Security:     <Vulnerability reference (one per line) or description.>
    # Sponsored by: <If the change was sponsored by an organization.>
    # Pull Request: <https://github.com/freebsd/<repo>/pull/###>
    # Differential Revision:        <https://reviews.freebsd.org/D###>
    #
    # "Pull Request" and "Differential Revision" require the *full* GitHub or
    # Phabricator URL.  The commit author should be set appropriately, using
    # `git commit --author` if someone besides the committer sent in the change.
---
 usr.sbin/bhyve/riscv/fdt.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/usr.sbin/bhyve/riscv/fdt.c b/usr.sbin/bhyve/riscv/fdt.c
index 3ccd7ae5dc79..b9fe5ae6c32f 100644
--- a/usr.sbin/bhyve/riscv/fdt.c
+++ b/usr.sbin/bhyve/riscv/fdt.c
@@ -312,15 +312,15 @@ fdt_add_pcie(int intrs[static 4])
 		pin = i % 4;
 		slot = i / 4;
 		intr = intrs[(pin + slot) % 4];
-		SET_PROP_U32(prop, 10 * i + 0, slot << 11);
-		SET_PROP_U32(prop, 10 * i + 1, 0);
-		SET_PROP_U32(prop, 10 * i + 2, 0);
-		SET_PROP_U32(prop, 10 * i + 3, pin + 1);
-		SET_PROP_U32(prop, 10 * i + 4, aplic_phandle);
-		SET_PROP_U32(prop, 10 * i + 5, 0);
-		SET_PROP_U32(prop, 10 * i + 6, 0);
-		SET_PROP_U32(prop, 10 * i + 7, intr);
-		SET_PROP_U32(prop, 10 * i + 8, IRQ_TYPE_LEVEL_HIGH);
+		SET_PROP_U32(prop, 9 * i + 0, slot << 11);
+		SET_PROP_U32(prop, 9 * i + 1, 0);
+		SET_PROP_U32(prop, 9 * i + 2, 0);
+		SET_PROP_U32(prop, 9 * i + 3, pin + 1);
+		SET_PROP_U32(prop, 9 * i + 4, aplic_phandle);
+		SET_PROP_U32(prop, 9 * i + 5, 0);
+		SET_PROP_U32(prop, 9 * i + 6, 0);
+		SET_PROP_U32(prop, 9 * i + 7, intr);
+		SET_PROP_U32(prop, 9 * i + 8, IRQ_TYPE_LEVEL_HIGH);
 	}
 
 	fdt_end_node(fdt);