From nobody Sat Nov 23 17:36:11 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE1231DF255 for ; Fri, 22 Nov 2024 13:14:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732281264; cv=none; b=n/jSQ3TriSXyfgeXiGFBcsM9bCLrgEEBuuAs3NljkNKsHktv3b4sza5tGQrPgcE+HYcey8hVAh+we1tvWHJ3qTd76hbOj1PrxVOkIAI01UELasBxu1/K+yqJIgwcIEJ1886qnPUC5CtKIkuu6szQGsM8yyxZR5Z8HZ+zsezqm80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732281264; c=relaxed/simple; bh=Pf05cBXdyni1wyrDC8/6pBUg2HAAj3lp4+Zp/z88sBM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ikXA64GtfkQ4QDD4C8wKn20NLI9hIVmoV6AJEblq2hZvQ/voCuL2f8aJYIIxLpsszwI/00PTJmL7yDKw82SnQy8GYDZB9d8T/YxPQjp4alNzNo334U5n0shRu1rTYs/nVQ2y+mrsyZN3oTI5RqIExmHhFxaub0MT+i1AGJuJn4E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Cr/4ZjCb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Cr/4ZjCb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F350C4CEDC; Fri, 22 Nov 2024 13:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732281264; bh=Pf05cBXdyni1wyrDC8/6pBUg2HAAj3lp4+Zp/z88sBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cr/4ZjCbqBS2n1dp81M6Uu40MNgHHF2BUf9CYbc167TFcohCNX2ZMn7jjGxg4CshJ gD7V0JuhEfEIl3OrV5NwgAiTG291OKRSx4/3Duuo+js9hG3hmNwzxKjm0kdyi70QAQ eSNcfPXgrjj5Ek+A8q4391zlOeRXnrUfOyteCWKD5D/4y8tlIpJXrS0oOUroCqwHJa /xrdO/e0HqP+1Ne1by61SC/USjdfEPWTJP0YQNAvEi2qi6bFgoNfPnaFCF6nRNXYUU rvJd0gigxen8kGkhgf3MnqtBqaxvILeYznmR3C+gt/8eB9XcSS9jFa1GNN7C6rjhY9 GUqdaAl72X9mw== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tETUM-00000006v9u-0YTL; Fri, 22 Nov 2024 14:14:22 +0100 From: Mauro Carvalho Chehab To: Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ani Sinha , Dongjiu Geng , Eduardo Habkost , Igor Mammedov , Marcel Apfelbaum , Peter Maydell , Shannon Zhao , Yanan Wang , Zhao Liu , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 5/5] acpi/generic_event_device: add logic to detect if HEST addr is available Date: Fri, 22 Nov 2024 14:14:15 +0100 Message-ID: <7505ad000ed66099bf443fd7769c83bd7d5d4136.1732281080.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Create a new property (x-has-hest-addr) and use it to detect if the GHES table offsets can be calculated from the HEST address (qemu 9.2 and upper) or via the legacy way via an offset obtained from the hardware_errors firmware file. Signed-off-by: Mauro Carvalho Chehab --- hw/acpi/generic_event_device.c | 1 + hw/acpi/ghes.c | 28 +++++++++++++++++++++------- hw/arm/virt-acpi-build.c | 30 ++++++++++++++++++++++++++---- hw/core/machine.c | 2 ++ include/hw/acpi/ghes.h | 1 + 5 files changed, 51 insertions(+), 11 deletions(-) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index c1116dd8d7ae..df6b4fab2d30 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -318,6 +318,7 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, Acp= iEventStatusBits ev) =20 static Property acpi_ged_properties[] =3D { DEFINE_PROP_UINT32("ged-event", AcpiGedState, ged_event_bitmap, 0), + DEFINE_PROP_BOOL("x-has-hest-addr", AcpiGedState, ghes_state.hest_look= up, true), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index b5e3e2891445..a10f7e266a6a 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -359,6 +359,8 @@ void acpi_build_hest(GArray *table_data, GArray *hardwa= re_errors, { AcpiTable table =3D { .sig =3D "HEST", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; + AcpiGedState *acpi_ged_state; + AcpiGhesState *ags =3D NULL; int i; =20 build_ghes_error_table(hardware_errors, linker, num_sources); @@ -379,10 +381,20 @@ void acpi_build_hest(GArray *table_data, GArray *hard= ware_errors, * tell firmware to write into GPA the address of HEST via fw_cfg, * once initialized. */ - bios_linker_loader_write_pointer(linker, - ACPI_HEST_ADDR_FW_CFG_FILE, 0, - sizeof(uint64_t), - ACPI_BUILD_TABLE_FILE, hest_offset); + + acpi_ged_state =3D ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED, + NULL)); + if (!acpi_ged_state) { + return; + } + + ags =3D &acpi_ged_state->ghes_state; + if (ags->hest_lookup) { + bios_linker_loader_write_pointer(linker, + ACPI_HEST_ADDR_FW_CFG_FILE, 0, + sizeof(uint64_t), + ACPI_BUILD_TABLE_FILE, hest_offse= t); + } } =20 void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s, @@ -396,8 +408,10 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgSta= te *s, fw_cfg_add_file_callback(s, ACPI_HW_ERROR_ADDR_FW_CFG_FILE, NULL, NULL, NULL, &(ags->hw_error_le), sizeof(ags->hw_error_le), false); =20 - fw_cfg_add_file_callback(s, ACPI_HEST_ADDR_FW_CFG_FILE, NULL, NULL, - NULL, &(ags->hest_addr_le), sizeof(ags->hest_addr_le), false); + if (ags && ags->hest_lookup) { + fw_cfg_add_file_callback(s, ACPI_HEST_ADDR_FW_CFG_FILE, NULL, NULL, + NULL, &(ags->hest_addr_le), sizeof(ags->hest_addr_le), false); + } =20 ags->present =3D true; } @@ -512,7 +526,7 @@ void ghes_record_cper_errors(const void *cper, size_t l= en, } ags =3D &acpi_ged_state->ghes_state; =20 - if (!ags->hest_addr_le) { + if (!ags->hest_lookup) { get_hw_error_offsets(le64_to_cpu(ags->hw_error_le), &cper_addr, &read_ack_register_addr); } else { diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index bd5582bc75f8..46ce3f3bb07a 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -893,6 +893,10 @@ static const AcpiNotificationSourceId hest_ghes_notify= [] =3D { { ACPI_HEST_SRC_ID_SYNC, ACPI_GHES_NOTIFY_SEA }, }; =20 +static const AcpiNotificationSourceId hest_ghes_notify_9_1[] =3D { + { ACPI_HEST_SRC_ID_SYNC, ACPI_GHES_NOTIFY_SEA }, +}; + static void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) { @@ -946,10 +950,28 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuild= Tables *tables) build_dbg2(tables_blob, tables->linker, vms); =20 if (vms->ras) { - acpi_add_table(table_offsets, tables_blob); - acpi_build_hest(tables_blob, tables->hardware_errors, tables->link= er, - hest_ghes_notify, ARRAY_SIZE(hest_ghes_notify), - vms->oem_id, vms->oem_table_id); + AcpiGhesState *ags; + AcpiGedState *acpi_ged_state; + + acpi_ged_state =3D ACPI_GED(object_resolve_path_type("", TYPE_ACPI= _GED, + NULL)); + if (acpi_ged_state) { + ags =3D &acpi_ged_state->ghes_state; + + acpi_add_table(table_offsets, tables_blob); + + if (!ags->hest_lookup) { + acpi_build_hest(tables_blob, tables->hardware_errors, + tables->linker, hest_ghes_notify_9_1, + ARRAY_SIZE(hest_ghes_notify_9_1), + vms->oem_id, vms->oem_table_id); + } else { + acpi_build_hest(tables_blob, tables->hardware_errors, + tables->linker, hest_ghes_notify, + ARRAY_SIZE(hest_ghes_notify), + vms->oem_id, vms->oem_table_id); + } + } } =20 if (ms->numa_state->num_nodes > 0) { diff --git a/hw/core/machine.c b/hw/core/machine.c index a35c4a8faecb..00521a1963ba 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -34,10 +34,12 @@ #include "hw/virtio/virtio-pci.h" #include "hw/virtio/virtio-net.h" #include "hw/virtio/virtio-iommu.h" +#include "hw/acpi/generic_event_device.h" #include "audio/audio.h" =20 GlobalProperty hw_compat_9_1[] =3D { { TYPE_PCI_DEVICE, "x-pcie-ext-tag", "false" }, + { TYPE_ACPI_GED, "x-has-hest-addr", "false" }, }; const size_t hw_compat_9_1_len =3D G_N_ELEMENTS(hw_compat_9_1); =20 diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 237721fec0a2..164ed8b0f9a3 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -61,6 +61,7 @@ typedef struct AcpiGhesState { uint64_t hest_addr_le; uint64_t hw_error_le; bool present; /* True if GHES is present at all on this board */ + bool hest_lookup; /* True if HEST address is present */ } AcpiGhesState; =20 /* --=20 2.47.0