From nobody Thu Apr 3 10:11:36 2025 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 730E3250BE9 for ; Fri, 7 Mar 2025 19:14:58 +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=1741374898; cv=none; b=LMRe4bDEG8loHw+NfQ6Pz/LGelnttRjplxLxdg084RfvaYPJC9oQigYQlNWE7v3um4++G8bUyyaxAX6sGM7FtOFzi5sdP4c89KauAILCqJSetM/aK4V1ReROpljHYYFNzZvWrOMnS82QtfXEsYLhMfG7INM++IcFzWGap8LTtbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741374898; c=relaxed/simple; bh=8BoyWsZH7yMX5VJVVDi6rK24BbVZK+x44gJfcWJ6v2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sIDaan30u/ZOfb1dEQw12gSmeifO625TEz+ucDV9ope44rImMWsMs6lbfh9dC2oB/R5QqwRG5/ha3Lp3ul5JiRJ1XLdllopfOczGgai2/26fVSL16L+vF+QoTnUg2six0kPhYODxkT+GFNDOujaL3+dEj0ae+EV5kuLHHsVHGuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ro4AjwYg; 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="ro4AjwYg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD37AC4CEEC; Fri, 7 Mar 2025 19:14:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741374897; bh=8BoyWsZH7yMX5VJVVDi6rK24BbVZK+x44gJfcWJ6v2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ro4AjwYghsrwf6heBM+SjoMqKUR4BIrhv3n+g0npqK64VvrvQkAB5R1A/IliCskKd 3c/9YeXfZEdio/rWc0LPxZNDMUkO4LOvqkhm7x2KeUvUoLBDJWkuGWciXj9qgGCmrR ukze15M1os5tUu3od+7C4hFs0rstbNRE//u1UcyyrlNwZr3SpXz4kNRet3MLKD/zNS 3usxR3sK6XBCFM2EqNyP6wLlZAYz/LZ+dftzQffKYxzd3lrB48w1QSvjsbjaj/kGOS nGqM7NEz6Smi6VTYd3l3wdKRhulSsIW6uL+xUV4A7RfT5JWwlaFOczmI2b4yvNWKML jMtpLpmS0nt6g== Received: from mchehab by mail.kernel.org with local (Exim 4.98.1) (envelope-from ) id 1tqd9r-0000000BQmj-3Pgc; Fri, 07 Mar 2025 20:14:55 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov , "Michael S . Tsirkin" Cc: Jonathan Cameron , Shiju Jose , qemu-arm@nongnu.org, qemu-devel@nongnu.org, Mauro Carvalho Chehab , "Gavin Shan" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org Subject: [PATCH v8 07/20] acpi/ghes: add a firmware file with HEST address Date: Fri, 7 Mar 2025 20:14:36 +0100 Message-ID: <1b19d47464134b4ca61e34b4423124ed3dc5234a.1741374594.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.48.1 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" Store HEST table address at GPA, placing its the start of the table at hest_addr_le variable. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov --- hw/acpi/ghes.c | 22 ++++++++++++++++++++-- include/hw/acpi/ghes.h | 6 +++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 9243b5ad4acb..cbc96c1909f0 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -30,6 +30,7 @@ =20 #define ACPI_HW_ERROR_FW_CFG_FILE "etc/hardware_errors" #define ACPI_HW_ERROR_ADDR_FW_CFG_FILE "etc/hardware_errors_addr" +#define ACPI_HEST_ADDR_FW_CFG_FILE "etc/acpi_table_hest_addr" =20 /* The max size in bytes for one error block */ #define ACPI_GHES_MAX_RAW_DATA_LENGTH (1 * KiB) @@ -341,6 +342,9 @@ void acpi_build_hest(AcpiGhesState *ags, GArray *table_= data, { AcpiTable table =3D { .sig =3D "HEST", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; + uint32_t hest_offset; + + hest_offset =3D table_data->len; =20 build_ghes_error_table(ags, hardware_errors, linker); =20 @@ -352,6 +356,17 @@ void acpi_build_hest(AcpiGhesState *ags, GArray *table= _data, ACPI_GHES_NOTIFY_SEA, ACPI_HEST_SRC_ID_SEA); =20 acpi_table_end(linker, &table); + + if (ags->use_hest_addr) { + /* + * 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_offse= t); + } } =20 void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s, @@ -361,7 +376,10 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgSta= te *s, fw_cfg_add_file(s, ACPI_HW_ERROR_FW_CFG_FILE, hardware_error->data, hardware_error->len); =20 - if (!ags->use_hest_addr) { + if (ags->use_hest_addr) { + 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); + } else { /* Create a read-write fw_cfg file for Address */ 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); @@ -484,7 +502,7 @@ AcpiGhesState *acpi_ghes_get_state(void) } ags =3D &acpi_ged_state->ghes_state; =20 - if (!ags->hw_error_le) { + if (!ags->hw_error_le && !ags->hest_addr_le) { return NULL; } return ags; diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 411f592662af..ea9baab764e2 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -70,9 +70,13 @@ enum { * When use_hest_addr is false, the GPA of the etc/hardware_errors firmware * is stored at hw_error_le. This is the default on QEMU 9.x. * - * An GPA value equal to zero means that GHES is not present. + * When use_hest_addr is true, the GPA of the HEST table is stored at + * hest_addr_le. This is the default for QEMU 10.x and above. + * + * Whe both GPA values are equal to zero means that GHES is not present. */ typedef struct AcpiGhesState { + uint64_t hest_addr_le; uint64_t hw_error_le; bool use_hest_addr; /* Currently, always false */ } AcpiGhesState; --=20 2.48.1