From nobody Mon Nov 3 18:26:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15057525298431003.5718237805252; Mon, 18 Sep 2017 09:35:29 -0700 (PDT) Received: from localhost ([::1]:37768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtz16-00031e-UO for importer@patchew.org; Mon, 18 Sep 2017 12:35:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyzF-0001xb-DJ for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:33:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyzB-0000E9-D3 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:33:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40400 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyzB-0000Df-6n for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:33:29 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8IGOaHC128039 for ; Mon, 18 Sep 2017 12:33:28 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2d2ex0upgq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 18 Sep 2017 12:33:28 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Sep 2017 17:33:26 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 18 Sep 2017 17:33:23 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8IGXM4v31326374; Mon, 18 Sep 2017 16:33:22 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB60A52045; Mon, 18 Sep 2017 16:28:23 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 966DF5203F; Mon, 18 Sep 2017 16:28:23 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 9772120F62B; Mon, 18 Sep 2017 18:33:22 +0200 (CEST) From: Christian Borntraeger To: Cornelia Huck Date: Mon, 18 Sep 2017 18:33:22 +0200 X-Mailer: git-send-email 2.9.4 X-TM-AS-GCONF: 00 x-cbid: 17091816-0040-0000-0000-000003FAD42F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17091816-0041-0000-0000-0000209C018A Message-Id: <20170918163322.206581-1-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-18_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709180234 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH] s390x/cpu: expose the guest crash information X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , David Hildenbrand , Jing Liu , qemu-devel , Alexander Graf , Christian Borntraeger , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jing Liu This patch is the s390 implementation of guest crash information, similar to commit d187e08dc4 ("i386/cpu: add crash-information QOM property") and the related commits. We will detect several crash reasons, with the "disabled wait" being the most important one, since this is used by all s390 guests as a "panic like" notification. Demonstrate the these ways with examples as follows. 1. crash-information QOM property; Run qemu with -qmp unix:qmp-sock,server, then use utility "qmp-shell" to execute "qom-get" command, and might get the result like, (QEMU) qom-get path=3D/machine/cpu[0]/ property=3Dcrash-information {"return": {"psw_addr": 1105350, "psw_mask": 562956395872256, "reason": "disabled wait", "type": "kvm-s390"}} 2. GUEST_PANICKED event reporting; Run qemu with a socket option, and telnet or nc to that, -chardev socket,id=3Dqmp,port=3D4444,host=3Dlocalhost,server \ -mon chardev=3Dqmp,mode=3Dcontrol,pretty=3Don \ Negotiating the mode by { "execute": "qmp_capabilities" }, and the crash information will be reported on a guest crash event like, { "timestamp": { "seconds": 1499931739, "microseconds": 961296 }, "event": "GUEST_PANICKED", "data": { "action": "pause", "info": { "psw_addr": 1105350, "reason": "disabled wait", "psw_mask": 562956395872256, "type": "kvm-s390" } } } 3. log; Run qemu with the parameters: -D -d guest_errors, to specify the logfile and log item. The results might be, >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Guest crashed KVM-S390 crash parameters: (0x2000180000000 0x10ddc6) KVM-S390 crash reason: disabled wait >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Signed-off-by: Jing Liu Reviewed-by: Christian Borntraeger Signed-off-by: Christian Borntraeger --- qapi/run-state.json | 19 ++++++++++++++++-- target/s390x/cpu.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++ target/s390x/cpu.h | 6 ++++++ target/s390x/kvm.c | 29 +++++++++++++++++++++------ vl.c | 6 ++++++ 5 files changed, 109 insertions(+), 8 deletions(-) diff --git a/qapi/run-state.json b/qapi/run-state.json index d36ff49..3bf65ea 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -320,10 +320,12 @@ # # An enumeration of the guest panic information types # +# @kvm-s390: s390 guest panic information type (Since: 2.11) +# # Since: 2.9 ## { 'enum': 'GuestPanicInformationType', - 'data': [ 'hyper-v'] } + 'data': [ 'hyper-v', 'kvm-s390' ] } =20 ## # @GuestPanicInformation: @@ -335,7 +337,8 @@ {'union': 'GuestPanicInformation', 'base': {'type': 'GuestPanicInformationType'}, 'discriminator': 'type', - 'data': { 'hyper-v': 'GuestPanicInformationHyperV' } } + 'data': { 'hyper-v': 'GuestPanicInformationHyperV', + 'kvm-s390': 'GuestPanicInformationKVMS390' } } =20 ## # @GuestPanicInformationHyperV: @@ -350,3 +353,15 @@ 'arg3': 'uint64', 'arg4': 'uint64', 'arg5': 'uint64' } } + +## +# @GuestPanicInformationKVMS390: +# +# KVM-S390 specific guest panic information (PSW) +# +# Since: 2.11 +## +{'struct': 'GuestPanicInformationKVMS390', + 'data': { 'psw_mask': 'uint64', + 'psw_addr': 'uint64', + 'reason': 'str' } } diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 74b3e4f..bfaee04 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -35,6 +35,8 @@ #include "qemu/error-report.h" #include "trace.h" #include "qapi/visitor.h" +#include "qapi-visit.h" +#include "sysemu/hw_accel.h" #include "exec/exec-all.h" #ifndef CONFIG_USER_ONLY #include "hw/hw.h" @@ -276,6 +278,58 @@ static void s390x_cpu_set_id(Object *obj, Visitor *v, = const char *name, cpu->id =3D value; } =20 +static GuestPanicInformation *s390x_cpu_get_crash_info(CPUState *cs) +{ + GuestPanicInformation *panic_info; + S390CPU *cpu =3D S390_CPU(cs); + + cpu_synchronize_state(cs); + panic_info =3D g_malloc0(sizeof(GuestPanicInformation)); + + panic_info->type =3D GUEST_PANIC_INFORMATION_TYPE_KVM_S390; + panic_info->u.kvm_s390.psw_mask =3D cpu->env.psw.mask; + panic_info->u.kvm_s390.psw_addr =3D cpu->env.psw.addr; + + switch (cs->exception_index) { + case EXCP_CRASH_PGM: + panic_info->u.kvm_s390.reason =3D g_strdup("program interrupt loop= "); + break; + case EXCP_CRASH_EXT: + panic_info->u.kvm_s390.reason =3D g_strdup("external interrupt loo= p"); + break; + case EXCP_CRASH_WAITPSW: + panic_info->u.kvm_s390.reason =3D g_strdup("disabled wait"); + break; + case EXCP_CRASH_OPEREXC: + panic_info->u.kvm_s390.reason =3D g_strdup("operation exception lo= op"); + break; + default: + panic_info->u.kvm_s390.reason =3D g_strdup("unknown crash reason"); + break; + } + + return panic_info; +} + +static void s390x_cpu_get_crash_info_qom(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + CPUState *cs =3D CPU(obj); + GuestPanicInformation *panic_info; + + if (!cs->crash_occurred) { + error_setg(errp, "No crash occured"); + return; + } + + panic_info =3D s390x_cpu_get_crash_info(cs); + + visit_type_GuestPanicInformation(v, "crash-information", &panic_info, + errp); + qapi_free_GuestPanicInformation(panic_info); +} + static void s390_cpu_initfn(Object *obj) { CPUState *cs =3D CPU(obj); @@ -291,6 +345,8 @@ static void s390_cpu_initfn(Object *obj) cs->exception_index =3D EXCP_HLT; object_property_add(OBJECT(cpu), "id", "int64_t", s390x_cpu_get_id, s390x_cpu_set_id, NULL, NULL, NULL); + object_property_add(obj, "crash-information", "GuestPanicInformation", + s390x_cpu_get_crash_info_qom, NULL, NULL, NULL, NU= LL); s390_cpu_model_register_props(obj); #if !defined(CONFIG_USER_ONLY) qemu_get_timedate(&tm, 0); @@ -517,6 +573,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) cc->do_interrupt =3D s390_cpu_do_interrupt; #endif cc->dump_state =3D s390_cpu_dump_state; + cc->get_crash_info =3D s390x_cpu_get_crash_info; cc->set_pc =3D s390_cpu_set_pc; cc->gdb_read_register =3D s390_cpu_gdb_read_register; cc->gdb_write_register =3D s390_cpu_gdb_write_register; diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 0bd97a5..dba32db 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -396,6 +396,12 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState*= env, target_ulong *pc, #define EXCP_IO 7 /* I/O interrupt */ #define EXCP_MCHK 8 /* machine check */ =20 +/* Crash cases. */ +#define EXCP_CRASH_PGM 9 +#define EXCP_CRASH_EXT 10 +#define EXCP_CRASH_WAITPSW 11 +#define EXCP_CRASH_OPEREXC 12 + #define INTERRUPT_EXT (1 << 0) #define INTERRUPT_TOD (1 << 1) #define INTERRUPT_CPUTIMER (1 << 2) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index d07763f..950ea42 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1941,15 +1941,31 @@ static bool is_special_wait_psw(CPUState *cs) return cs->kvm_run->psw_addr =3D=3D 0xfffUL; } =20 -static void unmanageable_intercept(S390CPU *cpu, const char *str, int pswo= ffset) +static void unmanageable_intercept(S390CPU *cpu, int32_t reason, int pswof= fset) { CPUState *cs =3D CPU(cpu); + const char *str; =20 + switch (reason) { + case EXCP_CRASH_PGM: + str =3D "program interrupt"; + break; + case EXCP_CRASH_EXT: + str =3D "external interrupt"; + break; + case EXCP_CRASH_OPEREXC: + str =3D "operation exception loop"; + break; + default: + str =3D "unknown crash reason"; + break; + } error_report("Unmanageable %s! CPU%i new PSW: 0x%016lx:%016lx", str, cs->cpu_index, ldq_phys(cs->as, cpu->env.psa + pswof= fset), ldq_phys(cs->as, cpu->env.psa + pswoffset + 8)); s390_cpu_halt(cpu); - qemu_system_guest_panicked(NULL); + cs->exception_index =3D reason; + qemu_system_guest_panicked(cpu_get_crash_info(cs)); } =20 /* try to detect pgm check loops */ @@ -1979,7 +1995,7 @@ static int handle_oper_loop(S390CPU *cpu, struct kvm_= run *run) !(oldpsw.mask & PSW_MASK_PSTATE) && (newpsw.mask & PSW_MASK_ASC) =3D=3D (oldpsw.mask & PSW_MASK_ASC) && (newpsw.mask & PSW_MASK_DAT) =3D=3D (oldpsw.mask & PSW_MASK_DAT)) { - unmanageable_intercept(cpu, "operation exception loop", + unmanageable_intercept(cpu, EXCP_CRASH_OPEREXC, offsetof(LowCore, program_new_psw)); return EXCP_HALTED; } @@ -2000,12 +2016,12 @@ static int handle_intercept(S390CPU *cpu) r =3D handle_instruction(cpu, run); break; case ICPT_PROGRAM: - unmanageable_intercept(cpu, "program interrupt", + unmanageable_intercept(cpu, EXCP_CRASH_PGM, offsetof(LowCore, program_new_psw)); r =3D EXCP_HALTED; break; case ICPT_EXT_INT: - unmanageable_intercept(cpu, "external interrupt", + unmanageable_intercept(cpu, EXCP_CRASH_EXT, offsetof(LowCore, external_new_psw)); r =3D EXCP_HALTED; break; @@ -2016,7 +2032,8 @@ static int handle_intercept(S390CPU *cpu) if (is_special_wait_psw(cs)) { qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUT= DOWN); } else { - qemu_system_guest_panicked(NULL); + cs->exception_index =3D EXCP_CRASH_WAITPSW; + qemu_system_guest_panicked(cpu_get_crash_info(cs)); } } r =3D EXCP_HALTED; diff --git a/vl.c b/vl.c index 9e62e92..354513a 100644 --- a/vl.c +++ b/vl.c @@ -1825,6 +1825,12 @@ void qemu_system_guest_panicked(GuestPanicInformatio= n *info) info->u.hyper_v.arg3, info->u.hyper_v.arg4, info->u.hyper_v.arg5); + } else if (info->type =3D=3D GUEST_PANIC_INFORMATION_TYPE_KVM_S390= ) { + qemu_log_mask(LOG_GUEST_ERROR, "KVM-S390 crash parameters: (%#" + PRIx64" %#"PRIx64")\nKVM-S390 crash reason: %s\n= ", + info->u.kvm_s390.psw_mask, + info->u.kvm_s390.psw_addr, + info->u.kvm_s390.reason); } qapi_free_GuestPanicInformation(info); } --=20 2.9.4