This commit fixes two boot issues on GCE c4a-metal instances related to
the System Resource Affinity Table (SRAT):
- Smart Early Memory Allocation:
During early boot, acpi_pxm_init() allocates memory for the CPU affinity
array by stealing memory from the end of the last physical memory region
in the phys_avail list. On c4a-metal, the last physical memory chunk is
extremely small (less than the required size), causing a KASSERT(addr >=
phys_avail[idx]) panic.
Fix this by walking the phys_avail list backwards to find the first
physical memory region that is actually large enough to satisfy the
allocation, rather than assuming the last one always has space. If no
region has enough space, we fall back to disabling SRAT gracefully.
- CPU Enable Flag Handling:
The firmware on c4a-metal lists several CPUs as disabled in the SRAT
table, even though they are enabled in the MADT (APIC) table and start
up successfully. The original SRAT parser skipped disabled entries,
which caused these CPUs to boot without a proximity domain assigned,
leading to weird behavior or panics.
Fix this by removing the early exit in srat_parse_entry() for disabled
SRAT GICC entries. This ensures all CPUs listed in SRAT get assigned to
their defined proximity domain (or domain 0) to match their
MADT-activated state.
Note: The SRAT, DSDT, and APIC dumps are on freebsd.org/~ziaee/tmp/c4a-*
Authored by: Jasper Tran O'Leary <jtranoleary@google.com>
Sponsored by: Google Cloud