git: 081f751823aa - main - stand/powerpc/ofw: do not truncate device tree properties to 1024 bytes

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Tue, 29 Sep 2026 08:29:00 UTC
The branch main has been updated by pkubaj:

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

commit 081f751823aa90d8cfea53e900f81dff7cc9836b
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-09-28 05:33:06 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-09-29 08:28:46 +0000

    stand/powerpc/ofw: do not truncate device tree properties to 1024 bytes
    
    When the OpenFirmware loader flattens the firmware device tree into the
    FDT it hands to the kernel (usefdt=1, i.e. on every real-mode OF system
    such as pSeries LPARs and QEMU pseries guests), add_node_to_fdt() clamps
    every property value to 1024 bytes.  Any larger property reaches the
    kernel truncated.
    
    On QEMU pseries the PCI host bridge's "interrupt-map" is 3584 bytes
    (32 slots x 4 pins x 7 cells), so only the entries for slots 0-8 survive
    and the entry for slot 9 is cut in the middle.  A PCI device in slot 9
    or above therefore gets no INTx routing (irq 0), and with INVARIANTS the
    partial trailing entry trips the "ofw_bus_search_intrmap: truncated map"
    assertion in ofw_bus_search_intrmap() during PCI attach, panicking the
    kernel as soon as such a device is present.  "ibm,drc-indexes",
    "ibm,drc-names" and "ibm,drc-power-domains" are cut the same way.
    
    Drop the clamp.  fdt_setprop() already reports a property that does not
    fit into the FDT buffer, so no separate limit is needed.
    
    Fixes:  5ecf8e3852a9 ("Clean up some FDT-related code in the PowerPC bootloader, improving error checking and robustness. Prevents errors and crashes in FDT commands on PowerMac G5 systems.")
    
    Differential Revision:  https://reviews.freebsd.org/D60086
---
 stand/powerpc/ofw/ofwfdt.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/stand/powerpc/ofw/ofwfdt.c b/stand/powerpc/ofw/ofwfdt.c
index 5422924a3b4c..d55126e925bc 100644
--- a/stand/powerpc/ofw/ofwfdt.c
+++ b/stand/powerpc/ofw/ofwfdt.c
@@ -47,8 +47,6 @@ add_node_to_fdt(void *buffer, phandle_t node, int fdt_offset)
 		/* Detect and correct for errors and strangeness */
 		if (proplen < 0)
 			proplen = 0;
-		if (proplen > 1024)
-			proplen = 1024;
 
 		propbuf = malloc(proplen);
 		if (propbuf == NULL) {