From nobody Thu Nov 28 13:57:39 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 53AEB1DDC38 for ; Fri, 22 Nov 2024 09:11:50 +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=1732266710; cv=none; b=T7SMX74QVzMCmD8y9VquACgEs49Wlm5drxd744trHzCnaxku0UdtFHtGZk/TOCwZ/MDbwXy1Wq3ZVAyn3tgANc0PYoW4PyA0IKbL2nagKgt90vIUPtAGaGRGkxZOfzDhRVhz5pqNs7e71L3uOUFx3fDqhnN82WWmFSUr3O+D9cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266710; c=relaxed/simple; bh=QJ/9nC0AC0LVeMW5CIbUqcXtgVzZi7ledKJv1fQ37fc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a2mmqCwiBP5R3taD0hVn+Wgc1my+U0wsJArRPZaNl4y1wdjD42VlJPjHZIKxIZXwXsgVvYEwBo6tb+voW7p42WqcLS38m0rSVou03RYo+DDuejYyqCtyBXAA9VJukQGFhDm3PwmSo+9v4h9sR40apx9XxdYrxJBMLRpe1tlpBFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eqBfwoAv; 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="eqBfwoAv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEAA7C4CED3; Fri, 22 Nov 2024 09:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266709; bh=QJ/9nC0AC0LVeMW5CIbUqcXtgVzZi7ledKJv1fQ37fc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eqBfwoAvumZlfEVeo/fHikPFbd7YCqqtki1FECoVXdoLUxH0mSfU3KVFzibF75Idl 9fB66XbRhO2Ap+QX3bpPdNliIoaMTvvE1LTPrA86ZyIt3iHSCFUkGSlC6RO0ZSeR1v wmExPU9gxKumGEaHjybIPYRzG8J5tMfVxFCwMbSOSP82e/3kU7X3XbvPPva0XbRwiM 0ZiZljb7v4VD0MP5IdPxPJ9O0bzwHtsXJC/aPDdwOjukQvDUCfUERDrMe6m0dl6H74 Bm/q1B+oEQPVnEXVNxucOYVGpembhcWjpgEVgIQDTqUThLUir7bn8PgNGh/v4sdGx+ C4Cgpsmxe1pIA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhW-00000006l3Y-43rl; Fri, 22 Nov 2024 10:11:42 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 01/15] acpi/ghes: get rid of ACPI_HEST_SRC_ID_RESERVED Date: Fri, 22 Nov 2024 10:11:18 +0100 Message-ID: <9190c5106ac8e99aeef69a155b393c90ddd97d97.1732266152.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" This is just duplicating ACPI_GHES_ERROR_SOURCE_COUNT, which has a better name. So, drop the duplication. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Igor Mammedov Reviewed-by: Jonathan Cameron --- hw/acpi/ghes.c | 7 ++----- include/hw/acpi/ghes.h | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index e9511d9b8f71..dc217694deb9 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -34,9 +34,6 @@ /* The max size in bytes for one error block */ #define ACPI_GHES_MAX_RAW_DATA_LENGTH (1 * KiB) =20 -/* Now only support ARMv8 SEA notification type error source */ -#define ACPI_GHES_ERROR_SOURCE_COUNT 1 - /* Generic Hardware Error Source version 2 */ #define ACPI_GHES_SOURCE_GENERIC_ERROR_V2 10 =20 @@ -396,7 +393,7 @@ int acpi_ghes_record_errors(uint8_t source_id, uint64_t= physical_address) AcpiGedState *acpi_ged_state; AcpiGhesState *ags; =20 - assert(source_id < ACPI_HEST_SRC_ID_RESERVED); + assert(source_id < ACPI_GHES_ERROR_SOURCE_COUNT); =20 acpi_ged_state =3D ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED, NULL)); @@ -407,7 +404,7 @@ int acpi_ghes_record_errors(uint8_t source_id, uint64_t= physical_address) =20 if (physical_address) { =20 - if (source_id < ACPI_HEST_SRC_ID_RESERVED) { + if (source_id < ACPI_GHES_ERROR_SOURCE_COUNT) { start_addr +=3D source_id * sizeof(uint64_t); } =20 diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 674f6958e905..59e3b8fb24b9 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -59,7 +59,8 @@ enum AcpiGhesNotifyType { enum { ACPI_HEST_SRC_ID_SEA =3D 0, /* future ids go here */ - ACPI_HEST_SRC_ID_RESERVED, + + ACPI_GHES_ERROR_SOURCE_COUNT }; =20 typedef struct AcpiGhesState { --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 0405E1DB55C for ; Fri, 22 Nov 2024 09:11:50 +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=1732266710; cv=none; b=jI+WCxxPcg/oBcTJwU7DKg0ywguFSn5GNDTZYdJmxPubrRaRJ8d/st5ri+2hIl1cMPySGp7ideC70tfa6pVYP+QH2JyaxAXHzu3fDpaKTYJXrqgE0zxUPYO5+b1Dk6H+xuzumNtyRFcmPY2Eam9sJloVG7lmre0vj6F8ARO/UrQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266710; c=relaxed/simple; bh=u/evd6VNZ2Rw7eUqK3iewtjOB7zhkG2fVMmc7C1F68o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jjhDCwP3zG+2JvYwAqlABbooIVTWaaGHC/3PjAUvZGRd994ez86sumEEBHMJUjP94MXLpoWmBkoDNUZUQi8m+92JhIWkKoPmXsqaUYwEAaVArfw7CewRgaeSUDS8GmsTQcM7akh6lLfaoX57RfzOdusKMLIt8FqFo3PJt9aCCSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=flVnF+G6; 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="flVnF+G6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D637BC4AF0B; Fri, 22 Nov 2024 09:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266709; bh=u/evd6VNZ2Rw7eUqK3iewtjOB7zhkG2fVMmc7C1F68o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=flVnF+G6K8xjTew3rEgHR++AelrZMDjgU3036bxDCI8h5y2sMNwqOk3vssUBpyv9G KSrSZnsQjDuwfpRXw6bv/WGP5c0K4VSYe3aomKTXRTzTB/t0mVnskkrYcE0TTqohTN LeSkTJiQsD1WQZatNTLt6CW+F0kxBVsPMXnSOioCcpSEq3Ql/tFAXVamAM/dhx6AKQ AjMgwC9v80NnOHOFOugI5hOwoS5XD/f9g00j9JXcEKE/qmjmAjPt1x/WHnKPQVgtYn QK2nPXMTlAGf7q0LSj7c/g4yTE6o0LUumPf6QJsG81nOMDDssbh/R5j+EbQkqj+giC prW5938O05CQQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhW-00000006l3b-4Am5; Fri, 22 Nov 2024 10:11:42 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 02/15] acpi/ghes: simplify acpi_ghes_record_errors() code Date: Fri, 22 Nov 2024 10:11:19 +0100 Message-ID: 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" Reduce the ident of the function and prepares it for the next changes. No functional changes. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Igor Mammedov Reviewed-by: Jonathan Cameron --- hw/acpi/ghes.c | 56 ++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index dc217694deb9..e66f3be1502b 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -402,40 +402,42 @@ int acpi_ghes_record_errors(uint8_t source_id, uint64= _t physical_address) =20 start_addr =3D le64_to_cpu(ags->ghes_addr_le); =20 - if (physical_address) { + if (!physical_address) { + return -1; + } =20 - if (source_id < ACPI_GHES_ERROR_SOURCE_COUNT) { - start_addr +=3D source_id * sizeof(uint64_t); - } + if (source_id < ACPI_GHES_ERROR_SOURCE_COUNT) { + start_addr +=3D source_id * sizeof(uint64_t); + } =20 - cpu_physical_memory_read(start_addr, &error_block_addr, - sizeof(error_block_addr)); + cpu_physical_memory_read(start_addr, &error_block_addr, + sizeof(error_block_addr)); =20 - error_block_addr =3D le64_to_cpu(error_block_addr); + error_block_addr =3D le64_to_cpu(error_block_addr); =20 - read_ack_register_addr =3D start_addr + - ACPI_GHES_ERROR_SOURCE_COUNT * sizeof(uint64_t); + read_ack_register_addr =3D start_addr + + ACPI_GHES_ERROR_SOURCE_COUNT * sizeof(uint64_= t); =20 - cpu_physical_memory_read(read_ack_register_addr, - &read_ack_register, sizeof(read_ack_regis= ter)); + cpu_physical_memory_read(read_ack_register_addr, + &read_ack_register, sizeof(read_ack_register)= ); =20 - /* zero means OSPM does not acknowledge the error */ - if (!read_ack_register) { - error_report("OSPM does not acknowledge previous error," - " so can not record CPER for current error anymore"); - } else if (error_block_addr) { - read_ack_register =3D cpu_to_le64(0); - /* - * Clear the Read Ack Register, OSPM will write it to 1 when - * it acknowledges this error. - */ - cpu_physical_memory_write(read_ack_register_addr, - &read_ack_register, sizeof(uint64_t)); + /* zero means OSPM does not acknowledge the error */ + if (!read_ack_register) { + error_report("OSPM does not acknowledge previous error," + " so can not record CPER for current error anymore"); + } else if (error_block_addr) { + read_ack_register =3D cpu_to_le64(0); + /* + * Clear the Read Ack Register, OSPM will write it to 1 when + * it acknowledges this error. + */ + cpu_physical_memory_write(read_ack_register_addr, + &read_ack_register, sizeof(uint64_t)); =20 - ret =3D acpi_ghes_record_mem_error(error_block_addr, - physical_address); - } else - error_report("can not find Generic Error Status Block"); + ret =3D acpi_ghes_record_mem_error(error_block_addr, + physical_address); + } else { + error_report("can not find Generic Error Status Block"); } =20 return ret; --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 A325B4A04 for ; Fri, 22 Nov 2024 09:11:48 +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=1732266708; cv=none; b=bGVPIk4kFBUVrv5kuzseuuCNbZimsCUvM7QFpuLV9qrY4GAj+mlwXBIbYoG1BX9ZHSCkPpyyyGWo5uJO97+F2a3D0luZVPxe4yiM9ybzsvrS3AZKrjDShTvHxXpifxJZAMGsNwodeiG8oG8Q1H6s081aaqekSEJyfAwV4Vhhnn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266708; c=relaxed/simple; bh=BAIrfONVknkmj4qoXvrO8lvnEuBSNbh9qzzbtdJrOyE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=csnl0vHtT0NYyeOBnMSw6sejqniBp6ypoRKaWP4Ygi0Lc0XcmWutcicRtgOm7zuqCW16MzkoM6j5h/sY5yOeQHCnKJjKrFle20YIU4Zg86EWViuj5jA92sjhD3npfMy6QJUCTxEkByNCOGDNbF+n/z1iyOcYfSjCN8tlOwGprtg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TT8xeero; 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="TT8xeero" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61F91C4CECE; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=BAIrfONVknkmj4qoXvrO8lvnEuBSNbh9qzzbtdJrOyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TT8xeeros3BBOlnqHn+dJ/nOv4iC39JWc1/XxmXOQZZW5SIH0Cpd7swbe8t7Msm8i rtv2KtcAWxzaX3hYR5quxeo7UQiv0tCyhcMcFRrb6iCAarn01tbkPyDTcsvKEztVx5 DNYMnRX7QxZ09ZV6fEuSwyr7yc56dr/CQ2Jyi6qKc9mP86hIKLpUs6OhiGUDa/EAtM UhJibWvxhVmUMFrhYUmX6WHwd50/F+rtYzoi2pzT0/4VCg8bUK6VJUu5VuiAfd8t49 XNH2UYJeIpwCZ7cFfG4NSuCcTxdkkZqjxEfKoU+GleWkgeiVOwkO5c6V6g+7AoETEW lhiJqoAm1e5hA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l3e-05YK; Fri, 22 Nov 2024 10:11:43 +0100 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 v4 03/15] acpi/ghes: simplify the per-arch caller to build HEST table Date: Fri, 22 Nov 2024 10:11:20 +0100 Message-ID: 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" The GHES driver requires not only a HEST table, but also a separate firmware file to store Error Structure records. It can't do one without the other. Simplify the caller logic for it to require one function. No functional changes. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov --- Changes from v10: - Removed the logic which associates notification and source ID. This will be placed on a separate patch. 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 | 7 +++++-- hw/arm/virt-acpi-build.c | 5 ++--- include/hw/acpi/ghes.h | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index e66f3be1502b..4a6c45bcb4be 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -233,7 +233,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 @@ -356,12 +356,15 @@ 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 /* Error Source Count */ diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 620992c92c12..e059317b002e 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -942,10 +942,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 59e3b8fb24b9..20016c226d1f 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -68,8 +68,8 @@ 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); --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 53B431DDC39 for ; Fri, 22 Nov 2024 09:11:50 +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=1732266710; cv=none; b=MJ9+OtdK4a/1G57MVh/Bb1BxD7B0AU0FcGBSiop7iTnRoyXvzWTNDGi3b+HcDEgEOKDsW8W+GeryES3gx4958cLAJERrjmiNEaVhaEm4JNZBLlBz8nTyHukfVok4vrfjRBtdQmP9LiHtxO0UR0JAaTJm8QPciguCQGNDugW5IhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266710; c=relaxed/simple; bh=/J8Ik2gV7ARAny61vMhfWIVszDkkmW/W+wjqFlb9x4g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ILjWVsYiuVxaMAgits61P581dAQXcWgrlHo4F3+kzcQPW7MrqGVElhMxSKWweuFyJxOW3bN/E/TWVOsUlGHvMzHmMWXVFZbyGRAq3ZhXegGmlL7Pnx3pXTDFvod4EUD9y6vz9fr7pKf02baUAVGtNNZN6dR78Sswjue/Z11v1ks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SFraNgWm; 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="SFraNgWm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F8FC4CED7; Fri, 22 Nov 2024 09:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266709; bh=/J8Ik2gV7ARAny61vMhfWIVszDkkmW/W+wjqFlb9x4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SFraNgWmycLEBmSZeTbU6FaFmwpA6+S2emG81D+VIn0Y96qJN84pldb/55xtKKquz 7nyZGDEj9J7/D8FMfABrk4I/CgzMXpC4TPSsp2sqgdJ2NRXcHS/9bWswdZq08km4lN JlspEpoljbtvIgNNYXkASJAXPitbLBW90Y4FP4eUAu6oelzTHZUCJEMqMP86jTuf6r ROl5muLdvox5UtGTpNVtAlZoS8HFyYdPwL4Ai+3jyq1VMxksS0HdnzVh2j42IUhUZK dmnYSKm7Rx2gpDh5LQitqeDVJzOsDAfaPbeD169k21/yHAlbLU0gLcK75cztfTmip4 NHHEh57Egn5UQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l3h-0CNf; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 04/15] acpi/ghes: better handle source_id and notification Date: Fri, 22 Nov 2024 10:11:21 +0100 Message-ID: <0ad66ed39b357d5fbf2e4a6d1fa47d310796cc1c.1732266152.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" GHES has two fields that are stored on HEST error source blocks associated with notifications: - 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 sources. There could be several sources with the same notification type, which is dependent of the way each architecture maps notifications. Right now, build_ghes_v2() hardcodes a 1:1 mapping between such fields. Move it to two independent parameters, allowing the caller function to fill both. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov --- Chenges from v10: - Some changes got moved to the previous patch. 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 | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 4a6c45bcb4be..29cd7e4d8171 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -284,9 +284,13 @@ static void build_ghes_error_table(GArray *hardware_er= rors, BIOSLinker *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) @@ -316,18 +320,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= ); @@ -369,7 +363,8 @@ void acpi_build_hest(GArray *table_data, GArray *hardwa= re_errors, =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 2.47.0 From nobody Thu Nov 28 13:57:39 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 16E5518A951 for ; Fri, 22 Nov 2024 09:11:49 +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=1732266709; cv=none; b=igZN2Jv+We9UEHx9T396ma7M+Jv/SXV2TaHdoOug3sPzP5LYg0RjQSUV2L/0V7nC+YrnVSlXnXjwV0a8YOFJl0zbIjJfk8Uvi+5QS64YtLY+Goe4Gc71n1o37ee4RNo7gJT/JuLYvHxXDCx2I0jOiXYZ80/tlBOnudk7N2OoCr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266709; c=relaxed/simple; bh=80tymdZsA4gV0nz/70yruPzz2rfWPx4O9L07JwfBNsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l865q8oI1jbnJz9h+VPQBbnrfN7xHS5O+Tl3x4b+9qzFE8Kqmh5FsCLsKDUvZTOM/0tzz0RV+2musdgGqbi4ABp76EWL9EdktKK2WO1nyCaYTsk/cwj9RRHM/KtAbndhD/9/hbGvCrNK5xGv9mJU7UKMborjPisUX2znyHHToXU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xgim6UF4; 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="Xgim6UF4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C3EAC4CED7; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=80tymdZsA4gV0nz/70yruPzz2rfWPx4O9L07JwfBNsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xgim6UF4N0aFf5qEPKNhNevuAd2AV+b5ufeY1q311b+8FuojhUkU9e6pcFx23nJBl 4DoBCZ6MrFh+rhuCejs781gBaWAncJqYs4ie1/SAhEaqlwztO2ipiejzTj8ZcIBjfS 7aBg+pVmJVEDiZgJkzxm0EbBI8SQEPaWVMnxXMqVpINBMXSjXkudsbKZzmJLR6MWxe tw5ZgAFbDWVByq/YgbI1DeJEkGgAe07C31X08jBYSHhGhxHBgcIGLM9olf/QolSW/w Sad9VfIgSQsRzOaDtwBDy56NQFuk2I2TmqOwn3qSO4YiefPYTjirj4bNC7z1DIQOC8 5NnMIwYsXjIsQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l3k-0JEe; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 05/15] acpi/ghes: Fix acpi_ghes_record_errors() argument Date: Fri, 22 Nov 2024 10:11:22 +0100 Message-ID: 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" Align the header file with the actual implementation of this function, as the first argument is source ID and not notification type. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov --- 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 --- include/hw/acpi/ghes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 20016c226d1f..50e3a25ea384 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -73,7 +73,7 @@ void acpi_build_hest(GArray *table_data, GArray *hardware= _errors, 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.47.0 From nobody Thu Nov 28 13:57:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1732266756; cv=none; d=zohomail.com; s=zohoarc; b=cOJAzRvL3WWmQHiWsf+N/OXYf7gcRNEdEEGxn1L3Waha2sDyBTtzg8it6tKH/ZIDa99dJAUDprCFZibZxJ7CrjlYNG7fD7LZVUx5cQWfb6n75ToiWZjpOAdU2c9/yHIBNWrkdu+ZHwZmX/Qf4Tj6joJ2LplUquZcB/nVU8wEIOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732266756; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K64PQ1ylL9qAD825pvhASNhbR4UUpQjXVd/mwPAYuBE=; b=dhxy4wxyjJ3vdAueaYvG4CUmnPodeSN/h2M1MLTRnPAyGHepubZ6Ehvr6TQ1V/FvWBbNOIdNrC9t5Y/Qss8DuqcwPABeWa0rHEDl2oKZTPNCmFGcbnUS2dnMidUUEGqdP2S8SCSP0ptgolaRnmPEiMrx9vWOKanxmD1nBHmfj4U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732266756805116.49865223924508; Fri, 22 Nov 2024 01:12:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tEPho-0002Bq-4f; Fri, 22 Nov 2024 04:12:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tEPhj-0002AE-4R; Fri, 22 Nov 2024 04:11:55 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tEPhg-0000tb-LK; Fri, 22 Nov 2024 04:11:54 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 569385C59C4; Fri, 22 Nov 2024 09:11:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71CD1C4CED6; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l3n-0Q2F; Fri, 22 Nov 2024 10:11:43 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=6YF6O7FV32gcRBG0RLhIa4885AgC80LqdL+tPakkMdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lb332XM2ifwY0ztPjDw1L6LAkgS8ZYPt6aqAG3aWH5Wms8IaEHcY5OjyJNFKkZldO XjR138ysD02CL39unykzwDkGB3qNcD4OSrzDAeCd0AgOZvsPOykvVg4IJppUEvypIN WvGci1Yn/KaLCoTNSo+sF61ajOghAzaD08xj5yUAteMj/+eNPZtFEgfmVZqA1aasHf UAEcSFC0UO/FiZQq7mN4PXbqE5uCmuGyRTuDp+W8j/T7opfFhlN7O+j8stTtok36ZK OUS0wsj73jnaeDBM3R4MHpV1xvra1oW0UVasTMMhwWNBaNavVJMVtyLCdHTJufuDep wTaYqhn2Ynehw== From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 06/15] acpi/ghes: Remove a duplicated out of bounds check Date: Fri, 22 Nov 2024 10:11:23 +0100 Message-ID: <1aae261ad685e3d50fa8fbe530b9e3c677ec28e4.1732266152.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=139.178.84.217; envelope-from=mchehab+huawei@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -71 X-Spam_score: -7.2 X-Spam_bar: ------- X-Spam_report: (-7.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1732266757236116600 Content-Type: text/plain; charset="utf-8" acpi_ghes_record_errors() has an assert() at the beginning to ensure that source_id will be lower than ACPI_GHES_ERROR_SOURCE_COUNT. Remove a duplicated check. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Igor Mammedov Reviewed-by: Jonathan Cameron --- hw/acpi/ghes.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 29cd7e4d8171..5f67322bf0f2 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -404,9 +404,7 @@ int acpi_ghes_record_errors(uint8_t source_id, uint64_t= physical_address) return -1; } =20 - if (source_id < ACPI_GHES_ERROR_SOURCE_COUNT) { - start_addr +=3D source_id * sizeof(uint64_t); - } + start_addr +=3D source_id * sizeof(uint64_t); =20 cpu_physical_memory_read(start_addr, &error_block_addr, sizeof(error_block_addr)); --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 E5708175D44 for ; Fri, 22 Nov 2024 09:11:48 +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=1732266709; cv=none; b=buitZDSn18WSxOjyAV3MKH7YEvVQl3RKMfA8UIy+bEBXbfZD0msUEK2H+lV6mekb6bgrlfDMqAR/GIPoSseZ4Venf2DvVAodRERFnzXbysEjSoWJ1l0LnB/cssgUJNGb7yqtI17NFXq7cqezgaZv9nh5N0j9yGQOMYkvmDb67Rg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266709; c=relaxed/simple; bh=x/EqlciAexRjOLdohp886lYLI6VXFWugrEheoNJPLkw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C3aqt1eWZWAiEf/V05SQTrpbFqfOmyHFKlKy9s0TuARvMWglYcxvgB2AC4drKDeJetqlC5qn0P8xmuqIPQ7LQ4a/VcRgT0OCVUJdiOrcBkVcN8vvgZqpfF0kUSblcsbyYrXs5QQh0/rFJASk9jmFsvRhyjkQF28dxrD9ETtvEsk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JGc6myAp; 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="JGc6myAp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E9B9C4CED3; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=x/EqlciAexRjOLdohp886lYLI6VXFWugrEheoNJPLkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JGc6myApwGSDIhgTQWYRAImRb4EIXwiP63pKoNIVOT5VTOaAiSYeE9o9W+8PZITTH ap6NWMSWtQL8kZ6A+42PirfvRPhtfE/bPoWk/1NjAnvNzK3jvtgXlKqDDa+m5QJnU6 aLcSy/NT7Ni8wFoW19L/h+wYDxgi9MYctEmB1A+abDDUC9l6wteaqLs0d7PFyCFDSG VO2jIYisbV7vex+//Xswf7TKmhbNre5M3OENKkh3CNFmJTPyfw6tbUHo7CduEYXy/y SAuNpUfOBd2M/6Ie+pq/aem2lOpoqFYpBi4Fhr9RU6YOMl5DTPFUSDDYxDzPmjNcbX nwIFtDR934BAA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l3q-0WlB; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 07/15] acpi/ghes: Change the type for source_id Date: Fri, 22 Nov 2024 10:11:24 +0100 Message-ID: <84475e30b69680d93697ec666214482e36cd8844.1732266152.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" As described at: ACPI 6.5 spec at: 18.3.2. ACPI Error Source In particular at GHES/GHESv2 table: Table 18.10 Generic Hardware Error Source Structure HEST source ID is actually a 16-bit value. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov --- hw/acpi/ghes-stub.c | 2 +- hw/acpi/ghes.c | 2 +- include/hw/acpi/ghes.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/acpi/ghes-stub.c b/hw/acpi/ghes-stub.c index c315de1802d6..2b64cbd2819a 100644 --- a/hw/acpi/ghes-stub.c +++ b/hw/acpi/ghes-stub.c @@ -11,7 +11,7 @@ #include "qemu/osdep.h" #include "hw/acpi/ghes.h" =20 -int acpi_ghes_record_errors(uint8_t source_id, uint64_t physical_address) +int acpi_ghes_record_errors(uint16_t source_id, uint64_t physical_address) { return -1; } diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 5f67322bf0f2..edc74c38bf8a 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -383,7 +383,7 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgStat= e *s, ags->present =3D true; } =20 -int acpi_ghes_record_errors(uint8_t source_id, uint64_t physical_address) +int acpi_ghes_record_errors(uint16_t source_id, uint64_t physical_address) { uint64_t error_block_addr, read_ack_register_addr, read_ack_register = =3D 0; uint64_t start_addr; diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 50e3a25ea384..9295e46be25e 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -73,7 +73,7 @@ void acpi_build_hest(GArray *table_data, GArray *hardware= _errors, 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 source_id, uint64_t error_physical_add= r); +int acpi_ghes_record_errors(uint16_t source_id, uint64_t error_physical_ad= dr); =20 /** * acpi_ghes_present: Report whether ACPI GHES table is present --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 4370F1D3576 for ; Fri, 22 Nov 2024 09:11:49 +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=1732266709; cv=none; b=ZmYqJlVttS0FBL5AWnTXOyPG42c4oUhSIGqbB6aOBBMccukhN2eNKZVUwk7ATXpZe3XY3VAR4Tu8I7w2wHWSgNrF+tTYXkdow+r/k8ppM0ywTCEg8cTnErWENeGUwY2cugWgX5GH+9y/A/RLjalfmifzAx7vTnojuWKrVdXaKHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266709; c=relaxed/simple; bh=FYQWzY1NWPvyS9B1hBT0JbqR6VKHzPMfLmHBfI6DjaA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QPTAURX3TKZKxf0iHvRNHt/GusKv1rQga/Fda1IogcWtughkJhUPxJJqwlwhObjxnmEtVy4ZJWKLObfb4PMZVHNMq5AOcsGkgN2akPBE2T3BTQlDfUKhIWRw+cQ7VK42g03okvXXtXSDs5xBavHBF6VOoGGENGNah56kjj2AhSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FBdxtJFq; 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="FBdxtJFq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 813AEC4CEDC; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=FYQWzY1NWPvyS9B1hBT0JbqR6VKHzPMfLmHBfI6DjaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FBdxtJFqvlFlqPYVFZTaeeWLK4y+Ktkj/mZtNoB683+AARAh9MW3/5vjnX4SDjrsW j635/QrNNbcRLCFU3e+kQ2F/MYYSrYr/jLfdABLVPIRPiEAObLUW/00LNbs7oJC4uS rDKBLbPYxyBedUXaMYyIIXrPU0i78C/cklMWjm9TWW2TWOhYVRdQCdf7ibAycMfPK9 mRjS2Jng5BPKnJxdeEDdbyy5Sx54yzDTa2oM+vzw2Ac+mDtFCTI8e9yqnpASeg7roU DQNR+XEtfy8htnHqUyN57EXDYZtoC22G8+CIvWqqO4/PZEctMTv7zuMU/WizknUk27 B1CVJClA4tqQg== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l3t-0ddk; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 08/15] acpi/ghes: make the GHES record generation more generic Date: Fri, 22 Nov 2024 10:11:25 +0100 Message-ID: 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" Split the code into separate functions to allow using the common CPER filling code by different error sources. The generic code was moved to ghes_record_cper_errors(), and ghes_gen_err_data_uncorrectable_recoverable() now contains only a logic to fill the Generic Error Data part of the record, as described at: ACPI 6.2: 18.3.2.7.1 Generic Error Data The remaining code to generate a memory error now belongs to acpi_ghes_record_errors() function. A further patch will give it a better name. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- hw/acpi/ghes.c | 131 ++++++++++++++++++++++++----------------- include/hw/acpi/ghes.h | 3 + 2 files changed, 79 insertions(+), 55 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index edc74c38bf8a..a96856d5110b 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -181,51 +181,24 @@ static void acpi_ghes_build_append_mem_cper(GArray *t= able, build_append_int_noprefix(table, 0, 7); } =20 -static int acpi_ghes_record_mem_error(uint64_t error_block_address, - uint64_t error_physical_addr) +static void +ghes_gen_err_data_uncorrectable_recoverable(GArray *block, + const uint8_t *section_type, + int data_length) { - GArray *block; - - /* Memory Error Section Type */ - const uint8_t uefi_cper_mem_sec[] =3D - UUID_LE(0xA5BC1114, 0x6F64, 0x4EDE, 0xB8, 0x63, 0x3E, 0x83, \ - 0xED, 0x7C, 0x83, 0xB1); - /* invalid fru id: ACPI 4.0: 17.3.2.6.1 Generic Error Data, * Table 17-13 Generic Error Data Entry */ QemuUUID fru_id =3D {}; - uint32_t data_length; - - block =3D g_array_new(false, true /* clear */, 1); - - /* This is the length if adding a new generic error data entry*/ - data_length =3D ACPI_GHES_DATA_LENGTH + ACPI_GHES_MEM_CPER_LENGTH; - /* - * It should not run out of the preallocated memory if adding a new ge= neric - * error data entry - */ - assert((data_length + ACPI_GHES_GESB_SIZE) <=3D - ACPI_GHES_MAX_RAW_DATA_LENGTH); =20 /* Build the new generic error status block header */ acpi_ghes_generic_error_status(block, ACPI_GEBS_UNCORRECTABLE, 0, 0, data_length, ACPI_CPER_SEV_RECOVERABLE); =20 /* Build this new generic error data entry header */ - acpi_ghes_generic_error_data(block, uefi_cper_mem_sec, + acpi_ghes_generic_error_data(block, section_type, ACPI_CPER_SEV_RECOVERABLE, 0, 0, ACPI_GHES_MEM_CPER_LENGTH, fru_id, 0); - - /* Build the memory section CPER for above new generic error data entr= y */ - acpi_ghes_build_append_mem_cper(block, error_physical_addr); - - /* Write the generic error data entry into guest memory */ - cpu_physical_memory_write(error_block_address, block->data, block->len= ); - - g_array_free(block, true); - - return 0; } =20 /* @@ -383,15 +356,18 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgSt= ate *s, ags->present =3D true; } =20 -int acpi_ghes_record_errors(uint16_t source_id, uint64_t physical_address) +void ghes_record_cper_errors(const void *cper, size_t len, + uint16_t source_id, Error **errp) { uint64_t error_block_addr, read_ack_register_addr, read_ack_register = =3D 0; uint64_t start_addr; - bool ret =3D -1; AcpiGedState *acpi_ged_state; AcpiGhesState *ags; =20 - assert(source_id < ACPI_GHES_ERROR_SOURCE_COUNT); + if (len > ACPI_GHES_MAX_RAW_DATA_LENGTH) { + error_setg(errp, "GHES CPER record is too big: %ld", len); + return; + } =20 acpi_ged_state =3D ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED, NULL)); @@ -400,16 +376,16 @@ int acpi_ghes_record_errors(uint16_t source_id, uint6= 4_t physical_address) =20 start_addr =3D le64_to_cpu(ags->ghes_addr_le); =20 - if (!physical_address) { - return -1; - } - start_addr +=3D source_id * sizeof(uint64_t); =20 cpu_physical_memory_read(start_addr, &error_block_addr, sizeof(error_block_addr)); =20 error_block_addr =3D le64_to_cpu(error_block_addr); + if (!error_block_addr) { + error_setg(errp, "can not find Generic Error Status Block"); + return; + } =20 read_ack_register_addr =3D start_addr + ACPI_GHES_ERROR_SOURCE_COUNT * sizeof(uint64_= t); @@ -419,24 +395,69 @@ int acpi_ghes_record_errors(uint16_t source_id, uint6= 4_t physical_address) =20 /* zero means OSPM does not acknowledge the error */ if (!read_ack_register) { - error_report("OSPM does not acknowledge previous error," - " so can not record CPER for current error anymore"); - } else if (error_block_addr) { - read_ack_register =3D cpu_to_le64(0); - /* - * Clear the Read Ack Register, OSPM will write it to 1 when - * it acknowledges this error. - */ - cpu_physical_memory_write(read_ack_register_addr, - &read_ack_register, sizeof(uint64_t)); - - ret =3D acpi_ghes_record_mem_error(error_block_addr, - physical_address); - } else { - error_report("can not find Generic Error Status Block"); + error_setg(errp, + "OSPM does not acknowledge previous error," + " so can not record CPER for current error anymore"); + return; } =20 - return ret; + read_ack_register =3D cpu_to_le64(0); + /* + * Clear the Read Ack Register, OSPM will write it to 1 when + * it acknowledges this error. + */ + cpu_physical_memory_write(read_ack_register_addr, + &read_ack_register, sizeof(uint64_t)); + + /* Write the generic error data entry into guest memory */ + cpu_physical_memory_write(error_block_addr, cper, len); + + return; +} + +int acpi_ghes_record_errors(uint16_t source_id, uint64_t physical_address) +{ + /* Memory Error Section Type */ + const uint8_t guid[] =3D + UUID_LE(0xA5BC1114, 0x6F64, 0x4EDE, 0xB8, 0x63, 0x3E, 0x83, \ + 0xED, 0x7C, 0x83, 0xB1); + Error *errp =3D NULL; + int data_length; + GArray *block; + + if (!physical_address) { + error_report("can not find Generic Error Status Block for source i= d %d", + source_id); + return -1; + } + + block =3D g_array_new(false, true /* clear */, 1); + + data_length =3D ACPI_GHES_DATA_LENGTH + ACPI_GHES_MEM_CPER_LENGTH; + /* + * It should not run out of the preallocated memory if adding a new ge= neric + * error data entry + */ + assert((data_length + ACPI_GHES_GESB_SIZE) <=3D + ACPI_GHES_MAX_RAW_DATA_LENGTH); + + ghes_gen_err_data_uncorrectable_recoverable(block, guid, + data_length); + + /* Build the memory section CPER for above new generic error data entr= y */ + acpi_ghes_build_append_mem_cper(block, physical_address); + + /* Report the error */ + ghes_record_cper_errors(block->data, block->len, source_id, &errp); + + g_array_free(block, true); + + if (errp) { + error_report_err(errp); + return -1; + } + + return 0; } =20 bool acpi_ghes_present(void) diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 9295e46be25e..8859346af51a 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -23,6 +23,7 @@ #define ACPI_GHES_H =20 #include "hw/acpi/bios-linker-loader.h" +#include "qapi/error.h" =20 /* * Values for Hardware Error Notification Type field @@ -73,6 +74,8 @@ void acpi_build_hest(GArray *table_data, GArray *hardware= _errors, const char *oem_id, const char *oem_table_id); void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s, GArray *hardware_errors); +void ghes_record_cper_errors(const void *cper, size_t len, + uint16_t source_id, Error **errp); int acpi_ghes_record_errors(uint16_t source_id, uint64_t error_physical_ad= dr); =20 /** --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 16EA718B473; Fri, 22 Nov 2024 09:11:49 +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=1732266709; cv=none; b=Jfq0YHmYywESOwzRFAzdSta3YRHzRTgx9nufgqiDJn6RVnvz+2ga/8jyzmkWrE+i6XszMG5fDV/BRAeoLD/zggy79zySLO7PjuIwdKAEVXs6vNVvWHeQ03hN2Tdjw0XthdcohOIh7nrnXPgDkZ993kRL7M2TfG7ADLOMFcQrW0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266709; c=relaxed/simple; bh=YzIb4ozSuFNohYnKeFqJQnA1QpxzdVirBPJofbxJBPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DUg2Og0Qm0REI0ul9kqRonap9wv4CUdPD7htiOaw1CV3CpH3RuaRrOUrUT12kHa95mleJZjNK1NjuFYYJh22Y/ToM35w945KICKDiivDKmlzLNmVPNhqmd3y/NN9bR6p/PlygEm2jYyRlvrrLq66AEvcQ+3kKJpEnb8zn0r3nSU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YEA3vhEA; 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="YEA3vhEA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8061FC4CED9; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=YzIb4ozSuFNohYnKeFqJQnA1QpxzdVirBPJofbxJBPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YEA3vhEAFqa2niH2eyMKUIKbJBypKF9Qv9pK7hC777v0Y1pe+175Y7EUALpEJa7Fy /FSJa/Cxe4j43RkcyQQEMYPgRR5nEO5F+N55DimDkvNdGqGjhUSHr+IXh2B9mdPJWk +mJnPCWJwk6TKVToXoMr5M5WgwyAI/7l51bAhEWta7gBcQKL0d+gIpKyrflW3yq6rM DkYKUgnXqt92p60aRWI+q7n1QW9/H14AJAO6neVmR4h4SLmGqx8jme5SLCwBPZ99Ss +ziUetiOakNBOH3ZNaLKrpiDbHqM0C1fFzTS90bHLKtGBSzLs3GvZQ+wGtgljMfnNT gPiEfRFCoTefw== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l3w-0kjr; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , Paolo Bonzini , Peter Maydell , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 09/15] acpi/ghes: better name GHES memory error function Date: Fri, 22 Nov 2024 10:11:26 +0100 Message-ID: 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" The current function used to generate GHES data is specific for memory errors. Give a better name for it, as we now have a generic function as well. Reviewed-by: Igor Mammedov Reviewed-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab --- hw/acpi/ghes-stub.c | 2 +- hw/acpi/ghes.c | 2 +- include/hw/acpi/ghes.h | 4 ++-- target/arm/kvm.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/acpi/ghes-stub.c b/hw/acpi/ghes-stub.c index 2b64cbd2819a..7cec1812dad9 100644 --- a/hw/acpi/ghes-stub.c +++ b/hw/acpi/ghes-stub.c @@ -11,7 +11,7 @@ #include "qemu/osdep.h" #include "hw/acpi/ghes.h" =20 -int acpi_ghes_record_errors(uint16_t source_id, uint64_t physical_address) +int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) { return -1; } diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index a96856d5110b..ad7d895def2a 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -415,7 +415,7 @@ void ghes_record_cper_errors(const void *cper, size_t l= en, return; } =20 -int acpi_ghes_record_errors(uint16_t source_id, uint64_t physical_address) +int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) { /* Memory Error Section Type */ const uint8_t guid[] =3D diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 8859346af51a..21666a4bcc8b 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -74,15 +74,15 @@ void acpi_build_hest(GArray *table_data, GArray *hardwa= re_errors, 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_memory_errors(uint16_t source_id, uint64_t error_physical_ad= dr); void ghes_record_cper_errors(const void *cper, size_t len, uint16_t source_id, Error **errp); -int acpi_ghes_record_errors(uint16_t source_id, uint64_t error_physical_ad= dr); =20 /** * acpi_ghes_present: Report whether ACPI GHES table is present * * Returns: true if the system has an ACPI GHES table and it is - * safe to call acpi_ghes_record_errors() to record a memory error. + * safe to call acpi_ghes_memory_errors() to record a memory error. */ bool acpi_ghes_present(void); #endif diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 7b6812c0de2e..b4260467f8b9 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2387,7 +2387,7 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, v= oid *addr) */ if (code =3D=3D BUS_MCEERR_AR) { kvm_cpu_synchronize_state(c); - if (!acpi_ghes_record_errors(ACPI_HEST_SRC_ID_SEA, paddr))= { + if (!acpi_ghes_memory_errors(ACPI_HEST_SRC_ID_SEA, paddr))= { kvm_inject_arm_sea(c); } else { error_report("failed to record the error"); --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 E56C117107F for ; Fri, 22 Nov 2024 09:11:48 +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=1732266709; cv=none; b=QzxAzpEGOphSDw05kU/iuy80RpGvtsN6mGhT4XvTH8llS6W3VzABq4Ao+1TXHSKh1LvOXQmheXXrrokc+kw7zzNjOkl6+YIVMNSACWcK+Y5FJ/IodD0wGtnubz+f62bEpvzmhPaa08aQwR82yYVjnbtlxDXed+krK/EJhYmI/p8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266709; c=relaxed/simple; bh=0AQUDLyqeERjbSqSRvCL78HkKAIvkN74meWRt+QvhBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LQIdvBh4WZMwLNF2qSzrG9tk13pA91f/H5YpMgSr2oVzSeUS1F9DM/GpgHW8mznxILN2XTMDeJA70Lq9chXtIN8bsqkWyD2WPE3Cr90tb31cR62NVyvPe5IxVx7XIdZ540MTYTupU3a3XAhahGcu1J2Za33g9GOame8W/aLdqno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cLd5FCWY; 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="cLd5FCWY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74351C4AF09; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=0AQUDLyqeERjbSqSRvCL78HkKAIvkN74meWRt+QvhBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cLd5FCWYYslwq3ct4I91L075lCQQTFwpn77DDvu64EA4rGJVXOea9VIZk9Ux+OIIR PBlcQ2y7ZljDH2VIf3ddXwbUEHGYvbiIsyTJSzOtXTI8kYu9NEDLgUBTrmr7TQrMIr T2K4TsZBL7kzLjQkUhIwRY2ne30NsRFn7k0RCgBWk/3g9m6Q6VT8KPjRkPl7IVJhY9 SribaSyqlgqjJFSysp9KjK4+5OydiXDKY4jGwqf89+V27b8m8psVZ9/dhBiZxrYaUB M3PuRixzTIzR6sl/6HGWs2I8N73o5OSBelohgNfZ2XiXknt5zEXuExdQL7N69lqQrS rx3FvdyQnFWMw== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l40-0rlY; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 10/15] acpi/ghes: don't crash QEMU if ghes GED is not found Date: Fri, 22 Nov 2024 10:11:27 +0100 Message-ID: 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" Make error handling within ghes_record_cper_errors() consistent, i.e. instead abort just print a error in case ghes GED is not found. Reviewed-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Igor Mammedov --- hw/acpi/ghes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index ad7d895def2a..25587f5fc9ab 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -371,7 +371,10 @@ void ghes_record_cper_errors(const void *cper, size_t = len, =20 acpi_ged_state =3D ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED, NULL)); - g_assert(acpi_ged_state); + if (!acpi_ged_state) { + error_setg(errp, "Can't find ACPI_GED object"); + return; + } ags =3D &acpi_ged_state->ghes_state; =20 start_addr =3D le64_to_cpu(ags->ghes_addr_le); --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 16EF018BBA0 for ; Fri, 22 Nov 2024 09:11:49 +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=1732266709; cv=none; b=XAG+4RWdRXFiBV0Xcs+aMSJVuWyplzzQSlx513Pa9acfFUx5H1/u0uQ71qI2vk+5HioBVOEIcgWhZUKbVDcvIowRhgCm0V5lmBUcYywN/yBjbkcOZoYUioxFFL8zxO2UAIpmo/RJOYTa4peGjMyRfkTlK/MRFT5UxKwPbVBQ0C4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266709; c=relaxed/simple; bh=x78e6XF7ieITH+Cf0HMK6FZFoSIze6WxQOLiEdcX0U0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QstfDiSoL6hZHDEI3BFikHn1K7JgAjeAlpULLs7jLy5ZKwoDiqr31VpK4mBqlvztajns2pjsKAxlghKzSSOWZ09WMcNNrxrlu9xcg6mEwdqcl1ktm2fkGuKveC5LMmk2YK3CjsjE/TclWITMxrXeM2buJ/bvcs9DJ5XntGh0SOg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K0Wo9b7w; 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="K0Wo9b7w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E9C4C4CEDA; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=x78e6XF7ieITH+Cf0HMK6FZFoSIze6WxQOLiEdcX0U0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K0Wo9b7wPyQ2TCSOVRBqAxnfw+/w2hJc8aygW4Vy51lJbpmQvJHY5b8RHO4JIN1yk ydsoPU6uwYW1u3YxV2UCa7Dl0m/f8IvtIgUe0bwpsQMV62+kHgBPLYW2GhBkxWyco7 JktI40GlRE+naQVx/XG4AWvWB9/068csswKWV1bddkyBLzzmpd1v7A6+D3sWpQOAUZ KhwMKXWv+in0G+jdVNFm+jM+kVYER11NWT8zfovVS+0ri76l25xwrTPkl5nvl/o8vz SGoX9ElaMIOWgUu9tSVGNlHUOPAYsGis+Ojk/Fj6U8dpPlSmRNGnfwWgZq1syQy1KT 5Ci3Y7VdaPuhA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l43-0yip; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 11/15] acpi/ghes: rename etc/hardware_error file macros Date: Fri, 22 Nov 2024 10:11:28 +0100 Message-ID: <741bccf9c6de5dadcbd2ed7b42e0da62e6a787d1.1732266152.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" Now that we have also have a file to store HEST data location, which is part of GHES, better name the file where CPER records are stored. No functional changes. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Igor Mammedov Reviewed-by: Jonathan Cameron --- hw/acpi/ghes.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 25587f5fc9ab..292c77e78a5a 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -28,8 +28,8 @@ #include "hw/nvram/fw_cfg.h" #include "qemu/uuid.h" =20 -#define ACPI_GHES_ERRORS_FW_CFG_FILE "etc/hardware_errors" -#define ACPI_GHES_DATA_ADDR_FW_CFG_FILE "etc/hardware_errors_addr" +#define ACPI_HW_ERROR_FW_CFG_FILE "etc/hardware_errors" +#define ACPI_HW_ERROR_ADDR_FW_CFG_FILE "etc/hardware_errors_addr" =20 /* The max size in bytes for one error block */ #define ACPI_GHES_MAX_RAW_DATA_LENGTH (1 * KiB) @@ -234,7 +234,7 @@ static void build_ghes_error_table(GArray *hardware_err= ors, BIOSLinker *linker) ACPI_GHES_MAX_RAW_DATA_LENGTH * ACPI_GHES_ERROR_SOURCE_COUNT); =20 /* Tell guest firmware to place hardware_errors blob into RAM */ - bios_linker_loader_alloc(linker, ACPI_GHES_ERRORS_FW_CFG_FILE, + bios_linker_loader_alloc(linker, ACPI_HW_ERROR_FW_CFG_FILE, hardware_errors, sizeof(uint64_t), false); =20 for (i =3D 0; i < ACPI_GHES_ERROR_SOURCE_COUNT; i++) { @@ -243,17 +243,21 @@ static void build_ghes_error_table(GArray *hardware_e= rrors, BIOSLinker *linker) * corresponding "Generic Error Status Block" */ bios_linker_loader_add_pointer(linker, - ACPI_GHES_ERRORS_FW_CFG_FILE, sizeof(uint64_t) * i, - sizeof(uint64_t), ACPI_GHES_ERRORS_FW_CFG_FILE, - error_status_block_offset + i * ACPI_GHES_MAX_RAW_DATA_LENGTH); + ACPI_HW_ERROR_FW_CFG_FILE, + sizeof(uint64_t) * i, + sizeof(uint64_t), + ACPI_HW_ERROR_FW_CFG_FILE, + error_status_block_offset + + i * ACPI_GHES_MAX_RAW_DATA_LENGTH); } =20 /* * tell firmware to write hardware_errors GPA into * hardware_errors_addr fw_cfg, once the former has been initialized. */ - bios_linker_loader_write_pointer(linker, ACPI_GHES_DATA_ADDR_FW_CFG_FI= LE, - 0, sizeof(uint64_t), ACPI_GHES_ERRORS_FW_CFG_FILE, 0); + bios_linker_loader_write_pointer(linker, ACPI_HW_ERROR_ADDR_FW_CFG_FIL= E, 0, + sizeof(uint64_t), + ACPI_HW_ERROR_FW_CFG_FILE, 0); } =20 /* Build Generic Hardware Error Source version 2 (GHESv2) */ @@ -290,8 +294,10 @@ static void build_ghes_v2(GArray *table_data, build_append_gas(table_data, AML_AS_SYSTEM_MEMORY, 0x40, 0, 4 /* QWord access */, 0); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, - address_offset + GAS_ADDR_OFFSET, sizeof(uint64_t), - ACPI_GHES_ERRORS_FW_CFG_FILE, source_id * sizeof(uint64_t)); + address_offset + GAS_ADDR_OFFSET, + sizeof(uint64_t), + ACPI_HW_ERROR_FW_CFG_FILE, + source_id * sizeof(uint64_t)); =20 /* Notification Structure */ build_ghes_hw_error_notification(table_data, notify); @@ -308,9 +314,11 @@ static void build_ghes_v2(GArray *table_data, build_append_gas(table_data, AML_AS_SYSTEM_MEMORY, 0x40, 0, 4 /* QWord access */, 0); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, - address_offset + GAS_ADDR_OFFSET, - sizeof(uint64_t), ACPI_GHES_ERRORS_FW_CFG_FILE, - (ACPI_GHES_ERROR_SOURCE_COUNT + source_id) * sizeof(uint64_t)); + address_offset + GAS_ADDR_OFFSET, + sizeof(uint64_t), + ACPI_HW_ERROR_FW_CFG_FILE, + (ACPI_GHES_ERROR_SOURCE_COUNT + source_= id) + * sizeof(uint64_t)); =20 /* * Read Ack Preserve field @@ -346,11 +354,11 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgSt= ate *s, GArray *hardware_error) { /* Create a read-only fw_cfg file for GHES */ - fw_cfg_add_file(s, ACPI_GHES_ERRORS_FW_CFG_FILE, hardware_error->data, + fw_cfg_add_file(s, ACPI_HW_ERROR_FW_CFG_FILE, hardware_error->data, hardware_error->len); =20 /* Create a read-write fw_cfg file for Address */ - fw_cfg_add_file_callback(s, ACPI_GHES_DATA_ADDR_FW_CFG_FILE, NULL, NUL= L, + fw_cfg_add_file_callback(s, ACPI_HW_ERROR_ADDR_FW_CFG_FILE, NULL, NULL, NULL, &(ags->ghes_addr_le), sizeof(ags->ghes_addr_le), false); =20 ags->present =3D true; --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 DCF5E16F824 for ; Fri, 22 Nov 2024 09:11:48 +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=1732266708; cv=none; b=FGCyvq1ClKpjEneviO2+xZFY6HeolUee5Cjpv28eZt9Ac8X8X2V/IdELju7reaG25E1eT3KVLVcTPyTCt00Sm2B68NK4k+IpWpUOo8v5b2JxWl2a4yaiTJj7QiqyJDpZsnnAppceVIc1LvPc/VO21RLbf4SC5roWH/0kgwwcQIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266708; c=relaxed/simple; bh=cnC/4PFJE/2cvBR4Q7/KZ6l55Niv58/LD5ZqxNIOM3A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dMvTjEqe9HB5kSrRGa029ClXu0GJ+JoDb7CZ63HM/oIFSltebuOWpsjy+1c3Kql+ONlY9HgMTm9cYrcmPusnSqbdKHw/oIsPsD98ysuKX0FKqhMVfke5uixwtiFojbwacMRFb5PJHsH3eh2nLPjqoObRGayEan1mknIdnxLl8Fg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cHhnWAhY; 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="cHhnWAhY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 692CFC4AF0B; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=cnC/4PFJE/2cvBR4Q7/KZ6l55Niv58/LD5ZqxNIOM3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cHhnWAhYZCSn3+zHWS5kYI7IAF8mBYUofwobG85xEqk0jlXf1So0dfVjdwOcVyZ16 T1A8w4HfOJwI6rUh6/oewiBYCZx93f8XPmqBzpe6uSK/hPeTcq6eF0y0qmUsWyG3t6 1RTThynw32RQyOIvwnnuGWo9lHuTVD+7Xql40G0FgSOlK4VL3B6OYfYAlPWq6z5nwc jJkmIpIv5aGa6RN/2sV6UaUFVj95qpMC5hkwAEy6pW3ujojZvtnE5Bs3VQ86h+EzJy VGEnBXmrIZf4QggSNFFkSI9xKQzqn5Vi6WmO7rfllbe58r5r+cDuOpBAff6Fivdaq1 O08VHlk00vO+g== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l46-15eY; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 12/15] acpi/ghes: better name the offset of the hardware error firmware Date: Fri, 22 Nov 2024 10:11:29 +0100 Message-ID: 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" The hardware error firmware is where HEST error structures are stored. Those can be GHESv2, but they can also be other types. Better name the location of the hardware error. No functional changes. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov --- hw/acpi/generic_event_device.c | 4 ++-- hw/acpi/ghes.c | 4 ++-- include/hw/acpi/ghes.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 663d9cb09380..17baf36132a8 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -364,7 +364,7 @@ static const VMStateDescription vmstate_ghes =3D { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (const VMStateField[]) { - VMSTATE_UINT64(ghes_addr_le, AcpiGhesState), + VMSTATE_UINT64(hw_error_le, AcpiGhesState), VMSTATE_END_OF_LIST() }, }; @@ -372,7 +372,7 @@ static const VMStateDescription vmstate_ghes =3D { static bool ghes_needed(void *opaque) { AcpiGedState *s =3D opaque; - return s->ghes_state.ghes_addr_le; + return s->ghes_state.hw_error_le; } =20 static const VMStateDescription vmstate_ghes_state =3D { diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 292c77e78a5a..87fd3feedd2a 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -359,7 +359,7 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgStat= e *s, =20 /* 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->ghes_addr_le), sizeof(ags->ghes_addr_le), false); + NULL, &(ags->hw_error_le), sizeof(ags->hw_error_le), false); =20 ags->present =3D true; } @@ -385,7 +385,7 @@ void ghes_record_cper_errors(const void *cper, size_t l= en, } ags =3D &acpi_ged_state->ghes_state; =20 - start_addr =3D le64_to_cpu(ags->ghes_addr_le); + start_addr =3D le64_to_cpu(ags->hw_error_le); =20 start_addr +=3D source_id * sizeof(uint64_t); =20 diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 21666a4bcc8b..39619a2457cb 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -65,7 +65,7 @@ enum { }; =20 typedef struct AcpiGhesState { - uint64_t ghes_addr_le; + uint64_t hw_error_le; bool present; /* True if GHES is present at all on this board */ } AcpiGhesState; =20 --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 E848C17BB1E for ; Fri, 22 Nov 2024 09:11:48 +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=1732266709; cv=none; b=TE91LLQakv/uJAibffm4+05tKKtr5wi5/nyy9lRnDuZDBfnW7/zMTT2JlC/uR7yltX3LbfmfeVWfq9JnRInglg520kaSo1CAhIns1qPcO6Ba4YETaVKTiLg/IMrEY1bMfBf9Ye16Mh9TVnrky+mVLxUt/q1rMDo79ORmu5Zsfyo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266709; c=relaxed/simple; bh=hJXdm+o+Qg2Q0Ak/9rfyKRugnUJHbORHdHLMHQnys24=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rRIhMtHKCtsQIKmSNSvXn3UVAr68N+1YjEvmwlwxT5sCvLgj9nqVV+JiUnDHm8fHI3mhVHs/5VjKoPCWYcPK3J9zRCqS788NoHfj0KGTT8yV0mqWYsc/3zGqPL/vXNULNiKtl3akL7JKmrSEsUZJivFFMLjdXBKaP0eLzUxIlfw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bXchZ+Py; 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="bXchZ+Py" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76C05C4CED1; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=hJXdm+o+Qg2Q0Ak/9rfyKRugnUJHbORHdHLMHQnys24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bXchZ+Pyl9gL0P0J3RAOfRkZGPQMToOi8b3/NLYLu6PDbUgyyFIyRnKOOtdj/vzmJ GLH5FEHFHYiG9p0S1NLcG85bIik3neETZ1TbG9qllnP079i0E8sJzK0oL0ADWhJRJI r3UZapF1u/5tdFcmTpYud6s9A+7uurEZh7u/Zaem9LnwHIVppFinV/NDjJxKzTL6yd /Zr3+qmSEwymL9VTS+tR4+SAkPOUGdPI2FMAOjfJVy0+hpgdGzMMvc65NxhHygebB0 hKdMlZdlAK9E40wzC1pbCVV8jV1TIBL2SJYkllY1rA65aqEJ4W7xLE9XvhJ+2FzmGy D5LOwh/BRtr7w== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l4A-1CV3; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 13/15] acpi/ghes: move offset calculus to a separate function Date: Fri, 22 Nov 2024 10:11:30 +0100 Message-ID: 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" Currently, CPER address location is calculated as an offset of the hardware_errors table. It is also badly named, as the offset actually used is the address where the CPER data starts, and not the beginning of the error source. Move the logic which calculates such offset to a separate function, in preparation for a patch that will be changing the logic to calculate it from the HEST table. While here, properly name the variable which stores the cper address. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- hw/acpi/ghes.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 87fd3feedd2a..d99697b20164 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -364,10 +364,37 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgSt= ate *s, ags->present =3D true; } =20 +static void get_hw_error_offsets(uint64_t ghes_addr, + uint64_t *cper_addr, + uint64_t *read_ack_register_addr) +{ + if (!ghes_addr) { + return; + } + + /* + * non-HEST version supports only one source, so no need to change + * the start offset based on the source ID. Also, we can't validate + * the source ID, as it is stored inside the HEST table. + */ + + cpu_physical_memory_read(ghes_addr, cper_addr, + sizeof(*cper_addr)); + + *cper_addr =3D le64_to_cpu(*cper_addr); + + /* + * As the current version supports only one source, the ack offset is + * just sizeof(uint64_t). + */ + *read_ack_register_addr =3D ghes_addr + + ACPI_GHES_ERROR_SOURCE_COUNT * sizeof(uint64_t); +} + void ghes_record_cper_errors(const void *cper, size_t len, uint16_t source_id, Error **errp) { - uint64_t error_block_addr, read_ack_register_addr, read_ack_register = =3D 0; + uint64_t cper_addr =3D 0, read_ack_register_addr =3D 0, read_ack_regis= ter; uint64_t start_addr; AcpiGedState *acpi_ged_state; AcpiGhesState *ags; @@ -389,18 +416,14 @@ void ghes_record_cper_errors(const void *cper, size_t= len, =20 start_addr +=3D source_id * sizeof(uint64_t); =20 - cpu_physical_memory_read(start_addr, &error_block_addr, - sizeof(error_block_addr)); + get_hw_error_offsets(start_addr, &cper_addr, &read_ack_register_addr); =20 - error_block_addr =3D le64_to_cpu(error_block_addr); - if (!error_block_addr) { + cper_addr =3D le64_to_cpu(cper_addr); + if (!cper_addr) { error_setg(errp, "can not find Generic Error Status Block"); return; } =20 - read_ack_register_addr =3D start_addr + - ACPI_GHES_ERROR_SOURCE_COUNT * sizeof(uint64_= t); - cpu_physical_memory_read(read_ack_register_addr, &read_ack_register, sizeof(read_ack_register)= ); =20 @@ -421,7 +444,7 @@ void ghes_record_cper_errors(const void *cper, size_t l= en, &read_ack_register, sizeof(uint64_t)); =20 /* Write the generic error data entry into guest memory */ - cpu_physical_memory_write(error_block_addr, cper, len); + cpu_physical_memory_write(cper_addr, cper, len); =20 return; } --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 DCF0215D5CA for ; Fri, 22 Nov 2024 09:11:48 +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=1732266708; cv=none; b=cDRb1GGyMWZsrEXtS0UXBFAD7oWpkd4tzoQqi+0qLdflr+kU4Q443laM37atFeO4gVLUgNDgKNOV46lJTERHa/CKkqsmLdIa2k84rwKUnex6v5yNRYqLYjyrfrGw9jR/tNcxZlEFAlUVY1bG+zSxniEXezdZDafstrobJsNT690= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266708; c=relaxed/simple; bh=Jpw03OAVmKrjW75U8f0KTzCuzLgX024dWth/Db/t5WE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bifAela9BIkYp4bwWtLf13NKefb4vTsYIUj4urvNGwbDK8tIm7RyHtz6nU1CFQzFheHWaDzBo4EN7uJitYvgSHp/pIKFgCuZlH2P2h0zdQfcz4ut121SqmFjizRqKdWs9h3U4ZC0W21k4Zo8XLEbY+/QUmQeftuTBCCgGma8XFQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R52bK5dT; 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="R52bK5dT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67097C4CED0; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=Jpw03OAVmKrjW75U8f0KTzCuzLgX024dWth/Db/t5WE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R52bK5dTR0zzen9fII3gqQNS4BqfPmKY2XVN7fqHlHtzQbv7MkRM2K9MvopXr1vCf JrAdzM/+ac6x4mKhoG4pfvxcJQLHXm+9cJIaXrOnhP+ZIWbysvHAIjlXnOKmBk8O7g 5NKQ9gGNm38HiSZUh5UcoaD8jd7C57ZHrBwKZuufAc5sgRj0s75iRpw3TPAMMY2L6u wdDq3Ho7VJWej2CilYvDFxWAN6XMHRJ9aC4eVrVRjfZYDfNM4/+d1aYTj+b5K+faC4 7aaC5xWOIktemQTzc12dMe0NQ256PFkZ3PiBUTEcDj5UfX+dIqVJLBgzKdVnMSJ6ok dTw5LBsCxW4dw== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l4E-1JNH; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 14/15] acpi/ghes: Change ghes fill logic to work with only one source Date: Fri, 22 Nov 2024 10:11:31 +0100 Message-ID: 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" Extending to multiple sources require a BIOS pointer to the beginning of the HEST table, which in turn requires a backward-compatible code. So, the current code supports only one source. Ensure that and simplify the code. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- hw/acpi/ghes.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index d99697b20164..b0b1865dc8d3 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -387,15 +387,13 @@ static void get_hw_error_offsets(uint64_t ghes_addr, * As the current version supports only one source, the ack offset is * just sizeof(uint64_t). */ - *read_ack_register_addr =3D ghes_addr + - ACPI_GHES_ERROR_SOURCE_COUNT * sizeof(uint64_t); + *read_ack_register_addr =3D ghes_addr + sizeof(uint64_t); } =20 void ghes_record_cper_errors(const void *cper, size_t len, uint16_t source_id, Error **errp) { uint64_t cper_addr =3D 0, read_ack_register_addr =3D 0, read_ack_regis= ter; - uint64_t start_addr; AcpiGedState *acpi_ged_state; AcpiGhesState *ags; =20 @@ -412,11 +410,9 @@ void ghes_record_cper_errors(const void *cper, size_t = len, } ags =3D &acpi_ged_state->ghes_state; =20 - start_addr =3D le64_to_cpu(ags->hw_error_le); - - start_addr +=3D source_id * sizeof(uint64_t); - - get_hw_error_offsets(start_addr, &cper_addr, &read_ack_register_addr); + assert(ACPI_GHES_ERROR_SOURCE_COUNT =3D=3D 1); + get_hw_error_offsets(le64_to_cpu(ags->hw_error_le), + &cper_addr, &read_ack_register_addr); =20 cper_addr =3D le64_to_cpu(cper_addr); if (!cper_addr) { --=20 2.47.0 From nobody Thu Nov 28 13:57:39 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 1931218BBA2 for ; Fri, 22 Nov 2024 09:11:49 +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=1732266709; cv=none; b=EvUMi8TnytdMA2ikDunhgM4qwWbbhlI6ctM3DormbRSCNWByvnaGr0e5sbBVM+N2KRc81jzeCdCW1b5xeXozTn647Iv5jlGJ1vnkR+vFrwJeMVFI9gDhoEGItE1MTVaVfLgNARwtDMgZscIPoNUxuMSMUbudvD27Xb2zJTpzNzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732266709; c=relaxed/simple; bh=3q4iw0X8CIIZSET8d9LVRHez80oiBXEYI6La10ZBs2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RUr6jSOUsC8RVNxbACO7ag5AhEtZgaeJf557oav+fSUDx4d/8kqcfAfqbnuoiUQ6/aKQ8z3F1NFJp4LlkAvgmTiF8s/Q62wxndLyruwZG76DqajQVA9QYRfONYGkfjpkmpr51h7AR4RsLjJlWm+TMfUEd6I5KoSCgacE6qHuAdE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jS8pVzYE; 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="jS8pVzYE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83057C4CEDB; Fri, 22 Nov 2024 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732266708; bh=3q4iw0X8CIIZSET8d9LVRHez80oiBXEYI6La10ZBs2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jS8pVzYEGdbIOf/LBSWmnly7FTCZTAoGJWxB97Cq7HFPyhat1ohlQdORYAPkhi5HE dalvTn3KTjHgFeLNYUHYUTXhqEGVQX4IG6xEQsJUUPakjtSgjrJzelsh80vWYjo/Zh QRBZJywblfOa6a3nEy9a7kf2m/4bN0iRZz4mwjvuzeBa3aHPV3fuiNpxelHY3D4STa 3FH1hbRbVi+QX4/U1UkaJ+uKFlJfsBGSAwvI8HDD34yS72BS3ndyRP972SvVSen6/6 2Ld64jsIh6b4/3UNPleUQhVTaOoBE+rkMQ2YXwwogJonp/wm6UPgTDjMkVpWxLah+9 gfA5MePoZ2iZQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tEPhX-00000006l4H-1Q5o; Fri, 22 Nov 2024 10:11:43 +0100 From: Mauro Carvalho Chehab To: Igor Mammedov Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , Dongjiu Geng , linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v4 15/15] docs: acpi_hest_ghes: fix documentation for CPER size Date: Fri, 22 Nov 2024 10:11:32 +0100 Message-ID: <3bfe6c991d187f48b9c34500be106296b9480059.1732266152.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" While the spec defines a CPER size of 4KiB for each record, currently it is set to 1KiB. Fix the documentation and add a pointer to the macro name there, as this may help to keep it updated. Signed-off-by: Mauro Carvalho Chehab Acked-by: Igor Mammedov Reviewed-by: Jonathan Cameron --- docs/specs/acpi_hest_ghes.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/specs/acpi_hest_ghes.rst b/docs/specs/acpi_hest_ghes.rst index 68f1fbe0a4af..c3e9f8d9a702 100644 --- a/docs/specs/acpi_hest_ghes.rst +++ b/docs/specs/acpi_hest_ghes.rst @@ -67,8 +67,10 @@ Design Details (3) The address registers table contains N Error Block Address entries and N Read Ack Register entries. The size for each entry is 8-byte. The Error Status Data Block table contains N Error Status Data Block - entries. The size for each entry is 4096(0x1000) bytes. The total size - for the "etc/hardware_errors" fw_cfg blob is (N * 8 * 2 + N * 4096) by= tes. + entries. The size for each entry is defined at the source code as + ACPI_GHES_MAX_RAW_DATA_LENGTH (currently 1024 bytes). The total size + for the "etc/hardware_errors" fw_cfg blob is + (N * 8 * 2 + N * ACPI_GHES_MAX_RAW_DATA_LENGTH) bytes. N is the number of the kinds of hardware error sources. =20 (4) QEMU generates the ACPI linker/loader script for the firmware. The --=20 2.47.0