On Fri, 13 Nov 2026 at 02:33, Ren Yanyi <[email protected]> wrote:
>
> virt_acpi_build() gates HEST table construction on:
>
> acpi_ged_state = ACPI_GED(vms->acpi_dev);
> ags = &acpi_ged_state->ghes_state;
> if (ags) {
>
> ags is the address of the ghes_state member of AcpiGedState and can
> never be NULL, so the check always passes. Whether the GED device
> exists is a separate condition (has_ged also depends on firmware
> being loaded and on ACPI being enabled), so a machine started with
> ras=on but without a GED device reaches this code with a NULL
> acpi_ged_state; ags then holds a bogus non-NULL pointer and
> acpi_build_hest() dereferences it.
>
> Test vms->acpi_dev in the enclosing condition instead, so the HEST
> table is only built when the GED device exists and the ACPI_GED()
> cast is always valid.
>
> Fixes: 2e9c5c5bc85a ("acpi/ghes: prepare to change the way HEST offsets are
> calculated")
> Signed-off-by: Ren Yanyi <[email protected]>
I've applied this to target-arm.next, but to let you know: your emails
do not seem to be making it to the mailing list. I only got this one
because I'm on the direct CC list for it.
(Full patch below for the record.)
> ---
>
> Changes since v1:
> - hoist the check into the outer "if (vms->ras && vms->acpi_dev)"
> condition and unwrap the always-true inner check, as suggested
> by Peter Maydell
>
> hw/arm/virt-acpi-build.c | 25 ++++++++++++-------------
> 1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index d368913..5670d1e 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -1406,7 +1406,7 @@ void virt_acpi_build(VirtMachineState *vms,
> AcpiBuildTables *tables)
> acpi_add_table(table_offsets, tables_blob);
> build_dbg2(tables_blob, tables->linker, vms);
>
> - if (vms->ras) {
> + if (vms->ras && vms->acpi_dev) {
> AcpiGedState *acpi_ged_state;
> static const AcpiNotificationSourceId *notify;
> unsigned int notify_sz;
> @@ -1414,21 +1414,20 @@ void virt_acpi_build(VirtMachineState *vms,
> AcpiBuildTables *tables)
>
> acpi_ged_state = ACPI_GED(vms->acpi_dev);
> ags = &acpi_ged_state->ghes_state;
> - if (ags) {
> - acpi_add_table(table_offsets, tables_blob);
>
> - if (!ags->use_hest_addr) {
> - notify = hest_ghes_notify_10_0;
> - notify_sz = ARRAY_SIZE(hest_ghes_notify_10_0);
> - } else {
> - notify = hest_ghes_notify;
> - notify_sz = ARRAY_SIZE(hest_ghes_notify);
> - }
> + acpi_add_table(table_offsets, tables_blob);
>
> - acpi_build_hest(ags, tables_blob, tables->hardware_errors,
> - tables->linker, notify, notify_sz,
> - vms->oem_id, vms->oem_table_id);
> + if (!ags->use_hest_addr) {
> + notify = hest_ghes_notify_10_0;
> + notify_sz = ARRAY_SIZE(hest_ghes_notify_10_0);
> + } else {
> + notify = hest_ghes_notify;
> + notify_sz = ARRAY_SIZE(hest_ghes_notify);
> }
> +
> + acpi_build_hest(ags, tables_blob, tables->hardware_errors,
> + tables->linker, notify, notify_sz,
> + vms->oem_id, vms->oem_table_id);
> }
>
> if (ms->numa_state->num_nodes > 0) {
> --
> 2.53.0
>
thanks
-- PMM