From nobody Sat Nov 30 00:49:54 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 86CA047772 for ; Sat, 14 Sep 2024 06:13:54 +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=1726294434; cv=none; b=UAt3RtkwkWIiPKt5mOFi5xtCsEkwaEyfE54fBLaK36kQ4PMGovyHkPqspb4GGxFvg8La36kAa3Ow5/4BgfufripcwSwjb7ky3Zs26pZ0HTdUtWel9dV9V1y5pTf76GprooY3ujbEQlN9Rw/+xPHWSIMKrDfWJ3LUetWltbCkHfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726294434; c=relaxed/simple; bh=EWLyILZhCmCqcM/xaUKf+oF1P3KuMlWwct4g79O+XOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GYGtx2eVw4X6mtWl9G0UusIKhy9lCCDWTaZg25qt8eagvgWS8qXs1vegXNRJrFonKV+/BxmbtX7GgKvpsfDLFjRaCU07zjlXtVYwC4JSyfEX4LKLD/OXaHq9AB6RUKLu8hN54lBA1eca1F/RUe0V89AYJXXv9aL5gnN+7esdPbY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FSTB2IFI; 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="FSTB2IFI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 016CCC4CED0; Sat, 14 Sep 2024 06:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726294434; bh=EWLyILZhCmCqcM/xaUKf+oF1P3KuMlWwct4g79O+XOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FSTB2IFIosJuVdm74y9wJR9dM/lBNHjiDH76v/rOhjIsuhl1sfwWp7ZvM502rRv2+ KCBy9CnecJhveDK/lzMkCla/PJLhyArcetFN6jpNZWyOzfclyZuHWShdpf0QK64z92 sasjN3p89ZLM+R9VMSuAbPgX9Us5phens2+xrXTav/2Db8zM9CmZH/X8xatijMz4Sp 5k9GbktJ8UU2KEr7s4mIn7tKLKJKF5qcP7hlxJ91PXUjbschbnqEs+Lv+9zROWH67K x2karIbvcNaTUn1YrxuhMkfTFyhxaTGdg0jWO6EoytePydblwD8WMy8WTvN2cpo5FJ 7d+voAxwJTSXw== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1spM2a-00000003V5i-0HSX; Sat, 14 Sep 2024 08:13:52 +0200 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , Peter Maydell , Shannon Zhao , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v10 05/21] acpi/ghes: better handle source_id and notification Date: Sat, 14 Sep 2024 08:13:26 +0200 Message-ID: <409491c21021b3cc0b239bb95ca6cc78e6adda10.1726293808.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.46.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" GHES has two fields with somewhat meanings: - notification type, which is a number defined at the ACPI spec containing several arch-specific synchronous and assynchronous types; - source id, which is a HW/FW defined number, used to distinguish between different implemented hardware report mechanisms. The current logic is arm-specific, implementing a single source ID, for an armv8-specific synchronous report mechanism (SEA). Cleanup the code to make easier to add other types and make the code portable to non-ARM. As a collateral effect of such change, build_ghes_error_table() function is now an internal function. Signed-off-by: Mauro Carvalho Chehab --- Changes from v8: - Non-rename/cleanup changes merged altogether; - source ID is now more generic, defined per guest target. That should make easier to add support for 86. Signed-off-by: Mauro Carvalho Chehab --- hw/acpi/ghes.c | 31 +++++++++++++++---------------- hw/arm/virt-acpi-build.c | 5 ++--- include/hw/acpi/ghes.h | 6 +++--- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 17b7d9e10f3e..939e89723a2f 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -234,7 +234,7 @@ static int acpi_ghes_record_mem_error(uint64_t error_bl= ock_address, * Initialize "etc/hardware_errors" and "etc/hardware_errors_addr" fw_cfg = blobs. * See docs/specs/acpi_hest_ghes.rst for blobs format. */ -void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *linker) +static void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *li= nker) { int i, error_status_block_offset; =20 @@ -285,9 +285,13 @@ void build_ghes_error_table(GArray *hardware_errors, B= IOSLinker *linker) } =20 /* Build Generic Hardware Error Source version 2 (GHESv2) */ -static void build_ghes_v2(GArray *table_data, int source_id, BIOSLinker *l= inker) +static void build_ghes_v2(GArray *table_data, + BIOSLinker *linker, + enum AcpiGhesNotifyType notify, + uint16_t source_id) { uint64_t address_offset; + /* * Type: * Generic Hardware Error Source version 2(GHESv2 - Type 10) @@ -317,18 +321,8 @@ static void build_ghes_v2(GArray *table_data, int sour= ce_id, BIOSLinker *linker) address_offset + GAS_ADDR_OFFSET, sizeof(uint64_t), ACPI_GHES_ERRORS_FW_CFG_FILE, source_id * sizeof(uint64_t)); =20 - switch (source_id) { - case ACPI_HEST_SRC_ID_SEA: - /* - * Notification Structure - * Now only enable ARMv8 SEA notification type - */ - build_ghes_hw_error_notification(table_data, ACPI_GHES_NOTIFY_SEA); - break; - default: - error_report("Not support this error source"); - abort(); - } + /* Notification Structure */ + build_ghes_hw_error_notification(table_data, notify); =20 /* Error Status Block Length */ build_append_int_noprefix(table_data, ACPI_GHES_MAX_RAW_DATA_LENGTH, 4= ); @@ -357,19 +351,24 @@ static void build_ghes_v2(GArray *table_data, int sou= rce_id, BIOSLinker *linker) } =20 /* Build Hardware Error Source Table */ -void acpi_build_hest(GArray *table_data, BIOSLinker *linker, +void acpi_build_hest(GArray *table_data, GArray *hardware_errors, + BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { AcpiTable table =3D { .sig =3D "HEST", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 + build_ghes_error_table(hardware_errors, linker); + acpi_table_begin(&table, table_data); =20 + /* Beginning at the HEST Error Source struct count and data */ int hest_offset =3D table_data->len; =20 /* Error Source Count */ build_append_int_noprefix(table_data, ACPI_GHES_ERROR_SOURCE_COUNT, 4); - build_ghes_v2(table_data, ACPI_HEST_SRC_ID_SEA, linker); + build_ghes_v2(table_data, linker, + ACPI_GHES_NOTIFY_SEA, ACPI_HEST_SRC_ID_SEA); =20 acpi_table_end(linker, &table); =20 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index f76fb117adff..bafd9a56c217 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -943,10 +943,9 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildT= ables *tables) build_dbg2(tables_blob, tables->linker, vms); =20 if (vms->ras) { - build_ghes_error_table(tables->hardware_errors, tables->linker); acpi_add_table(table_offsets, tables_blob); - acpi_build_hest(tables_blob, tables->linker, vms->oem_id, - vms->oem_table_id); + acpi_build_hest(tables_blob, tables->hardware_errors, tables->link= er, + vms->oem_id, vms->oem_table_id); } =20 if (ms->numa_state->num_nodes > 0) { diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 5421ffcbb7fa..c9bbda4740e2 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -69,12 +69,12 @@ typedef struct AcpiGhesState { bool present; /* True if GHES is present at all on this board */ } AcpiGhesState; =20 -void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *linker); -void acpi_build_hest(GArray *table_data, BIOSLinker *linker, +void acpi_build_hest(GArray *table_data, GArray *hardware_errors, + BIOSLinker *linker, const char *oem_id, const char *oem_table_id); void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s, GArray *hardware_errors); -int acpi_ghes_record_errors(uint8_t notify, uint64_t error_physical_addr); +int acpi_ghes_record_errors(uint8_t source_id, uint64_t error_physical_add= r); =20 /** * acpi_ghes_present: Report whether ACPI GHES table is present --=20 2.46.0