From nobody Sat May 18 21:45:36 2024 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=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1601463511; cv=none; d=zohomail.com; s=zohoarc; b=LflnAxAgHl1rxIeZYqyedV4416sftb0HjoREpsKmjpa2tFc78x8yj1S36Hvrfgx2fzXGrJGiIUJ0Ij4NVXsN0UraZUqY4v5VRryqquFAG1O1W2czUc2GNipMmPD19QNDlRzXrPcV0GJrFaZKe9wA2BTGsVnlRaI8nB9/Ay+WZcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601463511; 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=qkISPEvs2HSa1jdrSv5pc1AMksIAz5SfeO1sHOXjAF0=; b=NAJaPjk3Ypqw0oNh/vX8ky5hWyWYGi7EqZifwVW7G0WWF4Q7O6hFUWx/TQW0UgHeYBwepY1pQXrpE9sma6ZWTbpzkkzM1yk813ChVdo/HMKOqQ9LYrnoMc+3WX4qyR1admVt7jVvgjU+Ywry9jYNx2rE0NlKijUam8YpzWMQvp0= 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=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 1601463511698716.198272244291; Wed, 30 Sep 2020 03:58:31 -0700 (PDT) Received: from localhost ([::1]:50130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNZ21-0006Xb-8Z for importer@patchew.org; Wed, 30 Sep 2020 06:08:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNYyj-0003Bb-Ag for qemu-devel@nongnu.org; Wed, 30 Sep 2020 06:04:53 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44208) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNYyf-0005Cn-Te for qemu-devel@nongnu.org; Wed, 30 Sep 2020 06:04:51 -0400 Received: by mail-pl1-x642.google.com with SMTP id j7so735528plk.11 for ; Wed, 30 Sep 2020 03:04:49 -0700 (PDT) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id c185sm1884230pfb.123.2020.09.30.03.04.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2020 03:04:48 -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=qkISPEvs2HSa1jdrSv5pc1AMksIAz5SfeO1sHOXjAF0=; b=dgiZWHYfH5Wa0+J5rsouL75Ha+UUEweanMxD4/8AenU67hSnUZ6B48yYLpen9twyM3 WhYiZjkemGPqj/AVWSXDawXJ1f5ps2JNkppwMHlGPxatifDXmaXA27hi5IRAQFsnQjhm AIJrzymeF6BRGF+o3LO0QpOtdlCI+xQIrsmym7lJSOehho1I9IpDU9T6iEGZM1PmdKsV oT8YkdKDPrm/oetIxvzIv4hY+XVEX7gphXebgKQtPb1lUcPbRoroc7O7n3SpkCC1IRYk 9mnk9CISOHsETod50aiAEYkzuuR/snzgcramVpJNMb+Dc/Bk58BKFjXOXLRRtf7YwmMR wc6w== 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=qkISPEvs2HSa1jdrSv5pc1AMksIAz5SfeO1sHOXjAF0=; b=OshJKK/Jho78oiw7INehZ4forYpWiuAxvLEQDUxogXQbSWTz3kPAPaXxEPxlh56ih9 BPNn2Jp44lDJrRm1lYkDMnvsQfXKZsqCRFdvOPA59akD8hr3IbPITnSbU5AV0aMIqhRK 6bsHwaC3ZVudhh5PIe+APpqc3vZNhrDWAsNf8yYk0NAjNZSAVFokhdERArFy1upi+oy6 9UVIGq08juX9jEaz2cyiM2KuNOSdOyMOe8PqPxs/rz5i/ZxchALZu555QiimwmcjpjA/ J08EuMXlVqv5qG5Q8jxitkyapZZyi3g4h50vmZxQr7gvCqVXhXXpETN3tPRsbq57oV/T /9/A== X-Gm-Message-State: AOAM530qfiQczXm4pwL7OpAhIYoTRMp3kFWdayczcSBm9cv5fP39OiS3 /3p/TP5cjkfk9RZ659gZEpu6JA== X-Google-Smtp-Source: ABdhPJxFjGJkaaLHaFpSoKkaYz/e5Rdh8dA9LeyVmXYAbzJM8hE2XRFkuetcfIh/hvNM+aDiTrRfFA== X-Received: by 2002:a17:90a:2dcd:: with SMTP id q13mr1799447pjm.202.1601460288737; Wed, 30 Sep 2020 03:04:48 -0700 (PDT) From: zhenwei pi To: pbonzini@redhat.com, peter.maydell@linaro.org Subject: [PATCH v3 1/3] target-i386: seperate MCIP & MCE_MASK error reason Date: Wed, 30 Sep 2020 18:04:38 +0800 Message-Id: <20200930100440.1060708-2-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200930100440.1060708-1-pizhenwei@bytedance.com> References: <20200930100440.1060708-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::642; envelope-from=pizhenwei@bytedance.com; helo=mail-pl1-x642.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: qemu-devel@nongnu.org, zhenwei pi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bytedance-com.20150623.gappssmtp.com) 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..17e1684ff9 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; + g_autofree char *msg =3D NULL; + 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; + msg =3D g_strdup_printf("CPU %d: Previous MCE still in progres= s, " + "raising triple fault", cs->cpu_index); + } + + if (!(cenv->cr[4] & CR4_MCE_MASK)) { + need_reset =3D true; + msg =3D g_strdup_printf("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 |=3D MCI_STATUS_OVER; } --=20 2.11.0 From nobody Sat May 18 21:45:36 2024 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=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1601465610; cv=none; d=zohomail.com; s=zohoarc; b=fQgJBrwJklo58MOxl1tFfbO/dL7JGQao9kXltkbKYFjpUa2EPLEQY3tImLvK181MmhdRY7TYMqCxDTz2yV+WTIMiBSldKiXM1Vub9uNuUPW1UCbMdOwxM9hO4DRaLOz0URXlqHn5U+GvE7RP07ktNb/PvkpgfD4DwaAvlmQq4hM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601465610; 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=+9cBS9q+xgUSdyMFawIlbdh6WJVyAxWj5RAwUseTc8A=; b=WQfrgbWvPhwnd2k4YKlGSWi7vQ/OCSQgREjkzsGykQfGWQk1YpPplLAMdOY/zwhdpVfwcT6jw9gm77YMM9yUdc+/ld4bSDFqWwn0jQEqyrHIcI3lkqMJwhp6SvYBuzeoOD6sNZF1QI3dIEdH8houaQCoXtvajSNX1CIlCTTsIFU= 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=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 1601465610741835.4854050980584; Wed, 30 Sep 2020 04:33:30 -0700 (PDT) Received: from localhost ([::1]:54362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNZ3L-0008Ho-MS for importer@patchew.org; Wed, 30 Sep 2020 06:09:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNYyk-0003Io-Fz for qemu-devel@nongnu.org; Wed, 30 Sep 2020 06:04:54 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:55902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNYyi-0005D2-Jn for qemu-devel@nongnu.org; Wed, 30 Sep 2020 06:04:54 -0400 Received: by mail-pj1-x102c.google.com with SMTP id q4so646847pjh.5 for ; Wed, 30 Sep 2020 03:04:52 -0700 (PDT) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id c185sm1884230pfb.123.2020.09.30.03.04.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2020 03:04:50 -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=+9cBS9q+xgUSdyMFawIlbdh6WJVyAxWj5RAwUseTc8A=; b=yqeAtQZ9/UiLRGqs2WOHGHimF8asXs95C+pXd3cpLCcjyP3fZ+zNHE1RQ3asLkU7CI e5J9avb2clZDMBVkMQqEf2sKfVrW5N03S7iYI3DUpeVIipbPiNvN3iuJI11SHN7RwVIX xMq86mfmEt5YTJR6qz5tEKhG647InUICT8g7sGVDbIHMJs1qAxM555k4UCIj7n7ebibq sHn1NUFjnR+iebIFbftO4iTDravzH3QUGsopVhl7m34h/BwgqlqDmOyJYj+ikyXD9fLL EomBtEg016nXky9gfeQLroLzsWnJwaFKc9hOdjBGDUjWeWwzXSmTaOu4u0+3iPbWQzgl iDKQ== 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=+9cBS9q+xgUSdyMFawIlbdh6WJVyAxWj5RAwUseTc8A=; b=bbCHrjRPpElRo4/c9x8wXiAE4y1EvKb6HVg1iyG3p1iiwhTXyVjemC98/9WRSl8qP6 clRu92ZMmFaYctn7VKuGKnAhF+FD2xDa7RryaXRrfLVOBixQdBpMtiH6zQt2jBr+nrCu HG3Hgg/NohHIds83jMnVqqWlXrTrWQkIL++OXSy1UuhNMQry3eMIbrP3cUy+wb9FeRrC bOOOtLB74wHgOD63fA9K2zSOB1jGfnZu6Jbt17X9zK/PXqqesVG8CeMIpggo0wDe4wjE nXB+50+ce+4bya0vvrzOoItZnkoW6uxizeca7S6hInx5Aa7l5zPmpHp5qo1RQUe3oalU 852Q== X-Gm-Message-State: AOAM531WUzfsYuM8Y1XvJG79jlVN+35TUufLAod7YzUayw3uc7YzSOCJ hkJGNvDYX0/wPIz/nVG7Xi9AzIIlmAPIjQ== X-Google-Smtp-Source: ABdhPJx0WImcJOY1rJGpv3ECsXXMaUKo7BIYErwQFF00ahw9xT4pixxqU4nDxloDs32yr8d2bQhfAQ== X-Received: by 2002:a17:90b:715:: with SMTP id s21mr1754885pjz.113.1601460291309; Wed, 30 Sep 2020 03:04:51 -0700 (PDT) From: zhenwei pi To: pbonzini@redhat.com, peter.maydell@linaro.org Subject: [PATCH v3 2/3] qapi/run-state.json: introduce memory failure event Date: Wed, 30 Sep 2020 18:04:39 +0800 Message-Id: <20200930100440.1060708-3-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200930100440.1060708-1-pizhenwei@bytedance.com> References: <20200930100440.1060708-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::102c; envelope-from=pizhenwei@bytedance.com; helo=mail-pj1-x102c.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: qemu-devel@nongnu.org, zhenwei pi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bytedance-com.20150623.gappssmtp.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Introduce memory failure events for hyperviso/guest . Then uplayer could know when/why/what happened 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 mce is AR/AO, previous mce is still processing in guest or not. Signed-off-by: zhenwei pi --- qapi/run-state.json | 85 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 85 insertions(+) diff --git a/qapi/run-state.json b/qapi/run-state.json index 7cc9f96a5b..d795dc21fc 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -475,3 +475,88 @@ 'psw-mask': 'uint64', 'psw-addr': 'uint64', 'reason': 'S390CrashReason' } } + +## +# @MEMORY_FAILURE: +# +# Emitted when a memory failure occurs on host side. +# +# @recipient: recipient is defined as @MemoryFailureRecipient. +# +# @action: action that has been taken. action is defined as @MemoryFailure= Action. +# +# @flags: flags for MemoryFailureAction. action is defined as @MemoryFailu= reFlags. +# +# Since: 5.2 +# +# Example: +# +# <- { "event": "MEMORY_FAILURE", +# "data": { "action": "guest-mce" } } +# +## +{ 'event': 'MEMORY_FAILURE', + 'data': { 'recipient': 'MemoryFailureRecipient', + 'action': 'MemoryFailureAction', + 'flags': 'MemoryFailureFlags'} } + +## +# @MemoryFailureRecipient: +# +# Hardware memory failure occurs, handled by recipient. +# +# @hypervisor: memory failure at QEMU process address space. +# (none guest memory, but used by QEMU itself). +# +# @guest: memory failure at guest memory, +# +# Since: 5.2 +# +## +{ 'enum': 'MemoryFailureRecipient', + 'data': [ 'hypervisor', + 'guest' ] } + + +## +# @MemoryFailureAction: +# +# Hardware memory failure occurs, action by QEMU. +# +# @ignore: action optional memory failure which could be ignored. +# +# @inject: memory failure at guest memory, and guest enables MCE handling +# mechanism, QEMU injects MCE to guest successfully. +# +# @fatal: action required memory failure occurs. If recipient is hypervior= , QEMU +# hits a fatal error and exits later. And if recipient is guest, Q= EMU +# tries to inject MCE to guest, but guest is not ready to handle M= CE +# (typical cases: guest has no MCE mechanism, or guest disables MC= E, +# or during previous MCE still in processing, an AR MCE occurs). Q= EMU +# has to raise a fault and shutdown/reset. Also see detailed info = in +# QEMU log. +# +# Since: 5.2 +# +## +{ 'enum': 'MemoryFailureAction', + 'data': [ 'ignore', + 'inject', + '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 Sat May 18 21:45:36 2024 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=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1601465595; cv=none; d=zohomail.com; s=zohoarc; b=Izwg2CC7zcX2m6nqwaJq2f9yk2sXI00uNqh2+QwFEFnwfuaZpkk7GdotyIEDn9HB8J4TN4ij5SFrRdhflUWMuSYFoM3BL1P/uKHKGmcfJ6SAE9iCdG8EEaC9lt9+4Le7/luN4azNv8aA+a5nhtLn2VKRyThgu+OaQmMyKLLyrhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601465595; 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=rNTLRO7eI/MsFc78yk63Tq1O7QMzt9xIGkepVz1ORQA=; b=ahKxPOopO+zNvTRtYAwt8e5xPQahwXbnSCpfLotJ6o2wrFHQh89gsL6FlmKsLRBygCSUWBJ815ObD6gP1eZMQpJy0qDVi2sPk63Ncsv6iqa9u8yHkFHhpQiATwkjgRfswXkat3MnKstsj9KIS1YYgqZQQ45s+yUKQBl8va+uXEg= 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=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 1601465595864658.3659498116607; Wed, 30 Sep 2020 04:33:15 -0700 (PDT) Received: from localhost ([::1]:35532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNZ8A-0003uF-59 for importer@patchew.org; Wed, 30 Sep 2020 06:14:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNYyn-0003Om-4I for qemu-devel@nongnu.org; Wed, 30 Sep 2020 06:04:57 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34535) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNYyl-0005DK-61 for qemu-devel@nongnu.org; Wed, 30 Sep 2020 06:04:56 -0400 Received: by mail-pf1-x441.google.com with SMTP id k13so870593pfg.1 for ; Wed, 30 Sep 2020 03:04:54 -0700 (PDT) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id c185sm1884230pfb.123.2020.09.30.03.04.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2020 03:04:53 -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=rNTLRO7eI/MsFc78yk63Tq1O7QMzt9xIGkepVz1ORQA=; b=RfdEwHOm/YtysAXRfe7WQW6Q4ZJNpK8yO+i/9mR3jxX+OVgJP6mkdNtKncDUHHL6HM mDQDlHtRVb7661IDKWnF+qQsco+esHlfWIc55TNHHcF+dvbdTIGjm2dtzUpuB686O+7N TwriZ6c4+WAZxxAOwawK0HDxkkvxstgpOJg54+cXBR8j/jPNiExY5Zs6rAw9DJ69rK9z C/OVMfFxSKt1P/lSw4UrGmJojpdkC0FBz62UqhQ3o2iiaKnSRxbniyqmVjYwDfwmoXMq 3bO6yDIVqtUugZAwHVod2CAaaXcIGUm1DPwZ/CyTpo2Sl8ru9eTkDyHTD6tXhkuZrPR+ Nr+g== 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=rNTLRO7eI/MsFc78yk63Tq1O7QMzt9xIGkepVz1ORQA=; b=GICtNV7/AWDQR4/6VaA8PJ0yAf/7AzomgbifSy4ez7n4EnmPslqy8LvgN0jb3EjXbY oBnX0nwx2t8ac/m6a06syFHzjDmJ6iYRcLtWm3ikosbmduZ4ZbJDrCX5JdNyj/AStoMK PXZ5RWXl4LqI1pjrjoXNJV3oL8EB319rY+UnaZwhf8zDWxQvbkrLU3Acgno6OwW6+eQm Wvur/BSL7om0aw8MTXsGb7fvzEPpp291E8sRJSuHlPu021UQG3Rwni051d2FSCfQbM5Q AJ875Hde0oPrNWDufJW/S/MsP1EYnDVKR3HAQzusoU7DUVpHyYHWChSNmAYHOy6SKnxi u+bg== X-Gm-Message-State: AOAM532QBHFIJoDP3KtY74VFeg5lq700AYiVAOUdVNNH3ocAIxq0umDC 7EmOso0mD9TgOWsAUsMjV/u37Q== X-Google-Smtp-Source: ABdhPJxG0VpP00vLQ3zN321QiHTdOpuRsUyHXysd1hI3TMFTQDpaw+AKN5L+PX/TXrHYh6EtdmRWBg== X-Received: by 2002:a63:ff4e:: with SMTP id s14mr1517836pgk.137.1601460293836; Wed, 30 Sep 2020 03:04:53 -0700 (PDT) From: zhenwei pi To: pbonzini@redhat.com, peter.maydell@linaro.org Subject: [PATCH v3 3/3] target-i386: post memory failure event to uplayer Date: Wed, 30 Sep 2020 18:04:40 +0800 Message-Id: <20200930100440.1060708-4-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200930100440.1060708-1-pizhenwei@bytedance.com> References: <20200930100440.1060708-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::441; envelope-from=pizhenwei@bytedance.com; helo=mail-pf1-x441.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: qemu-devel@nongnu.org, zhenwei pi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bytedance-com.20150623.gappssmtp.com) 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 | 24 ++++++++++++++++++++---- target/i386/kvm.c | 13 ++++++++++++- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/target/i386/helper.c b/target/i386/helper.c index 17e1684ff9..2a184c4835 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" @@ -851,6 +852,15 @@ typedef struct MCEInjectionParams { int flags; } MCEInjectionParams; =20 +static void emit_guest_memory_failure(MemoryFailureAction action, bool ar, + bool recursive) +{ + MemoryFailureFlags mff =3D {.action_required =3D ar, .recursive =3D re= cursive}; + + qapi_event_send_memory_failure(MEMORY_FAILURE_RECIPIENT_GUEST, action, + &mff); +} + static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data) { MCEInjectionParams *params =3D data.host_ptr; @@ -859,16 +869,18 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cp= u_data data) uint64_t *banks =3D cenv->mce_banks + 4 * params->bank; g_autofree char *msg =3D NULL; bool need_reset =3D false; + bool recursive; + bool ar =3D !!(params->status & MCI_STATUS_AR); =20 cpu_synchronize_state(cs); + recursive =3D !!(cenv->mcg_status & MCG_STATUS_MCIP); =20 /* * If there is an MCE exception being processed, ignore this SRAO MCE * unless unconditional injection was requested. */ - if (!(params->flags & MCE_INJECT_UNCOND_AO) - && !(params->status & MCI_STATUS_AR) - && (cenv->mcg_status & MCG_STATUS_MCIP)) { + if (!(params->flags & MCE_INJECT_UNCOND_AO) && !ar && recursive) { + emit_guest_memory_failure(MEMORY_FAILURE_ACTION_IGNORE, ar, recurs= ive); return; } =20 @@ -896,7 +908,7 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_= data data) return; } =20 - if (cenv->mcg_status & MCG_STATUS_MCIP) { + if (recursive) { need_reset =3D true; msg =3D g_strdup_printf("CPU %d: Previous MCE still in progres= s, " "raising triple fault", cs->cpu_index); @@ -909,6 +921,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_= data data) } =20 if (need_reset) { + emit_guest_memory_failure(MEMORY_FAILURE_ACTION_FATAL, ar, + recursive); 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 +948,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_= data data) } else { banks[1] |=3D MCI_STATUS_OVER; } + + emit_guest_memory_failure(MEMORY_FAILURE_ACTION_INJECT, ar, recursive); } =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..923749f5d8 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -13,6 +13,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/qapi-events-run-state.h" #include "qapi/error.h" #include #include @@ -575,8 +576,17 @@ static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, = int code) (MCM_ADDR_PHYS << 6) | 0xc, flags); } =20 +static void emit_hypervisor_memory_failure(MemoryFailureAction action, boo= l ar) +{ + MemoryFailureFlags mff =3D {.action_required =3D ar, .recursive =3D fa= lse}; + + qapi_event_send_memory_failure(MEMORY_FAILURE_RECIPIENT_HYPERVISOR, ac= tion, + &mff); +} + static void hardware_memory_error(void *host_addr) { + emit_hypervisor_memory_failure(MEMORY_FAILURE_ACTION_FATAL, true); error_report("QEMU got Hardware memory error at addr %p", host_addr); exit(1); } @@ -631,7 +641,8 @@ 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 */ + emit_hypervisor_memory_failure(MEMORY_FAILURE_ACTION_IGNORE, false); } =20 static void kvm_reset_exception(CPUX86State *env) --=20 2.11.0