From nobody Thu May 2 12:51:13 2024 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; dmarc=fail(p=none dis=none) header.from=de.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517840323612933.93445524163; Mon, 5 Feb 2018 06:18:43 -0800 (PST) Received: from localhost ([::1]:47128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eihbW-000340-Lr for importer@patchew.org; Mon, 05 Feb 2018 09:18:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eihVs-00071T-AT for qemu-devel@nongnu.org; Mon, 05 Feb 2018 09:12:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eihVo-0004Un-Tv for qemu-devel@nongnu.org; Mon, 05 Feb 2018 09:12:52 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33730 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 1eihVo-0004UW-P9 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 09:12:48 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15ECfml140382 for ; Mon, 5 Feb 2018 09:12:48 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fxrf894f8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 09:12:45 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 14:12:19 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 14:12:16 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w15ECGrk58392774; Mon, 5 Feb 2018 14:12:16 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7EFAEA4051; Mon, 5 Feb 2018 14:05:43 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64AFDA4040; Mon, 5 Feb 2018 14:05:43 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 5 Feb 2018 14:05:43 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id AA10420F69E; Mon, 5 Feb 2018 15:12:15 +0100 (CET) From: Christian Borntraeger To: qemu-s390x Date: Mon, 5 Feb 2018 14:12:15 +0000 X-Mailer: git-send-email 2.14.3 X-TM-AS-GCONF: 00 x-cbid: 18020514-0020-0000-0000-000003F274DB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020514-0021-0000-0000-00004284E883 Message-Id: <20180205141215.50207-1-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802050181 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 v4] 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 , Cornelia Huck , Halil Pasic , qemu-devel , Christian Borntraeger 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" 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 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": "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": "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 S390 crash parameters: (0x0000100000000000 0x0000000000000006) S390 crash reason: operation exception loop Co-authored-by: Jing Liu Signed-off-by: Christian Borntraeger --- qapi/run-state.json | 27 ++++++++++++++++++++++-- target/s390x/cpu.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ target/s390x/cpu.h | 10 +++++++++ target/s390x/helper.c | 5 ++++- target/s390x/kvm.c | 15 +++++++------- vl.c | 6 ++++++ 6 files changed, 109 insertions(+), 11 deletions(-) diff --git a/qapi/run-state.json b/qapi/run-state.json index bca46a8785..13901b4b22 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -320,22 +320,29 @@ # # An enumeration of the guest panic information types # +# @hyper-v: hyper-v guest panic information type +# +# @s390: s390 guest panic information type (Since: 2.12) +# # Since: 2.9 ## { 'enum': 'GuestPanicInformationType', - 'data': [ 'hyper-v'] } + 'data': [ 'hyper-v', 's390' ] } =20 ## # @GuestPanicInformation: # # Information about a guest panic # +# @type: Crash type that defines the hypervisor specific information +# # Since: 2.9 ## {'union': 'GuestPanicInformation', 'base': {'type': 'GuestPanicInformationType'}, 'discriminator': 'type', - 'data': { 'hyper-v': 'GuestPanicInformationHyperV' } } + 'data': { 'hyper-v': 'GuestPanicInformationHyperV', + 's390': 'GuestPanicInformationS390' } } =20 ## # @GuestPanicInformationHyperV: @@ -350,3 +357,19 @@ 'arg3': 'uint64', 'arg4': 'uint64', 'arg5': 'uint64' } } + +## +# @GuestPanicInformationS390: +# +# S390 specific guest panic information (PSW) +# +# @psw-mask: control fields of guest PSW +# @psw-addr: guest instruction address +# @reason: guest crash reason in human readable form +# +# Since: 2.12 +## +{'struct': 'GuestPanicInformationS390', + 'data': { 'psw-mask': 'uint64', + 'psw-addr': 'uint64', + 'reason': 'str' } } diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index d2e6b9f5c7..4c13864a0e 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" #include "hw/qdev-properties.h" #ifndef CONFIG_USER_ONLY @@ -237,6 +239,58 @@ out: error_propagate(errp, err); } =20 +static GuestPanicInformation *s390_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_S390; + panic_info->u.s390.psw_mask =3D cpu->env.psw.mask; + panic_info->u.s390.psw_addr =3D cpu->env.psw.addr; + + switch (cpu->env.crash_reason) { + case CRASH_REASON_PGM: + panic_info->u.s390.reason =3D g_strdup("program interrupt loop"); + break; + case CRASH_REASON_EXT: + panic_info->u.s390.reason =3D g_strdup("external interrupt loop"); + break; + case CRASH_REASON_WAITPSW: + panic_info->u.s390.reason =3D g_strdup("disabled wait"); + break; + case CRASH_REASON_OPEREXC: + panic_info->u.s390.reason =3D g_strdup("operation exception loop"); + break; + default: + panic_info->u.s390.reason =3D g_strdup("unknown crash reason"); + break; + } + + return panic_info; +} + +static void s390_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 s390_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); @@ -249,6 +303,8 @@ static void s390_cpu_initfn(Object *obj) cs->env_ptr =3D env; cs->halted =3D 1; cs->exception_index =3D EXCP_HLT; + object_property_add(obj, "crash-information", "GuestPanicInformation", + s390_cpu_get_crash_info_qom, NULL, NULL, NULL, NUL= L); s390_cpu_model_register_props(obj); #if !defined(CONFIG_USER_ONLY) qemu_get_timedate(&tm, 0); @@ -482,6 +538,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 s390_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 a1123ad621..71414cc324 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -77,6 +77,14 @@ typedef struct MchkQueue { uint16_t type; } MchkQueue; =20 +/* Crash cases. */ +enum crash_reasons { + CRASH_REASON_PGM, + CRASH_REASON_EXT, + CRASH_REASON_WAITPSW, + CRASH_REASON_OPEREXC, +}; + struct CPUS390XState { uint64_t regs[16]; /* GP registers */ /* @@ -102,6 +110,8 @@ struct CPUS390XState { =20 PSW psw; =20 + enum crash_reasons crash_reason; + uint64_t cc_src; uint64_t cc_dst; uint64_t cc_vr; diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 35d9741918..56c3f13686 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -84,12 +84,15 @@ static inline bool is_special_wait_psw(uint64_t psw_add= r) =20 void s390_handle_wait(S390CPU *cpu) { + CPUState *cs =3D CPU(cpu); + if (s390_cpu_halt(cpu) =3D=3D 0) { #ifndef CONFIG_USER_ONLY if (is_special_wait_psw(cpu->env.psw.addr)) { qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); } else { - qemu_system_guest_panicked(NULL); + cpu->env.crash_reason =3D CRASH_REASON_WAITPSW; + qemu_system_guest_panicked(cpu_get_crash_info(cs)); } #endif } diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 8736001156..e8d2b7410b 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1568,15 +1568,14 @@ static int handle_instruction(S390CPU *cpu, struct = kvm_run *run) return r; } =20 -static void unmanageable_intercept(S390CPU *cpu, const char *str, int pswo= ffset) +static void unmanageable_intercept(S390CPU *cpu, enum crash_reasons reason, + int pswoffset) { CPUState *cs =3D CPU(cpu); =20 - 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); + cpu->env.crash_reason =3D reason; + qemu_system_guest_panicked(cpu_get_crash_info(cs)); } =20 /* try to detect pgm check loops */ @@ -1606,7 +1605,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, CRASH_REASON_OPEREXC, offsetof(LowCore, program_new_psw)); return EXCP_HALTED; } @@ -1627,12 +1626,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, CRASH_REASON_PGM, offsetof(LowCore, program_new_psw)); r =3D EXCP_HALTED; break; case ICPT_EXT_INT: - unmanageable_intercept(cpu, "external interrupt", + unmanageable_intercept(cpu, CRASH_REASON_EXT, offsetof(LowCore, external_new_psw)); r =3D EXCP_HALTED; break; diff --git a/vl.c b/vl.c index e517a8d995..74ea60f248 100644 --- a/vl.c +++ b/vl.c @@ -1761,6 +1761,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_S390) { + qemu_log_mask(LOG_GUEST_ERROR, "S390 crash parameters: (0x%016" + PRIx64" 0x%016" PRIx64")\nS390 crash reason: %s\= n", + info->u.s390.psw_mask, + info->u.s390.psw_addr, + info->u.s390.reason); } qapi_free_GuestPanicInformation(info); } --=20 2.14.3