From patchwork Tue Sep 22 09:56:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 11792025 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DE43139F for ; Tue, 22 Sep 2020 09:58:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CB41C2388B for ; Tue, 22 Sep 2020 09:58:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="rWRw0pGs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB41C2388B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKf4Q-000593-ST for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Sep 2020 05:58:46 -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) 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) 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) 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 = X86_CPU(cs); CPUX86State *cenv = &cpu->env; uint64_t *banks = cenv->mce_banks + 4 * params->bank; + char msg[64]; + bool need_reset = false; cpu_synchronize_state(cs); @@ -894,16 +896,25 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data) return; } - if ((cenv->mcg_status & MCG_STATUS_MCIP) || - !(cenv->cr[4] & CR4_MCE_MASK)) { - monitor_printf(params->mon, - "CPU %d: Previous MCE still in progress, raising" - " triple fault\n", - cs->cpu_index); - qemu_log_mask(CPU_LOG_RESET, "Triple fault\n"); + if (cenv->mcg_status & MCG_STATUS_MCIP) { + need_reset = true; + snprintf(msg, sizeof(msg), "CPU %d: Previous MCE still in progress," + " raising triple fault", cs->cpu_index); + } + + if (!(cenv->cr[4] & CR4_MCE_MASK)) { + need_reset = true; + snprintf(msg, sizeof(msg), "CPU %d: MCE capability is not enabled," + " 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 |= MCI_STATUS_OVER; } From patchwork Tue Sep 22 09:56:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 11792031 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3ECE1139F for ; Tue, 22 Sep 2020 10:00:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BEE0B2388B for ; Tue, 22 Sep 2020 10:00:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="RHzC4Fj5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEE0B2388B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKf5b-0007rB-TY for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Sep 2020 05:59:59 -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) 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) 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) 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 @MemoryFailureAction. +# +# 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 address +# 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), QEMU +# 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 mechanism, or +# guest disables MCE, or during previous MCE still in +# processing, an AR MCE occurs). QEMU has to raise a fault 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'} } From patchwork Tue Sep 22 09:56:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 11792033 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BCD56CB for ; Tue, 22 Sep 2020 10:00:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 21D752388B for ; Tue, 22 Sep 2020 10:00:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="RevQ/3fY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21D752388B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKf5l-00084p-3M for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Sep 2020 06:00:09 -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) 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) 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) 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 @@ */ #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 = &cpu->env; uint64_t *banks = cenv->mce_banks + 4 * params->bank; char msg[64]; + MemoryFailureFlags mf_flags = {0}; bool need_reset = false; 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 = true; + mf_flags.action_required = false; + mf_flags.has_recursive = true; + mf_flags.recursive = true; + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_GUEST_MCE_INJECT, + true, &mf_flags); return; } @@ -909,6 +917,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data) } 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] |= MCI_STATUS_OVER; } + + mf_flags.has_action_required = true; + mf_flags.action_required = !!(params->status & MCI_STATUS_AR); + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_GUEST_MCE_INJECT, + true, &mf_flags); } 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 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events-run-state.h" #include #include @@ -577,6 +578,8 @@ static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, int code) 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, void *addr) hardware_memory_error(addr); } - /* 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); } static void kvm_reset_exception(CPUX86State *env)