On Fri, 31 Jan 2025 18:42:49 +0100 Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx> wrote: > Move the check logic into a common function and simplify the > code which checks if GHES is enabled and was properly setup. > > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx> > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> > Reviewed-by: Igor Mammedov <imammedo@xxxxxxxxxx> One minor comment inline on a change I think should be in an earlier patch. > -void ghes_record_cper_errors(const void *cper, size_t len, > +void ghes_record_cper_errors(AcpiGhesState *ags, const void *cper, size_t len, > uint16_t source_id, Error **errp) > { > uint64_t cper_addr = 0, read_ack_register_addr = 0, read_ack_register; > - AcpiGedState *acpi_ged_state; > - AcpiGhesState *ags; > > if (len > ACPI_GHES_MAX_RAW_DATA_LENGTH) { > error_setg(errp, "GHES CPER record is too big: %zd", len); > return; > } > > - acpi_ged_state = ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED, > - NULL)); > - if (!acpi_ged_state) { > - error_setg(errp, "Can't find ACPI_GED object"); > - return; > - } > - ags = &acpi_ged_state->ghes_state; > - > - if (!ags->hest_addr_le) { > + if (!ags->use_hest_addr) { Should this change be moved back to patch 3? use_hest_addr was available at that point and it would reduce churn a tiny bit. > get_hw_error_offsets(le64_to_cpu(ags->hw_error_le), > &cper_addr, &read_ack_register_addr); > } else { > @@ -547,11 +531,6 @@ void ghes_record_cper_errors(const void *cper, size_t len, > &cper_addr, &read_ack_register_addr, errp); > } > > - if (!cper_addr) { > - error_setg(errp, "can not find Generic Error Status Block"); > - return; > - } > - > cpu_physical_memory_read(read_ack_register_addr, > &read_ack_register, sizeof(read_ack_register)); >