From nobody Mon Feb 9 11:02:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1600768856; cv=none; d=zohomail.com; s=zohoarc; b=hy7DUab4E1wlLYtcZxVPkwPeyeCSa7LhDlR7B3MbTRjvBMMjoSc0YrC5OHYpaWxTD+s74QNX8At1OR8/ENkbufr3wIW6ZH5zm1PhRWNGysmHesUFzPmH+gfKGZDX1aSmuUX89xQCQ2n6hGwYZvulLtZP7HdKrgEhNF4Zb2Xo0ZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600768856; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=EHvZtj7O7tPXhkiMzmOQzfWVzNatukvByFnFp0mGAN4=; b=lj2+jR1BOY00Je9+kh6inxr+krEfKm5m8sp7mIEXP1qwZdp8lo3noJMj8guIcxTXX+oculb8EFaGToUeJ6DJtPMq+jnE0fqB5YY8y/cpWylDBZPcqgHDMf1U2ANqBMd4g8ugYoLphWYp0r0YSSTwphqYE3xEknFwm7/Pr/LiuAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160076885639667.26229813366524; Tue, 22 Sep 2020 03:00:56 -0700 (PDT) Received: from localhost ([::1]:49574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKf6V-00084p-5k for importer@patchew.org; Tue, 22 Sep 2020 06:00:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKf2X-0002UZ-In for qemu-devel@nongnu.org; Tue, 22 Sep 2020 05:56:49 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:39792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kKf2V-0001sc-Rn for qemu-devel@nongnu.org; Tue, 22 Sep 2020 05:56:49 -0400 Received: by mail-pf1-x444.google.com with SMTP id n14so11948403pff.6 for ; Tue, 22 Sep 2020 02:56:47 -0700 (PDT) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id e2sm2013239pjm.27.2020.09.22.02.56.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Sep 2020 02:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EHvZtj7O7tPXhkiMzmOQzfWVzNatukvByFnFp0mGAN4=; b=RevQ/3fYwNr92g+duuuVr1EkEjl0iZhd6Rqb1/LtNkUTxBasoWVWVkf0/MG1tmo8FJ ZfGYb9V/Ufsigk9ToB+JdVvRtsee084Pr/VK9KguGu5XvrVc5gbph7MquixNVi95GCQs eKOPJibKiCPsKVoKTc/mk8rOnrZUfq3TBFswVXXwYcVnwfO2v3VCFiDEcn3iBwKQExGe iBd9pKv/Vh19gaV9nrGpVjaCUiGy26I8srC9e52wwKBw9/ZohqFJH4BtkrR7FG0kc38Y SQVf34253g5KZtY6/NNUtOAju7X6TyRSevMdUxS7VriJH9eeWGXVz+vdQZ7e9X9atk2h XSPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EHvZtj7O7tPXhkiMzmOQzfWVzNatukvByFnFp0mGAN4=; b=b81qTqoqvphV2uE7dAAr/39GOKtdE2KsBu+WeAyXDZQf0UmVuAxNssmkC8IJ7qaNB/ D6ncV3ALj9RYD/P1BAYHbOzm5l5W5+whLmhvyccJnZQLgedZXR9pveSiTlYsuXx5Km3+ 7/+aeyHgF55HmmOTApw80nxE+V3UV5YclVt5LApqHysaf9IQlMn5/8OsOzbOO9MwGpdH Qzjx0k4GZxYYf9BydkqU0uzBlWyVRHXV74cnvF0SDRogECz24Ee2WV2jtCUz+0V8B/Z1 9h46hj04NNVCqGseSe3s8JUNe0C/o2RxDFWUc98XQgFIGjRQUrgwHsxXqVbuAoiNEclp V90g== X-Gm-Message-State: AOAM5304khSdTeTt9H50aaGgEFUhiy8ZjHEZm/NyfcZ5miYr5wak4nFd p2te0NuqjTXnIFn6Foz11qzHDg== X-Google-Smtp-Source: ABdhPJxAX5p0Y6fcgu9jFlxeeO+QZF/v78S6U/3zd6efRjHzAerkZRwrqyFiq5juE+SGFC0JotNKiw== X-Received: by 2002:a62:10a:0:b029:142:2501:39e1 with SMTP id 10-20020a62010a0000b0290142250139e1mr3404072pfb.48.1600768606657; Tue, 22 Sep 2020 02:56:46 -0700 (PDT) From: zhenwei pi To: pbonzini@redhat.com, peter.maydell@linaro.org Subject: [PATCH v2 3/3] target-i386: post memory failure event to uplayer Date: Tue, 22 Sep 2020 17:56:30 +0800 Message-Id: <20200922095630.394893-4-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200922095630.394893-1-pizhenwei@bytedance.com> References: <20200922095630.394893-1-pizhenwei@bytedance.com> 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=2607:f8b0:4864:20::444; envelope-from=pizhenwei@bytedance.com; helo=mail-pf1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mtosatti@redhat.com, armbru@redhat.com, pizhenwei@bytedance.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Post memory failure event to uplayer to handle hardware memory corrupted event. Rather than simple QEMU log, QEMU could report more effective message to uplayer. For example, guest crashes by MCE, selecting another host server is a better choice. Signed-off-by: zhenwei pi --- target/i386/helper.c | 15 +++++++++++++++ target/i386/kvm.c | 7 ++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/target/i386/helper.c b/target/i386/helper.c index 0c7fd32491..47823c29e4 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/qapi-events-run-state.h" #include "cpu.h" #include "exec/exec-all.h" #include "qemu/qemu-print.h" @@ -858,6 +859,7 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_= data data) CPUX86State *cenv =3D &cpu->env; uint64_t *banks =3D cenv->mce_banks + 4 * params->bank; char msg[64]; + MemoryFailureFlags mf_flags =3D {0}; bool need_reset =3D false; =20 cpu_synchronize_state(cs); @@ -869,6 +871,12 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu= _data data) if (!(params->flags & MCE_INJECT_UNCOND_AO) && !(params->status & MCI_STATUS_AR) && (cenv->mcg_status & MCG_STATUS_MCIP)) { + mf_flags.has_action_required =3D true; + mf_flags.action_required =3D false; + mf_flags.has_recursive =3D true; + mf_flags.recursive =3D true; + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_GUEST_MCE_INJ= ECT, + true, &mf_flags); return; } =20 @@ -909,6 +917,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_= data data) } =20 if (need_reset) { + qapi_event_send_memory_failure( + MEMORY_FAILURE_ACTION_GUEST_MCE_FATAL, false, NULL); monitor_printf(params->mon, "%s", msg); qemu_log_mask(CPU_LOG_RESET, "%s\n", msg); qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); @@ -934,6 +944,11 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu= _data data) } else { banks[1] |=3D MCI_STATUS_OVER; } + + mf_flags.has_action_required =3D true; + mf_flags.action_required =3D !!(params->status & MCI_STATUS_AR); + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_GUEST_MCE_INJECT, + true, &mf_flags); } =20 void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank, diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 9efb07e7c8..989889c291 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -14,6 +14,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events-run-state.h" #include #include =20 @@ -577,6 +578,8 @@ static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, i= nt code) =20 static void hardware_memory_error(void *host_addr) { + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_HYPERVISOR_FATAL, + false, NULL); error_report("QEMU got Hardware memory error at addr %p", host_addr); exit(1); } @@ -631,7 +634,9 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, voi= d *addr) hardware_memory_error(addr); } =20 - /* Hope we are lucky for AO MCE */ + /* Hope we are lucky for AO MCE, just notify a event */ + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_HYPERVISOR_IGNORE, + false, NULL); } =20 static void kvm_reset_exception(CPUX86State *env) --=20 2.11.0