From nobody Sat Apr 5 01:25:18 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1739506709; cv=none; d=zohomail.com; s=zohoarc; b=aVQb+wloIA3xeK9egeXkD0/3WyXT8Mx23omKP9PEYWdFP4rAfcDpDSq5iHyr6wDEws2UpMU4kyWo8Qp2t16o6LdWtMfJQXNHbqKadkUey0kwWswffgXV9k6pKdgMnmRqQ0CErLfidiMaxnAxLld3o+Ylx0a0pxGFKIHzmk7Kxow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739506709; h=Content-Type: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=iolx7A0Ajzzjyh5cu4UFGHh5xMOZN6VaWDOUZQUqAxI=; b=SPN+D8eKDzF0ONfATY4r68qUNJzs5KkHZyJz7jaM3v4/+cZHALR/HFTOYZiD3b5WwsSk+C1Sp9haeVV4ehR6+z+Q8QbutCw9kwLn0HxHRkYo/kwjdpZ+ijQO+Luw5xepwnvXXcJ/mwWzYyfqbyX642qQ7UBdSmCo3e6pdBE3dQ8= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1739506709488275.6761953238059; Thu, 13 Feb 2025 20:18:29 -0800 (PST) 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 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 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) 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= X-MC-Unique: jL1QjvuwPtOobPtPcIrIRg-1 X-Mimecast-MFC-AGG-ID: jL1QjvuwPtOobPtPcIrIRg 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 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1739506710514019000 Content-Type: text/plain; charset="utf-8" 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 **err= p) return ret; } =20 +static void report_memory_error(CPUState *c, hwaddr paddr) +{ + int ret; + + while (true) { + /* Retry if the previously report error hasn't been claimed */ + ret =3D acpi_ghes_memory_errors(ACPI_HEST_SRC_ID_SEA, paddr, true); + if (ret <=3D 0) { + break; + } + + bql_unlock(); + g_usleep(1000); + bql_lock(); + } + + if (ret =3D=3D 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 =3D=3D 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; } --=20 2.48.1