From patchwork Fri Jan 10 10:06:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 1220912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=ZCnGyjz4; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 47vJYx5L1Zz9sPn for ; Fri, 10 Jan 2020 21:07:17 +1100 (AEDT) Received: from localhost ([::1]:43440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iprCF-0005ox-Go for incoming@patchwork.ozlabs.org; Fri, 10 Jan 2020 05:07:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34233) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iprBn-0005mz-Nv for qemu-devel@nongnu.org; Fri, 10 Jan 2020 05:06:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iprBm-0003Vt-JE for qemu-devel@nongnu.org; Fri, 10 Jan 2020 05:06:47 -0500 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:34779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iprBm-0003Sc-Ci for qemu-devel@nongnu.org; Fri, 10 Jan 2020 05:06:46 -0500 Received: by mail-pj1-x1042.google.com with SMTP id s94so1770798pjc.1 for ; Fri, 10 Jan 2020 02:06:46 -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=ZCnGyjz4JtzHSiIKTawQQFFawClt0WRij9NbnhP7RUUYZVdjjy1D9p2jpTH6nJ8Tmv jg14A971WglswnMZ4qFHpRKI3KbEv3y/J1PkACZdJhUJgE3VCR5rvKwXXJhvN478mZu7 QAq9H4WCPHGe6yjVCU8a3QuVHEb9pl3jhxejEIX4dXJfgyuxGRnJd54LXW1hIVGT6+SB 9XZUXRXaDfzBleyop6DCKdkSlL6sWtqlzy7cZ5P4pcZ2I7bjGAzFttaVcatZb+u8b3zu YiHN/37SOWbvCCiW2ndN5YG9eTyIuqeY6HCFMoSygQV6MPX3TdoauyvSqe+P/MJseMP1 CqSw== 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=HbDzlmWpWkfQ+9wWgKXGK1VxE3IPCG3lT0ZHPfXpuvaGxBfmomoKdq0VGiyw5zns5f iSsqhkSleJW0weerR3+P2H4mKSrtV0tIpCbzMDZ8SzVo55FjoseiNQHSStaRHcKid2PL I3c7FIxk2QMKPJ8XBj/CMf8/EVrxJM9Hba90IuDo0it+ciR2ebTfatTuV1eocWVzgp7/ ZMVrgs6DUurMcmQ0og3WBRubG3GDfdB2XSiiawzlInAqhQFNcJYt/xY7TnuFZLSmDlGI w6JGGptqp9QFlOhC0grOHoWQR/xEU5lpME0pDbsHabiYcp/NCpB+SIPcmf6l9mntnpGY NfHg== X-Gm-Message-State: APjAAAVpElR5dpY3xoM4VORyUPRNejUAOAg5+BQctfPPIhrNsvc44mk3 Uvkk6toQuo50d3SvbDVxpbU1NQ== X-Google-Smtp-Source: APXvYqyqnZ9lf3ppNVir68eoZT7u3buRR7s7HIwujRNHxEUEdVG6qsr88g9VM/pC+0jZaZIEUqzprA== X-Received: by 2002:a17:90a:1b4d:: with SMTP id q71mr3653557pjq.82.1578650805378; Fri, 10 Jan 2020 02:06:45 -0800 (PST) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id q21sm2179039pff.105.2020.01.10.02.06.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jan 2020 02:06:44 -0800 (PST) From: zhenwei pi To: pbonzini@redhat.com Subject: [PATCH 1/2] pvpanic: introduce crashloaded for pvpanic Date: Fri, 10 Jan 2020 18:06:33 +0800 Message-Id: <20200110100634.491936-2-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110100634.491936-1-pizhenwei@bytedance.com> References: <20200110100634.491936-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::1042 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: yelu@bytedance.com, libvir-list@redhat.com, gregkh@linuxfoundation.org, qemu-devel@nongnu.org, zhenwei pi , linux-kernel@vger.kernel.org, mprivozn@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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. ACPI Interface -------------- From patchwork Fri Jan 10 10:06:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 1220913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=jTrvQEzM; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 47vJbn1n0xz9sPn for ; Fri, 10 Jan 2020 21:08:52 +1100 (AEDT) Received: from localhost ([::1]:43450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iprDl-0007vS-SO for incoming@patchwork.ozlabs.org; Fri, 10 Jan 2020 05:08:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34479) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iprBr-0005pD-Dw for qemu-devel@nongnu.org; Fri, 10 Jan 2020 05:06:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iprBq-0003ke-4q for qemu-devel@nongnu.org; Fri, 10 Jan 2020 05:06:51 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:37260) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iprBp-0003hM-UB for qemu-devel@nongnu.org; Fri, 10 Jan 2020 05:06:50 -0500 Received: by mail-pf1-x442.google.com with SMTP id p14so907579pfn.4 for ; Fri, 10 Jan 2020 02:06:49 -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=jTrvQEzMTwHn/rWFhNwVM3gC79UFrZ/uuP6zVfefiRKyeh6bVS+DfyZq4ZpMFxAuSe 1sCkq2WvZGSqXTrGJBG4fDnmxo0m2PVk393Z/TFpNMJfTTiRL9GhM+0SHSxyfubHEOk+ DyWl6eTdDLnRzPxmZp4oRpXVUzoAnox6e4WERP30vR/ESaDHWvxdNos1OqI/y6eaVUnK qwOEgTgZ+jLO/O3SnN/HPWCVZw3gq5uDXZeFHcR5nhr5mLU56KGPZza7wr6AL6pKowR5 U8uTcXnGClHKTqT3UMes3pza4JtmMH32jHzLMNJ2oNlnfUW9BUHun5Q3OLtVbPDGlceM XGTQ== 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=sG+k/8vpxEROvVjaNrZAEvCEIoeTZhJDBL427FXKXQIq5JoHAJiviyOkgIceLRH8Fu GETDFQaIvodi/oAfrAQuS6+CFQQJULOeT9GF6XDCOKLPmFFtfsZuQH9XYElajVtq79RG dtudgbeISMIuDFUfhJiS31CjIVQMU68ZFfrjJT5frOOJeJCgBjdfvxXggeLEgBRf6sYE G1pdDp+4HDxGb78BsGFwkb5ZWQ0BkDCLbIKYkRZ/BbW/B3patoYjRcCbsKivm07cgbNs CelBR+syEEIpA408TTRlsN1dkRePQgoT3UfCpUQWk3jqnnuzyivcqI32Og7hTVgwkToh HRmQ== X-Gm-Message-State: APjAAAV2pOzAX3QGnUyPITAVCQFWFIbMm4FbUl8QREKO5h6rSHiL4NlZ ZhgwMln2yQNjjVqmrCQGr1uaeQ== X-Google-Smtp-Source: APXvYqwLM80h5i/WiPXHqIG/DdJ1TUWK+d+JqiEcoNNkviF23F6YROu6y6DgPL2cKbxCTsnfqsFYxg== X-Received: by 2002:a63:201d:: with SMTP id g29mr3428289pgg.427.1578650808856; Fri, 10 Jan 2020 02:06:48 -0800 (PST) Received: from libai.bytedance.net ([61.120.150.71]) by smtp.gmail.com with ESMTPSA id q21sm2179039pff.105.2020.01.10.02.06.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jan 2020 02:06:48 -0800 (PST) From: zhenwei pi To: pbonzini@redhat.com Subject: [PATCH 2/2] pvpanic: implement crashloaded event handling Date: Fri, 10 Jan 2020 18:06:34 +0800 Message-Id: <20200110100634.491936-3-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200110100634.491936-1-pizhenwei@bytedance.com> References: <20200110100634.491936-1-pizhenwei@bytedance.com> X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Received-From: 2607:f8b0:4864:20::442 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: yelu@bytedance.com, libvir-list@redhat.com, gregkh@linuxfoundation.org, qemu-devel@nongnu.org, zhenwei pi , linux-kernel@vger.kernel.org, mprivozn@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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" -/* The bit of supported pv event */ +/* The bit of supported pv event, TODO: include uapi header and remove this */ #define PVPANIC_F_PANICKED 0 +#define PVPANIC_F_CRASHLOADED 1 /* The pv event value */ #define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) +#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) #define ISA_PVPANIC_DEVICE(obj) \ OBJECT_CHECK(PVPanicState, (obj), TYPE_PVPANIC) @@ -34,7 +36,7 @@ static void handle_event(int event) { static bool logged; - if (event & ~PVPANIC_PANICKED && !logged) { + if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASHLOADED) && !logged) { qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", event); logged = 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; + } } #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); #endif 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' } } ## +# @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' ] } ## # @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(GuestPanicInformation *info) } } +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 != SHUTDOWN_CAUSE_SUBSYSTEM_RESET) {