From patchwork Fri Feb 14 04:16:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 13974440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81248C02198 for ; Fri, 14 Feb 2025 04:18:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tin8Y-0005UV-4y; Thu, 13 Feb 2025 23:17:10 -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 1tin8W-0005TV-Dm for qemu-devel@nongnu.org; Thu, 13 Feb 2025 23:17:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tin8U-0002a1-TP for qemu-devel@nongnu.org; Thu, 13 Feb 2025 23:17:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739506626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S3agoQvsnbcvfV7G3jamsH1kPMbU1IplGMn7H+8CMW8=; b=A+kpJoKeizR80DcwIzH9wjW1BCi60uPU/2ibVBDoagA/MS7OE3m4PKlsEsuhHuHwKtLp4D /eiWBLqmkfFHEL4iKh3opvHBNS9HIna76Z2oGnyY9gyaKWvWM2rVxSUaTI0x3IiuF3PYq8 bp60Qa2s+/t6mAl7YJ9l/G7LkfarpFk= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-_wMW2OMBMvSecvsVl1r2Lw-1; Thu, 13 Feb 2025 23:17:03 -0500 X-MC-Unique: _wMW2OMBMvSecvsVl1r2Lw-1 X-Mimecast-MFC-AGG-ID: _wMW2OMBMvSecvsVl1r2Lw Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E6D8619373D9; Fri, 14 Feb 2025 04:17:01 +0000 (UTC) Received: from gshan-thinkpadx1nanogen2.remote.csb (unknown [10.64.136.82]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E161019373C4; Fri, 14 Feb 2025 04:16:57 +0000 (UTC) From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, gengdongjiu1@gmail.com, peter.maydell@linaro.org, pbonzini@redhat.com, shan.gavin@gmail.com Subject: [PATCH 1/4] acpi/ghes: Make ghes_record_cper_errors() static Date: Fri, 14 Feb 2025 14:16:32 +1000 Message-ID: <20250214041635.608012-2-gshan@redhat.com> In-Reply-To: <20250214041635.608012-1-gshan@redhat.com> References: <20250214041635.608012-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass client-ip=170.10.129.124; envelope-from=gshan@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.495, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org acpi_ghes_memory_errors() is the only caller, no need to expose the function. Besides, the last 'return' in this function isn't necessary and remove it. No functional changes intended. Signed-off-by: Gavin Shan --- hw/acpi/ghes.c | 6 ++---- include/hw/acpi/ghes.h | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index b709c177cd..b85bb48195 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -390,8 +390,8 @@ static void get_hw_error_offsets(uint64_t ghes_addr, *read_ack_register_addr = ghes_addr + sizeof(uint64_t); } -void ghes_record_cper_errors(const void *cper, size_t len, - uint16_t source_id, Error **errp) +static void ghes_record_cper_errors(const void *cper, size_t len, + uint16_t source_id, Error **errp) { uint64_t cper_addr = 0, read_ack_register_addr = 0, read_ack_register; AcpiGedState *acpi_ged_state; @@ -440,8 +440,6 @@ void ghes_record_cper_errors(const void *cper, size_t len, /* Write the generic error data entry into guest memory */ cpu_physical_memory_write(cper_addr, cper, len); - - return; } int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 39619a2457..578a582203 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -75,8 +75,6 @@ void acpi_build_hest(GArray *table_data, GArray *hardware_errors, 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_addr); -void ghes_record_cper_errors(const void *cper, size_t len, - uint16_t source_id, Error **errp); /** * acpi_ghes_present: Report whether ACPI GHES table is present From patchwork Fri Feb 14 04:16:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 13974438 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DD30C021A6 for ; Fri, 14 Feb 2025 04:17:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tin8b-0005V7-QD; Thu, 13 Feb 2025 23:17:14 -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 1tin8a-0005Uv-7q for qemu-devel@nongnu.org; Thu, 13 Feb 2025 23:17:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tin8Y-0002ag-Li for qemu-devel@nongnu.org; Thu, 13 Feb 2025 23:17:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739506629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZbItnDkVozEodj/7S5tjbmbvM9HBQCKzb05IAlMJY8E=; b=ZLSYeSEAKArlKZJEliss31WfR+rL6kFZl+p3idg7oPF0xIG0L7oUjYznLdxXEVxcaZJfeG mhCLNmX0rxNdAjCTvgFf3EBdxYGLgnsHucDQ+wCAEsopKfEJgFk+I25dGv5tLnfLjzrxlR HU6YpxGLHa3kanN/QlhKr+TbDqVXX/s= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-1lYm0kuqOtW4TFoXJ_T81g-1; Thu, 13 Feb 2025 23:17:07 -0500 X-MC-Unique: 1lYm0kuqOtW4TFoXJ_T81g-1 X-Mimecast-MFC-AGG-ID: 1lYm0kuqOtW4TFoXJ_T81g Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B09F31975AFC; Fri, 14 Feb 2025 04:17:06 +0000 (UTC) Received: from gshan-thinkpadx1nanogen2.remote.csb (unknown [10.64.136.82]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 97EC6191D7C8; Fri, 14 Feb 2025 04:17:02 +0000 (UTC) From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, gengdongjiu1@gmail.com, peter.maydell@linaro.org, pbonzini@redhat.com, shan.gavin@gmail.com Subject: [PATCH 2/4] acpi/ghes: Use error_report() in ghes_record_cper_errors() Date: Fri, 14 Feb 2025 14:16:33 +1000 Message-ID: <20250214041635.608012-3-gshan@redhat.com> In-Reply-To: <20250214041635.608012-1-gshan@redhat.com> References: <20250214041635.608012-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass client-ip=170.10.129.124; envelope-from=gshan@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.495, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org An error object is created by ghes_record_cper_errors() to collect the error messages in its failing path. The caller prints the error messages and determine its return value base on the error object. It's unnecessary to use an error object if the error number is returned by ghes_record_cper_errors() and the error messages are printed with error_report() in the function. It's the preparatory work to add parameter for ghes_record_cper_errors() to indicate if the request can be retried by its callers. No functional changes intended. Signed-off-by: Gavin Shan --- hw/acpi/ghes.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index b85bb48195..a67326fd50 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -390,23 +390,23 @@ static void get_hw_error_offsets(uint64_t ghes_addr, *read_ack_register_addr = ghes_addr + sizeof(uint64_t); } -static void ghes_record_cper_errors(const void *cper, size_t len, - uint16_t source_id, Error **errp) +static int ghes_record_cper_errors(const void *cper, size_t len, + uint16_t source_id) { uint64_t cper_addr = 0, read_ack_register_addr = 0, read_ack_register; AcpiGedState *acpi_ged_state; AcpiGhesState *ags; if (len > ACPI_GHES_MAX_RAW_DATA_LENGTH) { - error_setg(errp, "GHES CPER record is too big: %zd", len); - return; + error_report("GHES CPER record is too big: %zd", len); + return -1; } acpi_ged_state = ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED, NULL)); if (!acpi_ged_state) { - error_setg(errp, "Can't find ACPI_GED object"); - return; + error_report("Can't find ACPI_GED object"); + return -1; } ags = &acpi_ged_state->ghes_state; @@ -415,8 +415,8 @@ static void ghes_record_cper_errors(const void *cper, size_t len, &cper_addr, &read_ack_register_addr); if (!cper_addr) { - error_setg(errp, "can not find Generic Error Status Block"); - return; + error_report("can not find Generic Error Status Block"); + return -1; } cpu_physical_memory_read(read_ack_register_addr, @@ -424,10 +424,9 @@ static void ghes_record_cper_errors(const void *cper, size_t len, /* zero means OSPM does not acknowledge the error */ if (!read_ack_register) { - error_setg(errp, - "OSPM does not acknowledge previous error," - " so can not record CPER for current error anymore"); - return; + error_report("OSPM does not acknowledge previous error," + " so can not record CPER for current error anymore"); + return -1; } read_ack_register = cpu_to_le64(0); @@ -440,6 +439,8 @@ static void ghes_record_cper_errors(const void *cper, size_t len, /* Write the generic error data entry into guest memory */ cpu_physical_memory_write(cper_addr, cper, len); + + return 0; } int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) @@ -448,9 +449,8 @@ int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) const uint8_t guid[] = UUID_LE(0xA5BC1114, 0x6F64, 0x4EDE, 0xB8, 0x63, 0x3E, 0x83, \ 0xED, 0x7C, 0x83, 0xB1); - Error *errp = NULL; - int data_length; GArray *block; + int data_length, ret; block = g_array_new(false, true /* clear */, 1); @@ -468,16 +468,11 @@ int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) acpi_ghes_build_append_mem_cper(block, physical_address); /* Report the error */ - ghes_record_cper_errors(block->data, block->len, source_id, &errp); + ret = ghes_record_cper_errors(block->data, block->len, source_id); g_array_free(block, true); - if (errp) { - error_report_err(errp); - return -1; - } - - return 0; + return ret; } bool acpi_ghes_present(void) From patchwork Fri Feb 14 04:16:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 13974439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A35AC021A4 for ; Fri, 14 Feb 2025 04:17:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tin8k-0005WW-1b; Thu, 13 Feb 2025 23:17:22 -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 1tin8i-0005Vy-Dt for qemu-devel@nongnu.org; Thu, 13 Feb 2025 23:17:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tin8g-0002bJ-M9 for qemu-devel@nongnu.org; Thu, 13 Feb 2025 23:17:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739506636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1ZQkjM4kHbfBWA6DXLB1gENCQu/+ABtUZ4HwunpxUY4=; b=N3RXgD5JDVtbfLJsnFMPlKiFOIGQbL7mA9F+z2845yiz9VB/2W0ouBbw7Y8uD5LFW7LwOO K0GLeZ8sN27xDJWSoc9kupt/p1Z4w+xhbO3Fd5IJL71NKifn3EmBXXiCjiFhctv6SK9E3H FmhvaGqaWze4WrxsRvQHYjMB5TfQ6o4= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-265-L-QaMNBaPTSIhDrfb2TGvA-1; Thu, 13 Feb 2025 23:17:14 -0500 X-MC-Unique: L-QaMNBaPTSIhDrfb2TGvA-1 X-Mimecast-MFC-AGG-ID: L-QaMNBaPTSIhDrfb2TGvA_1739506633 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6F9191800872; Fri, 14 Feb 2025 04:17:12 +0000 (UTC) Received: from gshan-thinkpadx1nanogen2.remote.csb (unknown [10.64.136.82]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 51F1419373C4; Fri, 14 Feb 2025 04:17:07 +0000 (UTC) From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, gengdongjiu1@gmail.com, peter.maydell@linaro.org, pbonzini@redhat.com, shan.gavin@gmail.com Subject: [PATCH 3/4] acpi/ghes: Allow retry to write CPER errors Date: Fri, 14 Feb 2025 14:16:34 +1000 Message-ID: <20250214041635.608012-4-gshan@redhat.com> In-Reply-To: <20250214041635.608012-1-gshan@redhat.com> References: <20250214041635.608012-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass client-ip=170.10.129.124; envelope-from=gshan@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.495, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Multiple CPER errors can be raised on multiple vCPUs at the same time. The error -1 is returned from ghes_record_cper_errors() and QEMU is terminated due to abort() in kvm_arch_on_sigbus_vcpu(). it isn't correct and expected behaviour since the affected vCPU can't proceed with execution. It's reasonable to retry if the reported error is transient, for example the previously reported CPER error isn't claimed by the guest. Add one more parameter (@retry_allowed) to acpi_ghes_memory_errors(), passed down to ghes_record_cper_errors(). The differentiated error number (1 or -1) is returned if the the previously reported CPER error hasn't been claimed by the guest. The caller will retry the request if the returned error number is 1. Signed-off-by: Gavin Shan --- hw/acpi/ghes-stub.c | 3 ++- hw/acpi/ghes.c | 12 +++++++++--- include/hw/acpi/ghes.h | 3 ++- target/arm/kvm.c | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hw/acpi/ghes-stub.c b/hw/acpi/ghes-stub.c index 7cec1812da..5c807afe21 100644 --- a/hw/acpi/ghes-stub.c +++ b/hw/acpi/ghes-stub.c @@ -11,7 +11,8 @@ #include "qemu/osdep.h" #include "hw/acpi/ghes.h" -int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) +int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address, + bool retry_allowed) { return -1; } diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index a67326fd50..60587f3c1b 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -391,7 +391,7 @@ static void get_hw_error_offsets(uint64_t ghes_addr, } static int ghes_record_cper_errors(const void *cper, size_t len, - uint16_t source_id) + uint16_t source_id, bool retry_allowed) { uint64_t cper_addr = 0, read_ack_register_addr = 0, read_ack_register; AcpiGedState *acpi_ged_state; @@ -424,6 +424,10 @@ static int ghes_record_cper_errors(const void *cper, size_t len, /* zero means OSPM does not acknowledge the error */ if (!read_ack_register) { + if (retry_allowed) { + return 1; + } + error_report("OSPM does not acknowledge previous error," " so can not record CPER for current error anymore"); return -1; @@ -443,7 +447,8 @@ static int ghes_record_cper_errors(const void *cper, size_t len, return 0; } -int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) +int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address, + bool retry_allowed) { /* Memory Error Section Type */ const uint8_t guid[] = @@ -468,7 +473,8 @@ int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) acpi_ghes_build_append_mem_cper(block, physical_address); /* Report the error */ - ret = ghes_record_cper_errors(block->data, block->len, source_id); + ret = ghes_record_cper_errors(block->data, block->len, + source_id, retry_allowed); g_array_free(block, true); diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 578a582203..1dad62100a 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -74,7 +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); -int acpi_ghes_memory_errors(uint16_t source_id, uint64_t error_physical_addr); +int acpi_ghes_memory_errors(uint16_t source_id, uint64_t error_physical_addr, + bool retry_allowed); /** * acpi_ghes_present: Report whether ACPI GHES table is present diff --git a/target/arm/kvm.c b/target/arm/kvm.c index da30bdbb23..5c0bf99aec 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, void *addr) */ if (code == BUS_MCEERR_AR) { kvm_cpu_synchronize_state(c); - if (!acpi_ghes_memory_errors(ACPI_HEST_SRC_ID_SEA, paddr)) { + if (!acpi_ghes_memory_errors(ACPI_HEST_SRC_ID_SEA, paddr, false)) { kvm_inject_arm_sea(c); } else { error_report("failed to record the error"); From patchwork Fri Feb 14 04:16:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 13974441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D300C02198 for ; Fri, 14 Feb 2025 04:18:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tin8n-0005XP-S6; Thu, 13 Feb 2025 23:17:25 -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 1tin8m-0005X2-Qo for qemu-devel@nongnu.org; Thu, 13 Feb 2025 23:17:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tin8k-0002bp-Nf for qemu-devel@nongnu.org; Thu, 13 Feb 2025 23:17:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739506641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iolx7A0Ajzzjyh5cu4UFGHh5xMOZN6VaWDOUZQUqAxI=; b=ekNvXHvtvDaSM8NhUYRtrxjGRKabwCeUYsgi5gzl2VRt8EpFAznslc7+M8VVDEievnjjXd EZKNarfHacL39xsfTua6fCONJz93Mw+36qSaYKfUlEGwXD02ShXeOyKSRhmjPpbp2hIqTe VTBMDrfUPNPz8w26BHNhrSl5PHXrcv0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-403-jL1QjvuwPtOobPtPcIrIRg-1; Thu, 13 Feb 2025 23:17:19 -0500 X-MC-Unique: jL1QjvuwPtOobPtPcIrIRg-1 X-Mimecast-MFC-AGG-ID: jL1QjvuwPtOobPtPcIrIRg Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EAE1F19373DC; Fri, 14 Feb 2025 04:17:17 +0000 (UTC) Received: from gshan-thinkpadx1nanogen2.remote.csb (unknown [10.64.136.82]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 15839191D7C8; Fri, 14 Feb 2025 04:17:12 +0000 (UTC) From: Gavin Shan To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, gengdongjiu1@gmail.com, peter.maydell@linaro.org, pbonzini@redhat.com, shan.gavin@gmail.com Subject: [PATCH 4/4] target/arm: Retry pushing CPER error if necessary Date: Fri, 14 Feb 2025 14:16:35 +1000 Message-ID: <20250214041635.608012-5-gshan@redhat.com> In-Reply-To: <20250214041635.608012-1-gshan@redhat.com> References: <20250214041635.608012-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass client-ip=170.10.129.124; envelope-from=gshan@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.495, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The error -1 is returned if the previously reported CPER error hasn't been claimed. The virtual machine is terminated due to abort(). It's conflicting to the ideal behaviour that the affected vCPU retries pushing the CPER error in this case since the vCPU can't proceed its execution. Move the chunk of code to push CPER error to a separate helper report_memory_errors() and retry the request when the return value from acpi_ghes_memory_errors() is greater than zero. Signed-off-by: Gavin Shan --- target/arm/kvm.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 5c0bf99aec..9f063f6053 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2362,6 +2362,30 @@ int kvm_arch_get_registers(CPUState *cs, Error **errp) return ret; } +static void report_memory_error(CPUState *c, hwaddr paddr) +{ + int ret; + + while (true) { + /* Retry if the previously report error hasn't been claimed */ + ret = acpi_ghes_memory_errors(ACPI_HEST_SRC_ID_SEA, paddr, true); + if (ret <= 0) { + break; + } + + bql_unlock(); + g_usleep(1000); + bql_lock(); + } + + if (ret == 0) { + kvm_inject_arm_sea(c); + } else { + error_report("Error %d to report memory error", ret); + abort(); + } +} + void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) { ram_addr_t ram_addr; @@ -2387,12 +2411,7 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) */ if (code == BUS_MCEERR_AR) { kvm_cpu_synchronize_state(c); - if (!acpi_ghes_memory_errors(ACPI_HEST_SRC_ID_SEA, paddr, false)) { - kvm_inject_arm_sea(c); - } else { - error_report("failed to record the error"); - abort(); - } + report_memory_error(c, paddr); } return; }