From nobody Fri Apr 26 12:42:13 2024 Delivered-To: importer@patchew.org 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; 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=1578969178; cv=none; d=zohomail.com; s=zohoarc; b=A7CYpfycHgjsG1aFiELFI/ZjeUTO89razWdOd3i1a7hO0XNg+OsGoJErIFJX2ptKGbymGseLW6dW49/n2kY4IYdVAJwVRGiQP+Jal6gY/6YxeBAR+1eIqrzL5UTqKgaFtOGf8jjGM6Axd79rQE5lvjdodBOHVfZUVVMeZ3ekg3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578969178; 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=dAhOey3cqiOp5/b6uTfIau2ZiRzs6yslTIYzXyRfd0c=; b=CWzmmVVomtyZQDdGzwC5ga05r0zqOz80cePwU5wUiFsaFvgbdt3JT0AXDaSN/GBi5e3Ve4iUsLyM70AVtmDMLdpjZfVuBBxH8HUpzpaA5Auj0TgbyXWp/t+oYGSRv+9LYnPJ52DQ3lbk9BWRP0+6kUzr0ZBSpEnx+OYt9nyBe4c= 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 1578969178630836.5246443370885; Mon, 13 Jan 2020 18:32:58 -0800 (PST) Received: from localhost ([::1]:58434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irC0n-0002Ff-AD for importer@patchew.org; Mon, 13 Jan 2020 21:32:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50923) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irBzB-0000Jk-M2 for qemu-devel@nongnu.org; Mon, 13 Jan 2020 21:31:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irBz7-0003T9-0N for qemu-devel@nongnu.org; Mon, 13 Jan 2020 21:31:16 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:43306) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1irBz6-0003SF-RC for qemu-devel@nongnu.org; Mon, 13 Jan 2020 21:31:12 -0500 Received: by mail-pg1-x544.google.com with SMTP id k197so5642819pga.10 for ; Mon, 13 Jan 2020 18:31:12 -0800 (PST) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id w5sm14693898pgb.78.2020.01.13.18.31.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jan 2020 18:31:11 -0800 (PST) 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=dAhOey3cqiOp5/b6uTfIau2ZiRzs6yslTIYzXyRfd0c=; b=wtDHZD8bqB+uan+hMSBRSzUNmG9/WOmSL/yl6dPhvuBti1zXoCe5xgp5Y4y2VRfiAN 3yn8r/NhEsXik/+nseS4mrX9c7gJ/mtQ0+N2GiqtKA1Loig2RzqHpl8ibwKhx4cBBFbn w7v5zKKZA1GA7Zp2HW/NgSf4pV37X8sZkM3bihlQ5nK4egT5DeiM00qmutHb3F2WcD3H p/l4fHPYKw5o4GzPWRnpY6LXlc+6YXpECgaRGpQkkDc5FYVNUdr0jmiORXRBM1EMuhVb isVnYnSbdWmEIJNAyM6MOimHPMHR09z4te3QtjjJMOqEMC7/KUXfgd4LvEG3h5UKx7H2 vI4Q== 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=dAhOey3cqiOp5/b6uTfIau2ZiRzs6yslTIYzXyRfd0c=; b=qu2CjAEUAoNu9PkHfAbnus39Vu0kHTN9H5y0JWV4NH7zFDYvTK89SmIk/bP/V+lx7y WHSjKMlsQ9ksW2n+iJLygnld6hoGMvzoHisaHAi8BmaSoUuvG2L4LbCqbM45xnA/BezC XlRUnp+M8zd4wwp9qUi4B1LUyOrsH9rHPiElaErAfNoR5eSwyNqDaLrw+XdHrj/+OOuC IuadfAXPfVc39zgD+syEa08gEhy6DCGTMnPQ96iVwGNSCrQ5dl/t85kdcZLAlZpq1ukm 5JyQIGtozGad1O5bxP4WMO3Hko4LUw930Kzjsx/B4YOL1PTasraaSbLrj6QpSvURKev1 ShZA== X-Gm-Message-State: APjAAAVsFWLqp51rC7skS9OIYiaBu+toS8XRvX6kIyocrT9gQGoj+cUx MvWCAuBwwvZENWpfGSLEtQm8fA== X-Google-Smtp-Source: APXvYqyTOx46iWqJwrGWImeS+HJuwYGs1QC70uQuMUJKJKNiaueahhv5Pf33oMjG/10CPJPrgpMW1w== X-Received: by 2002:a63:f743:: with SMTP id f3mr24204789pgk.28.1578969071801; Mon, 13 Jan 2020 18:31:11 -0800 (PST) From: zhenwei pi To: pbonzini@redhat.com Subject: [PATCH 1/2] pvpanic: introduce crashloaded for pvpanic Date: Tue, 14 Jan 2020 10:31:01 +0800 Message-Id: <20200114023102.612548-2-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200114023102.612548-1-pizhenwei@bytedance.com> References: <20200114023102.612548-1-pizhenwei@bytedance.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 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: gregkh@linuxfoundation.org, yelu@bytedance.com, qemu-devel@nongnu.org, zhenwei pi , mprivozn@redhat.com 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" Add bit 1 for pvpanic. This bit means that guest hits a panic, but guest wants to handle error by itself. Typical case: Linux guest runs kdump in panic. It will help us to separate the abnormal reboot from normal operation. Signed-off-by: zhenwei pi --- docs/specs/pvpanic.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/specs/pvpanic.txt b/docs/specs/pvpanic.txt index c7bbacc778..bdea68a430 100644 --- a/docs/specs/pvpanic.txt +++ b/docs/specs/pvpanic.txt @@ -16,8 +16,12 @@ pvpanic exposes a single I/O port, by default 0x505. On = read, the bits recognized by the device are set. Software should ignore bits it doesn't recognize. On write, the bits not recognized by the device are ignored. Software should set only bits both itself and the device recognize. -Currently, only bit 0 is recognized, setting it indicates a guest panic -has happened. + +Bit Definition +-------------- +bit 0: setting it indicates a guest panic has happened. +bit 1: named crashloaded. setting it indicates a guest panic and run + kexec to handle error by guest itself. =20 ACPI Interface -------------- --=20 2.11.0 From nobody Fri Apr 26 12:42:13 2024 Delivered-To: importer@patchew.org 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; 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=1578969173; cv=none; d=zohomail.com; s=zohoarc; b=FnfGgOSiGKDM5R+R1P5xESB9ucA/Bo5dCyDHW1LY+RmBl1HZUEyuOddA24Mrtx4ijYSwTfbmVejrjcvlsowFLHjeAfMULUdFo/1YLFgxnNjWm7MYGs2x/gvpqB5zikwfGQnZiWevz/Tpc/zAfqxvNQASf1rjwN/UjqmvRWKrJjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578969173; 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=fshKwfwt9Dp2Wq1APH+4/EX0Jo99Mva81d26eLwAGKU=; b=S4CRSISsU/uloKRjFbuK5YLEZJIax6uUmVr7/e8vnrVQBgJcRBZ5Yf0CafoZi2/Y58zCV1fyq9yS/r5J0Q40wQCZyUKE1oXlYF7lVU8E8VRGxGYTvWMjEXxHMGomWSlczWneabRpnmyTFrPNJ7q2KsQd69YALoqhpBq8kfFJY1M= 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 1578969173811246.38498867448902; Mon, 13 Jan 2020 18:32:53 -0800 (PST) Received: from localhost ([::1]:58432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irC0i-000278-C1 for importer@patchew.org; Mon, 13 Jan 2020 21:32:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50942) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irBzD-0000NQ-RN for qemu-devel@nongnu.org; Mon, 13 Jan 2020 21:31:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irBzB-0003Xt-Kn for qemu-devel@nongnu.org; Mon, 13 Jan 2020 21:31:19 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:44649) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1irBzB-0003WH-ER for qemu-devel@nongnu.org; Mon, 13 Jan 2020 21:31:17 -0500 Received: by mail-pg1-x542.google.com with SMTP id x7so5637963pgl.11 for ; Mon, 13 Jan 2020 18:31:17 -0800 (PST) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id w5sm14693898pgb.78.2020.01.13.18.31.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jan 2020 18:31:14 -0800 (PST) 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=fshKwfwt9Dp2Wq1APH+4/EX0Jo99Mva81d26eLwAGKU=; b=mbpusgzsMyJviGzLEQxRIhG5CgsaAx8t/ft5X1z5SazNaYFCXZiEasmgwJ8TEoihU9 cHWgmC1irJvovbBccQpNoHt5fYBN/SINI/eW/RDe4qTkg5DkLbo7Yq9OWOxcdefpLgis iBoOfuJ9d/IomJghiIXEPuBZilKp8808IXel3ky6o2N6GYo3alGEdd1uik8+qDE/FOHz LL/e6XpZW9IsFEYW0OFzryuNAFPekPeEFIaoBL3AFknnB4E897O1JH1dOS8DSpyXh5GX Rka8jheQk1p2hk8ShV02Ctq3htxSKMtcQzHaOgrWGnrlXYzja+YWos5yJ9C1RuM1diNe PbCw== 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=fshKwfwt9Dp2Wq1APH+4/EX0Jo99Mva81d26eLwAGKU=; b=IK55ZSSZlo1DFNcxgL85wb7dzY6OQNmoTu94DbzSO4nWYayZ1qrWku/TutjaTpZD5P JyrYEpAGGJKkXd992IGks4BFh9z3aEWKwGDCPZvH6PBEnaRTFxRvTLxPYHorMfL/OpC6 peqWhVQp9U9AftFoHfPofpzA+jW4LyVMOoCP5cijUbDjRA9X25KecA/HUh28FXhYtIyU LmNZlMZ9lmp/bj6IssY+kn7+beZPj5g1YblmBieVaj7UZpMgAOwuB83EYPssno+WEHVF oq3WJuafw34aVz9X/yRsPmdYtCCnEKSQodmyBBfpz53YxzV96VJh6e0OruvFMK4Huu4A GsBA== X-Gm-Message-State: APjAAAXhBcGJyDKuSdaKmGMJGJN/L9svDp4qOUKpK98hUEz+D/Fsm7Pf GhL/XSPB/SFp9delVjTKzZQIpw== X-Google-Smtp-Source: APXvYqz/rAPjfjTLludp1mPfVH0zzc8heEjvHX9a2wJqZZzSpTwL0owkyfQXeCkEgofLKB/ffHjdoA== X-Received: by 2002:a63:6b07:: with SMTP id g7mr23798378pgc.243.1578969074943; Mon, 13 Jan 2020 18:31:14 -0800 (PST) From: zhenwei pi To: pbonzini@redhat.com Subject: [PATCH 2/2] pvpanic: implement crashloaded event handling Date: Tue, 14 Jan 2020 10:31:02 +0800 Message-Id: <20200114023102.612548-3-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200114023102.612548-1-pizhenwei@bytedance.com> References: <20200114023102.612548-1-pizhenwei@bytedance.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 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: gregkh@linuxfoundation.org, yelu@bytedance.com, qemu-devel@nongnu.org, zhenwei pi , mprivozn@redhat.com 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" Handle bit 1 write, then post event to monitor. Suggested by Paolo, declear a new event, using GUEST_PANICKED could cause upper layers to react by shutting down or rebooting the guest. In advance for extention, add GuestPanicInformation in event message. Signed-off-by: zhenwei pi --- hw/misc/pvpanic.c | 11 +++++++++-- include/sysemu/runstate.h | 1 + qapi/run-state.json | 22 +++++++++++++++++++++- vl.c | 12 ++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index d65ac86478..4ebda7872a 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -21,11 +21,13 @@ #include "hw/qdev-properties.h" #include "hw/misc/pvpanic.h" =20 -/* The bit of supported pv event */ +/* The bit of supported pv event, TODO: include uapi header and remove thi= s */ #define PVPANIC_F_PANICKED 0 +#define PVPANIC_F_CRASHLOADED 1 =20 /* The pv event value */ #define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) +#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) =20 #define ISA_PVPANIC_DEVICE(obj) \ OBJECT_CHECK(PVPanicState, (obj), TYPE_PVPANIC) @@ -34,7 +36,7 @@ static void handle_event(int event) { static bool logged; =20 - if (event & ~PVPANIC_PANICKED && !logged) { + if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASHLOADED) && !logged) { qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", ev= ent); logged =3D true; } @@ -43,6 +45,11 @@ static void handle_event(int event) qemu_system_guest_panicked(NULL); return; } + + if (event & PVPANIC_CRASHLOADED) { + qemu_system_guest_crashloaded(NULL); + return; + } } =20 #include "hw/isa/isa.h" diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 0b41555609..f760094858 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -63,6 +63,7 @@ ShutdownCause qemu_reset_requested_get(void); void qemu_system_killed(int signal, pid_t pid); void qemu_system_reset(ShutdownCause reason); void qemu_system_guest_panicked(GuestPanicInformation *info); +void qemu_system_guest_crashloaded(GuestPanicInformation *info); =20 #endif =20 diff --git a/qapi/run-state.json b/qapi/run-state.json index d7477cd715..b7a91f3125 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -357,6 +357,26 @@ 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation'= } } =20 ## +# @GUEST_CRASHLOADED: +# +# Emitted when guest OS crash loaded is detected +# +# @action: action that has been taken, currently always "run" +# +# @info: information about a panic (since 2.9) +# +# Since: 5.0 +# +# Example: +# +# <- { "event": "GUEST_CRASHLOADED", +# "data": { "action": "run" } } +# +## +{ 'event': 'GUEST_CRASHLOADED', + 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation'= } } + +## # @GuestPanicAction: # # An enumeration of the actions taken when guest OS panic is detected @@ -366,7 +386,7 @@ # Since: 2.1 (poweroff since 2.8) ## { 'enum': 'GuestPanicAction', - 'data': [ 'pause', 'poweroff' ] } + 'data': [ 'pause', 'poweroff', 'run' ] } =20 ## # @GuestPanicInformationType: diff --git a/vl.c b/vl.c index 86474a55c9..5b1b2ef095 100644 --- a/vl.c +++ b/vl.c @@ -1468,6 +1468,18 @@ void qemu_system_guest_panicked(GuestPanicInformatio= n *info) } } =20 +void qemu_system_guest_crashloaded(GuestPanicInformation *info) +{ + qemu_log_mask(LOG_GUEST_ERROR, "Guest crash loaded"); + + qapi_event_send_guest_crashloaded(GUEST_PANIC_ACTION_RUN, + !!info, info); + + if (info) { + qapi_free_GuestPanicInformation(info); + } +} + void qemu_system_reset_request(ShutdownCause reason) { if (no_reboot && reason !=3D SHUTDOWN_CAUSE_SUBSYSTEM_RESET) { --=20 2.11.0