From nobody Wed May 8 20:18:51 2024 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=1600768744; cv=none; d=zohomail.com; s=zohoarc; b=QehHD2jJpVldBTRVOacMf9g0wa0KOOiHb1/yU8ehzg1LtDdD7eFw1r7E7mKtOF8y1pWnU4OYehLxfBnVlYWKhNI5e3Vf3fjfzY5rtUEqGdmpXpOXc26IepJDxpFPcal0lvPloKjzoAt4AY60dTi60FudUs6oU2kJnm9pTzit6ck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600768744; 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=uQrg1REyMjiUFdnwANv+hN+vv/GKYugaQbmL1Bq+zcc=; b=VXZ14YlpX3RfdctLJxCi24KGGt37ErsZhWSFjGRw580pkbGUfTt/gg6ZrQsGmfIhusboyrG5S5B+Bkh5eTo8Vj+4CgsSlVDqm9Z7vpoAG7CWsS6bLRrBtiGoeRnhD1lXyWuQLwCTjn/1APpdMuqSEVbMyKnXLvECr5eTRPwLsLs= 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 1600768744820764.7792958286159; Tue, 22 Sep 2020 02:59:04 -0700 (PDT) Received: from localhost ([::1]:42262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKf4h-000593-HG for importer@patchew.org; Tue, 22 Sep 2020 05:59:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKf2R-0002Jd-Kd for qemu-devel@nongnu.org; Tue, 22 Sep 2020 05:56:43 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:36964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kKf2P-0001s6-Ak for qemu-devel@nongnu.org; Tue, 22 Sep 2020 05:56:42 -0400 Received: by mail-pg1-x541.google.com with SMTP id l71so11525374pge.4 for ; Tue, 22 Sep 2020 02:56:40 -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.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Sep 2020 02:56:39 -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=uQrg1REyMjiUFdnwANv+hN+vv/GKYugaQbmL1Bq+zcc=; b=rWRw0pGsRJ+BAci003Wmj8VSnJYyjRMbniDuJvP0+7kyuBQNxTKMCFb3vKRqi8XVFQ hThsrEa1AGUEyCL6SdkLqjJ9V+BVz/q5fb2inyG/XaS+D9gEWRE4YJuA8Z3QZOv0MnTg kHARQ9phN6ftVCIBmW/l+iSktW6I61fe4TMtlYPO3JtxzOBP3v5GJmzcbmcvjm+P/rgy rFGbUNDPlsRjDQMVspVR/ZW0aDKv2K9ZNvvZ2yPFzs941sFzdKpmPmO85G0F0dLx7yE3 kTL1tug06MSbf8DBcY8NjlgQafZdUQX2Fyx5o6J5GuEOFz4YgEZtxyJJkgTg7PC3BUX2 N89g== 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=uQrg1REyMjiUFdnwANv+hN+vv/GKYugaQbmL1Bq+zcc=; b=e56aNNI8GN0MXAQDHBPhBFIOfYnKcOQFJpZ6beNFX1sXPGUMRJ5897bAPf/dhsx4mk jBVt/Z4HGSCA5ywrRGf7EPvMynVm/LKwj57XqLcJWF53VOFcn2NUoDJdRx6ndD7hl4Kj bekBDw37uRLisRPE5mztA0NERR5gFxoVowbhaHaD8A9tNC73RPuJpPpV3EgCccwrEBGF A7hqeZXBixQbLpU2xOe3KmcpDtmWewIMKRkJvVoG7Equfvx1ENeO3bB5G08UWzouiJPn KH2FmAvxsmHoVhvIXUVN6wGwcBJRk0EXc7NK2MU38CFSdXrDvCvXVzKJzkITpVX31HN0 q6DA== X-Gm-Message-State: AOAM533g+E8lvANZUPSIRT5Mz2OIXiYStU+HMi1uA8kIG6fUFsazSKB6 YZOgSU8QRlU5670QVxFVBk8xiyeDrGvocQ== X-Google-Smtp-Source: ABdhPJy/XWX2MaJcWGO4gr4SbWRkwzhHUb1rVrwbZzcMKz2TrLFkSxKSVUorPon4xJAks/orMW6WxA== X-Received: by 2002:a63:1925:: with SMTP id z37mr2897417pgl.23.1600768600121; Tue, 22 Sep 2020 02:56:40 -0700 (PDT) From: zhenwei pi To: pbonzini@redhat.com, peter.maydell@linaro.org Subject: [PATCH v2 1/3] target-i386: seperate MCIP & MCE_MASK error reason Date: Tue, 22 Sep 2020 17:56:28 +0800 Message-Id: <20200922095630.394893-2-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::541; envelope-from=pizhenwei@bytedance.com; helo=mail-pg1-x541.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" Previously we can only get a simple string "Triple fault" in qemu log. Add detailed message for the two reasons to describe why qemu has to reset the guest. Signed-off-by: zhenwei pi --- target/i386/helper.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/target/i386/helper.c b/target/i386/helper.c index 70be53e2c3..0c7fd32491 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -857,6 +857,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_= data data) X86CPU *cpu =3D X86_CPU(cs); CPUX86State *cenv =3D &cpu->env; uint64_t *banks =3D cenv->mce_banks + 4 * params->bank; + char msg[64]; + bool need_reset =3D false; =20 cpu_synchronize_state(cs); =20 @@ -894,16 +896,25 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cp= u_data data) return; } =20 - if ((cenv->mcg_status & MCG_STATUS_MCIP) || - !(cenv->cr[4] & CR4_MCE_MASK)) { - monitor_printf(params->mon, - "CPU %d: Previous MCE still in progress, raisin= g" - " triple fault\n", - cs->cpu_index); - qemu_log_mask(CPU_LOG_RESET, "Triple fault\n"); + if (cenv->mcg_status & MCG_STATUS_MCIP) { + need_reset =3D true; + snprintf(msg, sizeof(msg), "CPU %d: Previous MCE still in prog= ress," + " raising triple fault", cs->cpu_index); + } + + if (!(cenv->cr[4] & CR4_MCE_MASK)) { + need_reset =3D true; + snprintf(msg, sizeof(msg), "CPU %d: MCE capability is not enab= led," + " raising triple fault", cs->cpu_index); + } + + if (need_reset) { + monitor_printf(params->mon, "%s", msg); + qemu_log_mask(CPU_LOG_RESET, "%s\n", msg); qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); return; } + if (banks[1] & MCI_STATUS_VAL) { params->status |=3D MCI_STATUS_OVER; } --=20 2.11.0 From nobody Wed May 8 20:18:51 2024 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=1600768818; cv=none; d=zohomail.com; s=zohoarc; b=iZUm8WwRCxg8qcorkGGlY/7qfIPvGuMaIO73bNwCVma/FEVT7b09qziuruukem8aEhm2kOIEZwoiq2GJzGvR3yFORxufYeYHkx26JJ3tCXkbGUkvGbg2wD3liv76QAGnUor1I1IcLS23JtforrWok7Nfh4Dy6hOZxUEs/OWDFtw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600768818; 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=Uq/e3kDQ8bi9U/Y2eWtsT7JIOpjroHauOp1FhUJ+aGU=; b=gnZyQK2ZgNAyuZk+Eb5ZGgB+GvaALT16YhSUm5952rsRfud0tWaMevYspkCTNl307rZqtRvaswNsXV3i1V2/Oe/IAhzphfCixaw5v/mr+AwNxl5w5S+B+4WOjnqpuO98nUpFYNYhMxxLrfJ/Glr1zKRLZs3kD6cH2DmOd/eKxGk= 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 1600768818362175.99746096123624; Tue, 22 Sep 2020 03:00:18 -0700 (PDT) Received: from localhost ([::1]:49048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKf5t-0007rB-0G for importer@patchew.org; Tue, 22 Sep 2020 06:00:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKf2U-0002RR-JU for qemu-devel@nongnu.org; Tue, 22 Sep 2020 05:56:46 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:35423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kKf2S-0001sM-OG for qemu-devel@nongnu.org; Tue, 22 Sep 2020 05:56:46 -0400 Received: by mail-pf1-x42d.google.com with SMTP id k8so11968974pfk.2 for ; Tue, 22 Sep 2020 02:56:44 -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.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Sep 2020 02:56:42 -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=Uq/e3kDQ8bi9U/Y2eWtsT7JIOpjroHauOp1FhUJ+aGU=; b=RHzC4Fj5sQCX8L7J4kmLqjRuRELpu1LSqD/2iI+DmiopC03DRXBsOfen/d8R0Ks6n7 4fsF8UzRMLfLcLom/0xsz7JIXBK4v98RFS3krRGIf538WSR/bk389yX1iRlacqGDTAXZ IzA1WiBKJ6x/XNLpp/jzDMEAnKHNhD6WYoHDWu+IakGLh8RqR+NPDz1AKzKXn1HTbBo4 Q1R6Mn4HBFrXP0llXkVMA0aSwNqtn26/KJCtjKLJ5rHZVTcy9FYB9sCWamURArRNr/pA vC/lpOA44Mb4ow1TEZc/xNnUbkh3XSUnU1tPuh+m0UERAlBCC0qNo8Y3NJxDuBYl/OPB Gz3Q== 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=Uq/e3kDQ8bi9U/Y2eWtsT7JIOpjroHauOp1FhUJ+aGU=; b=NdlUjQbLM1y8PuNk0UWbkZv7NgdZd9ZCPdo2iOk6pFOryy4+PbKvutBvsLByuZfjAx zblR8eqlPn452RqXsO+wHeYHxcSGsKR7FMZpG+6KdjJZwwoLjzcW44vrK+hzNW3kH/TY PBmlnON03IvGQdgYT9QxpAgVJtlhNKRPkG2gntKiktgq75O+EMpXXbSfhxCqEo2jC++U xQAZm8HXNQpbOYebR2Jtj9ZrFoAS49GhRGCUiyVyXFbUx9zm+T4QScJQRrmQoHCf2q+p 4NoytC2hM2io5XldxImcN396oZ3nE0vUwgMlQ9IFnMT7DPQ9ACRs3G/1j/1SJo1g40p9 AveQ== X-Gm-Message-State: AOAM533DFBH/z8mkKmcmXtCD2ri4T9sKtTo5tKSIJSsaNKNGOABdvUyJ sW4zMpHo2X3f3SZ+u8j/1i5iDQ== X-Google-Smtp-Source: ABdhPJypq0QKnZwTRNlvH8UZz80TqziW0Jax8kXY1JyMopFmqGk741s7JVd93CGFEi+yPeeL7Nyyng== X-Received: by 2002:a63:1257:: with SMTP id 23mr2639600pgs.401.1600768603380; Tue, 22 Sep 2020 02:56:43 -0700 (PDT) From: zhenwei pi To: pbonzini@redhat.com, peter.maydell@linaro.org Subject: [PATCH v2 2/3] qapi/run-state.json: introduce memory failure event Date: Tue, 22 Sep 2020 17:56:29 +0800 Message-Id: <20200922095630.394893-3-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::42d; envelope-from=pizhenwei@bytedance.com; helo=mail-pf1-x42d.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" Introduce 4 memory failure events for a guest. Then uplayer could know when/why/what happened to a guest during hitting a hardware memory failure. Suggested by Peter Maydell, rename events name&description to make them architecture-neutral; and suggested by Paolo, add more info to distinguish a guest-mce is AR/AO. Signed-off-by: zhenwei pi --- qapi/run-state.json | 67 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 67 insertions(+) diff --git a/qapi/run-state.json b/qapi/run-state.json index 7cc9f96a5b..f40111ac67 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -475,3 +475,70 @@ 'psw-mask': 'uint64', 'psw-addr': 'uint64', 'reason': 'S390CrashReason' } } + +## +# @MEMORY_FAILURE: +# +# Emitted when a memory failure occurs on host side. +# +# @action: action that has been taken. action is defined as @MemoryFailure= Action. +# +# Since: 5.2 +# +# Example: +# +# <- { "event": "MEMORY_FAILURE", +# "data": { "action": "guest-mce" } } +# +## +{ 'event': 'MEMORY_FAILURE', + 'data': { 'action': 'MemoryFailureAction', + '*flags': 'MemoryFailureFlags'} } + +## +# @MemoryFailureAction: +# +# Hardware memory failure occurs, handled by QEMU. +# +# @hypervisor-ignore: action optional memory failure at QEMU process addre= ss +# space (none guest memory, but used by QEMU itself), = QEMU +# could ignore this hardware memory failure. +# +# @hypervisor-fatal: action required memory failure at QEMU process address +# space (none guest memory, but used by QEMU itself), Q= EMU +# has to stop itself. +# +# @guest-mce-inject: memory failure at guest memory, and guest enables MCE +# handling mechanism, QEMU injects MCE to guest. +# +# @guest-mce-fatal: memory failure at guest memory, but guest is not ready= to +# to handle MCE(typical cases: guest has no MCE mechanis= m, or +# guest disables MCE, or during previous MCE still in +# processing, an AR MCE occurs). QEMU has to raise a fau= lt and +# shutdown/reset. Also see detailed info in QEMU log. +# +# Since: 5.2 +# +## +{ 'enum': 'MemoryFailureAction', + 'data': [ 'hypervisor-ignore', + 'hypervisor-fatal', + 'guest-mce-inject', + 'guest-mce-fatal' ] } + +## +# @MemoryFailureFlags: +# +# Structure of flags for each memory failure event. +# +# @action-required: describe a MCE event as AR/AO. +# +# @recursive: previous MCE in processing in guest, another AO MCE +# occurs, set recursive as true. +# +# Since: 5.2 +# +## +{ 'struct': 'MemoryFailureFlags', + 'data': { '*action-required': 'bool', + '*recursive': 'bool'} } --=20 2.11.0 From nobody Wed May 8 20:18:51 2024 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