From nobody Sun May 5 10:05:08 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=1600091396; cv=none; d=zohomail.com; s=zohoarc; b=cixi7fsmloz4fWh8FFhTRw1e7JhCZabV1DWKTKfrHeeiPFSdUGC2oXjqdZBuEPzCqhSxF8CbbV3S0FWv5VcwVbRs5HRHXOTg8Q12tAH3SyjWrflx22kukAKxPfnaY40qb/X0nSq7Kd2KVgme5C8lSo+lAUu7y2o7B2BF6g/DVB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600091396; 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=IfK5HuCajcyGlijBWzl+C3Pqms0hL95Ji4twHgdJHhQAhHZkNFNOuQSbDsShZ44XAzX9N3lwPLaGKQVkSp9wBtcG3R5JxdeQghztBpxTDxeQUKATBJCVGs18/VgRuO1A11f3g+lae+nt3xmXkSvxiqsYSArYxTuoqGueYajETYg= 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 160009139627218.479842584195012; Mon, 14 Sep 2020 06:49:56 -0700 (PDT) Received: from localhost ([::1]:47220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHorj-0004wg-6A for importer@patchew.org; Mon, 14 Sep 2020 09:49:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHola-0004Kr-Ps for qemu-devel@nongnu.org; Mon, 14 Sep 2020 09:43:34 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:46547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kHolY-0003DP-8R for qemu-devel@nongnu.org; Mon, 14 Sep 2020 09:43:33 -0400 Received: by mail-pg1-x543.google.com with SMTP id 34so11565921pgo.13 for ; Mon, 14 Sep 2020 06:43:31 -0700 (PDT) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id c4sm7626378pjq.7.2020.09.14.06.43.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 06:43:30 -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=C7a0ltWl6GQDSzT0MRVC+/MVpTf35edDb2/ALFKVEFo6kVoYrnjonGpxCD9AGCuaak rL8yOzP/FaJAQs1BhPf1fNNwG3HJsXpwpVuR5/xQmK8rsorGhZ25otdWZjxAz7md7NvC bWbw9nbHKp5CclIfm4vKaPTcIk3f6z1v4vpg2e6Ud9iT7nB/F2bREbfN8JkpjtiMNF4e WS/mrGxLUSKPOr3XHPUlQlQSkdHkJECMcCsb+k9MweskDKsuRSv1xEBHD1NuIkDB28zj Qn+RQF7VPhkjPKsPFBlcgMUsF+3EmKTBnvYopeOwrOypBRcOi1Or+daf6AkeaMIU972w qnHw== 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=QGpaoujDZuzoIi5xZK5UvCRxX4InWZxNXJHzBRWv1a0tcKuJXcL/LlyToTfOItvsav IXrHntxvhiPmmoBHcl/yhs3QCoK3fYQm/RbyLgKSgYV2U8FR+clKKB9tM8DHdc2/8QC4 LssGGfGF0+iwYPV0o8hnaKWWUirt6XtuAcB3Lxtk0Kj9JIOfi7xZm/bBAKTFoWjoi897 Hua40/UrQk3gwjNCJBMX+qI7tA7rgsfmqUIM0CyNyLCp/QCrbNgBr2v1IxAAG+srMsln iTQyALCH0xsRc3OwtX/F69hrlyDJlY+Mmfp30xks9KOH0prrg2Z7KfUo5zV+F/CgOgPN zzUg== X-Gm-Message-State: AOAM5323yxNw/Yfsg0AmLxkz+BOIywXNz9WTvIjHQQ9J2oTc2EianNvg 9qtEQy4VjsmlKMW2XypPyTd11qMTNf9oKQ== X-Google-Smtp-Source: ABdhPJzse4Mfto7/6YHK4720MVQ6yJ+5UCF6h1YuS2hHbe69kNs5Kr+Ek0SEuxdDDBiV1xa63ukggQ== X-Received: by 2002:a62:e501:0:b029:13c:1611:6527 with SMTP id n1-20020a62e5010000b029013c16116527mr13273942pff.7.1600091010913; Mon, 14 Sep 2020 06:43:30 -0700 (PDT) From: zhenwei pi To: armbru@redhat.com, pbonzini@redhat.com, mtosatti@redhat.com Subject: [PATCH 1/3] target-i386: seperate MCIP & MCE_MASK error reason Date: Mon, 14 Sep 2020 21:43:19 +0800 Message-Id: <20200914134321.958079-2-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200914134321.958079-1-pizhenwei@bytedance.com> References: <20200914134321.958079-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::543; envelope-from=pizhenwei@bytedance.com; helo=mail-pg1-x543.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, pizhenwei@bytedance.com 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..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 Sun May 5 10:05:08 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=1600091599; cv=none; d=zohomail.com; s=zohoarc; b=BC3jNmg9OIi5YdvYbnQjqsHDIcbbtyZ413AptZ/0qWLl9Nd4U8K1tzM+xR5gt2983Z+dsYyIvYrtqq+hE5TfBTydf09cWqT4Wu3gEqxtxiErXZiRQkHlgKfXOV92PIsijweJQt8fmRZVyjN31dQzdYIoFqakv6at3YLQODzwMq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600091599; 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=zoKhLvexSKKYei1gir7mK7K/SpLcA8kaJU8i6ucZAWw=; b=fq6lUZ5jmUxM4vyynprTdLkTiIlhotmz3xlwkFrZr51n1fiFCFiwwFo18vlzVv0liq2rFNxjXtRbgwK6f0Pb9NVqyPCd9t49IeDCgPVKt/h87arEBo5RyezOa8Cdp4cfV4fPxDaQ7A9rvixfx8Zyfm0k3Wm8LaaB2i6ajmHm3Ws= 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 1600091599738484.61826812612753; Mon, 14 Sep 2020 06:53:19 -0700 (PDT) Received: from localhost ([::1]:60752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHov0-00028S-Bb for importer@patchew.org; Mon, 14 Sep 2020 09:53:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHolc-0004SW-Vm for qemu-devel@nongnu.org; Mon, 14 Sep 2020 09:43:37 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:44159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kHolb-0003Dh-Bo for qemu-devel@nongnu.org; Mon, 14 Sep 2020 09:43:36 -0400 Received: by mail-pf1-x442.google.com with SMTP id o20so12649666pfp.11 for ; Mon, 14 Sep 2020 06:43:34 -0700 (PDT) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id c4sm7626378pjq.7.2020.09.14.06.43.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 06:43:33 -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=zoKhLvexSKKYei1gir7mK7K/SpLcA8kaJU8i6ucZAWw=; b=NKgh89W650cMzLxY0cCC/hzh9Led3M1MVzosGxjYMKCsqjlV/J1icAycchtwdvuu60 hrhs7X+E19i9ZaxzAIBqtfcIrMnoUpxr1XQ0HKlwsV3xJYxN2gQeV6FX6TBNn8adchUN w+HqdC2G+h9dpJYoLH4gekqVb6oUlfsI3g5pzg/3KI+sY/KXaTtUT+ishcmopzRUMIZx +7umaITeT36VnGlym/H2l1HokX0bDZJyAHy1d4XK+7uxcETAHZN5ja8cd6X5ruu1tVnU NwrBlaaeO5qzz9jMc6puhhFk3DYTKkypxN4qdoka7dVZeyB6SYgbUziGakwLSCWw01w2 hbXQ== 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=zoKhLvexSKKYei1gir7mK7K/SpLcA8kaJU8i6ucZAWw=; b=erL7TqW3X2XLTjugxZZn9USs7LuQTWdtBuYB8CwfumJvTFvAk6uPsdoDjg9ApIIyDm T3BOWJhA2dzDc7uNIVRT8HWpcA9gvNN+BHTG3AZXTvJeby1rW246XgthGivhUU6qSYz/ Hm8iiwmBIQriKeO9Rs/3zyLIJ8UfzRNiRYGBbWjFcn+KDKLtj6m+u5VnreYcoqDKfm9t nMI20sKG+z3Yc1sZ1FKMU5kLuQ1GB9+6k0oYpzJa5gLnc6v3xIKi3RwTdpIHxC4mE+li WREpVacNYyesLo3lv/1HX8xjA8o0N4MYzbQ0R8mKh4Z/6ZL/2QM9ZIAauii2jjJct48s wG0w== X-Gm-Message-State: AOAM532TM79e9d8Dl3H2MxpY7RPVI+EI4zEUMeJBBBmD/mCUyKR3ZTc4 jvcQ7bz2dYL7GE8CJYigsrGRFhgOnp+caw== X-Google-Smtp-Source: ABdhPJy9Ac3gg7uyHLthdUyrmFWrWgUy/wO2Dq1jvBS3jQjmFWFD7gIxlV+wrfQyB3NDy+Q5ZvacZA== X-Received: by 2002:a63:f53:: with SMTP id 19mr11024521pgp.26.1600091013884; Mon, 14 Sep 2020 06:43:33 -0700 (PDT) From: zhenwei pi To: armbru@redhat.com, pbonzini@redhat.com, mtosatti@redhat.com Subject: [PATCH 2/3] iqapi/run-state.json: introduce memory failure event Date: Mon, 14 Sep 2020 21:43:20 +0800 Message-Id: <20200914134321.958079-3-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200914134321.958079-1-pizhenwei@bytedance.com> References: <20200914134321.958079-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::442; envelope-from=pizhenwei@bytedance.com; helo=mail-pf1-x442.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, pizhenwei@bytedance.com 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 4 memory failure events for a guest. Then uplayer could know when/why/what happened to a guest during hitting a hardware memory failure. Signed-off-by: zhenwei pi --- qapi/run-state.json | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/qapi/run-state.json b/qapi/run-state.json index 7cc9f96a5b..fdc39ce262 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -475,3 +475,49 @@ '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'} } + +## +# @MemoryFailureAction: +# +# Host memory failure occurs, handled by QEMU. +# +# @hypervisor-ignore: action optional memory failure at QEMU process +# addressspace (none PC-RAM), QEMU could ignore this +# hardware memory failure. +# +# @hypervisor-stop: action required memory failure at QEMU process address +# space (none PC-RAM), QEMU has to stop itself. +# +# @guest-mce: action required memory failure at PC-RAM, and guest enables = MCE +# handling, QEMU injects MCE to guest. +# +# @guest-triple-fault: action required memory failure at PC-RAM, but guest= does +# not enable MCE handling. QEMU raises triple fault a= nd +# shutdown/reset. Also see detailed info in QEMU log. +# +# Since: 5.2 +# +## +{ 'enum': 'MemoryFailureAction', + 'data': [ 'hypervisor-ignore', + 'hypervisor-stop', + 'guest-mce', + 'guest-triple-fault' ] } --=20 2.11.0 From nobody Sun May 5 10:05:08 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=1600091476; cv=none; d=zohomail.com; s=zohoarc; b=ORov3Nyk0+jlWF7kWj489u4Q+jVZGdcL8ykleXA4UOHnMt4swFs9d0EtWXdIpdljtHtI5XA3OBHbhL4rO71EvlQWaPrmf57LcALT44La2F94vyRqANEEFNipHYnACyrt68Inuc5xPjmTi5bD6BVu1zWkkr1DoJA4RRjSjuZB7pc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600091476; 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=JROvm5rr8+1Wo6J5ML/BSylPouNvBTyMPETS3dPRS0U=; b=dcvpaoFkk+8GoNK5zKznPVDEGj7S1sPyQMKphNaJp1aSUPKrgmn2HT2Hi/HTm72lO0sOP0LaAHEaAkAqqDSwQF80r1Jcin91RhDU09LSG97ON3Y6IGYH+FmeOPEzFPGbu81uBl33RJwKk8d3msH6sKPsfc1xEIixc8PijAOOJ5s= 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 160009147636296.1819794360789; Mon, 14 Sep 2020 06:51:16 -0700 (PDT) Received: from localhost ([::1]:52116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHot1-00072J-1u for importer@patchew.org; Mon, 14 Sep 2020 09:51:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHolf-0004aC-QO for qemu-devel@nongnu.org; Mon, 14 Sep 2020 09:43:39 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:34507) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kHole-0003Dt-2O for qemu-devel@nongnu.org; Mon, 14 Sep 2020 09:43:39 -0400 Received: by mail-pf1-x432.google.com with SMTP id v196so12803331pfc.1 for ; Mon, 14 Sep 2020 06:43:37 -0700 (PDT) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id c4sm7626378pjq.7.2020.09.14.06.43.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2020 06:43:36 -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=JROvm5rr8+1Wo6J5ML/BSylPouNvBTyMPETS3dPRS0U=; b=iO2NTlUwRzUBjKxIrIcrFbtpVDp0XQ0a1GoBBi8ezebXOEJYVnCFA5YE3yDHFpdqN0 UpWaBYutZ4W4KeHjlRUo8YXQlFpdCWW8EvFRG62gxkpBQmf5/514DLIH3AYrmBwTKN2t Yz7jfi/B0b3JGjFqS/Y3jbHISVXncB3CmGQ1E5LcDjurXf13L116h9PLNMYAX0SWIQg3 huxoZAHVkCFMhas2w877YQjNDg5iqiQJXguTI0mAC1dlCGQzsYmeRo6kR8PXrhcOHc4q OrcOAPKjL+uy+FdtvWCXzfGL9Dn/iYq+NmYnnQYKaUeBW1itpVT8EgRpKhrFZSNJb8u2 3LXA== 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=JROvm5rr8+1Wo6J5ML/BSylPouNvBTyMPETS3dPRS0U=; b=NFZff72ez7sXpfKCl/T3CO/wUgzGYwRWQY1nH3z3cB45bnWruNZ1SVZHUYJoWmSrBl UE3vt0HOdpyrcuCXyoSBayfHcGucPmVYg6iL6TZuObHKuAP/0w32IUsfSN9VDY55gc7O G5h/2A8xE5xtKUxPjLbJEQSiQh5UjP6bA0iDJnaLKlaa01F8/LB91A1qAGk2WLWi48q+ 6euJbLqrJMumwyDocDLBeQj7uADXgyZ+XQcaDmD7Ooxrmee9PaH5jU7zyKUXXNhilgrz eMRPojwaOuVevvyydcFKnlklV/IIN6K1+jBpevw4nU7yDjM/F9TQBb02WOVpeCHYQWVX REVw== X-Gm-Message-State: AOAM533QaBTxmeHJAVCMHd71IAkHVfAHcP3betH+1iddMiqM7ZJPVzsT D3zhT79VjU/O5pfeApqyo0v3Yg== X-Google-Smtp-Source: ABdhPJz3IDFU3LaNb/2kVDj8Xj91ZvFmbnrqBDRygh4Rh/LOCuRErfRq2Y/yjx+HnrSSKzRvQT3idQ== X-Received: by 2002:a62:4e49:: with SMTP id c70mr13275778pfb.100.1600091016777; Mon, 14 Sep 2020 06:43:36 -0700 (PDT) From: zhenwei pi To: armbru@redhat.com, pbonzini@redhat.com, mtosatti@redhat.com Subject: [PATCH 3/3] target-i386: post memory failure event to uplayer Date: Mon, 14 Sep 2020 21:43:21 +0800 Message-Id: <20200914134321.958079-4-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200914134321.958079-1-pizhenwei@bytedance.com> References: <20200914134321.958079-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::432; envelope-from=pizhenwei@bytedance.com; helo=mail-pf1-x432.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, pizhenwei@bytedance.com 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 | 5 +++++ target/i386/kvm.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/i386/helper.c b/target/i386/helper.c index 0c7fd32491..f7b2dbeec8 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" @@ -897,6 +898,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_= data data) } =20 if (cenv->mcg_status & MCG_STATUS_MCIP) { + qapi_event_send_memory_failure( + MEMORY_FAILURE_ACTION_GUEST_TRIPLE_FAULT); need_reset =3D true; snprintf(msg, sizeof(msg), "CPU %d: Previous MCE still in prog= ress," " raising triple fault", cs->cpu_index); @@ -934,6 +937,8 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_= data data) } else { banks[1] |=3D MCI_STATUS_OVER; } + + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_GUEST_MCE); } =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 205b68bc0c..63a585cc64 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,7 @@ 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_STOP); error_report("QEMU got Hardware memory error at addr %p", host_addr); exit(1); } @@ -631,7 +633,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 */ + qapi_event_send_memory_failure(MEMORY_FAILURE_ACTION_HYPERVISOR_IGNORE= ); } =20 static void kvm_reset_exception(CPUX86State *env) --=20 2.11.0