From nobody Mon Apr 29 20:05:11 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.zoho.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 1487053920907725.336425651743; Mon, 13 Feb 2017 22:32:00 -0800 (PST) Received: from localhost ([::1]:32987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdWed-0000wl-OY for importer@patchew.org; Tue, 14 Feb 2017 01:31:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdWYO-0004I0-OO for qemu-devel@nongnu.org; Tue, 14 Feb 2017 01:25:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdWYL-0006V2-LO for qemu-devel@nongnu.org; Tue, 14 Feb 2017 01:25:32 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:40170 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cdWYL-0006T1-9h for qemu-devel@nongnu.org; Tue, 14 Feb 2017 01:25:29 -0500 Received: from iris.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v1E6POCi011943; Tue, 14 Feb 2017 09:25:26 +0300 (MSK) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Date: Tue, 14 Feb 2017 09:25:22 +0300 Message-Id: <1487053524-18674-2-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487053524-18674-1-git-send-email-den@openvz.org> References: <1487053524-18674-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH v4 1/3] i386/cpu: add crash-information QOM property 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: "Denis V . Lunev" , Anton Nefedov 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: Anton Nefedov Windows reports BSOD parameters through Hyper-V crash MSRs. This information is very useful for initial crash analysis and thus it would be nice to have a way to fetch it. Signed-off-by: Anton Nefedov Signed-off-by: Denis V. Lunev --- kvm-all.c | 1 + qapi-schema.json | 24 ++++++++++++++++++++++++ target/i386/cpu.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/kvm-all.c b/kvm-all.c index a27c880..64f46c8 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -2000,6 +2000,7 @@ int kvm_cpu_exec(CPUState *cpu) ret =3D EXCP_INTERRUPT; break; case KVM_SYSTEM_EVENT_CRASH: + kvm_cpu_synchronize_state(cpu); qemu_mutex_lock_iothread(); qemu_system_guest_panicked(); qemu_mutex_unlock_iothread(); diff --git a/qapi-schema.json b/qapi-schema.json index cbdffdd..9cb6ac5 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -5846,6 +5846,30 @@ 'data': [ 'pause', 'poweroff' ] } =20 ## +# @GuestPanicInformation: +# +# Information about a guest panic +# +# Since: 2.9 +## +{'union': 'GuestPanicInformation', + 'data': { 'hyper-v': 'GuestPanicInformationHyperV' } } + +## +# @GuestPanicInformationHyperV: +# +# Hyper-V specific guest panic information (HV crash MSRs) +# +# Since: 2.9 +## +{'struct': 'GuestPanicInformationHyperV', + 'data': { 'arg1': 'uint64', + 'arg2': 'uint64', + 'arg3': 'uint64', + 'arg4': 'uint64', + 'arg5': 'uint64' } } + +## # @rtc-reset-reinjection: # # This command will reset the RTC interrupt reinjection backlog. diff --git a/target/i386/cpu.c b/target/i386/cpu.c index eb49980..71aa91f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3495,6 +3495,53 @@ static void x86_cpu_register_feature_bit_props(X86CP= U *cpu, x86_cpu_register_bit_prop(cpu, name, &cpu->env.features[w], bitnr); } =20 +static GuestPanicInformation *x86_cpu_get_crash_info(CPUState *cs) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + GuestPanicInformation *panic_info =3D NULL; + + if (env->features[FEAT_HYPERV_EDX] & HV_X64_GUEST_CRASH_MSR_AVAILABLE)= { + GuestPanicInformationHyperV *panic_info_hv =3D + g_malloc0(sizeof(GuestPanicInformationHyperV)); + panic_info =3D g_malloc0(sizeof(GuestPanicInformation)); + + panic_info->type =3D GUEST_PANIC_INFORMATION_KIND_HYPER_V; + panic_info->u.hyper_v.data =3D panic_info_hv; + + assert(HV_X64_MSR_CRASH_PARAMS >=3D 5); + panic_info_hv->arg1 =3D env->msr_hv_crash_params[0]; + panic_info_hv->arg2 =3D env->msr_hv_crash_params[1]; + panic_info_hv->arg3 =3D env->msr_hv_crash_params[2]; + panic_info_hv->arg4 =3D env->msr_hv_crash_params[3]; + panic_info_hv->arg5 =3D env->msr_hv_crash_params[4]; + } + + return panic_info; +} +static void x86_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 x86_cpu_get_crash_info(cs); + if (panic_info =3D=3D NULL) { + error_setg(errp, "No crash information"); + return; + } + + visit_type_GuestPanicInformation(v, "crash-information", &panic_info, + errp); + qapi_free_GuestPanicInformation(panic_info); +} + static void x86_cpu_initfn(Object *obj) { CPUState *cs =3D CPU(obj); @@ -3530,6 +3577,9 @@ static void x86_cpu_initfn(Object *obj) x86_cpu_get_feature_words, NULL, NULL, (void *)cpu->filtered_features, NULL); =20 + object_property_add(obj, "crash-information", "GuestPanicInformation", + x86_cpu_get_crash_info_qom, NULL, NULL, NULL, NULL= ); + cpu->hyperv_spinlock_attempts =3D HYPERV_SPINLOCK_NEVER_RETRY; =20 for (w =3D 0; w < FEATURE_WORDS; w++) { --=20 2.7.4 From nobody Mon Apr 29 20:05:11 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.zoho.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 1487053647394636.6753256446086; Mon, 13 Feb 2017 22:27:27 -0800 (PST) Received: from localhost ([::1]:32963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdWaD-0005RW-R0 for importer@patchew.org; Tue, 14 Feb 2017 01:27:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdWYO-0004I1-Ox for qemu-devel@nongnu.org; Tue, 14 Feb 2017 01:25:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdWYL-0006VD-PJ for qemu-devel@nongnu.org; Tue, 14 Feb 2017 01:25:32 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:37333 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cdWYL-0006T2-9Z for qemu-devel@nongnu.org; Tue, 14 Feb 2017 01:25:29 -0500 Received: from iris.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v1E6POCj011943; Tue, 14 Feb 2017 09:25:26 +0300 (MSK) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Date: Tue, 14 Feb 2017 09:25:23 +0300 Message-Id: <1487053524-18674-3-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487053524-18674-1-git-send-email-den@openvz.org> References: <1487053524-18674-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH v4 2/3] report guest crash information in GUEST_PANICKED event 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: "Denis V . Lunev" , Anton Nefedov 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: Anton Nefedov it's not very convenient to use the crash-information property interface, so provide a CPU class callback to get the guest crash information, and pass that information in the event Signed-off-by: Anton Nefedov Signed-off-by: Denis V. Lunev --- hw/misc/pvpanic.c | 2 +- hw/ppc/spapr_rtas.c | 3 ++- include/qom/cpu.h | 10 ++++++++++ include/sysemu/sysemu.h | 2 +- kvm-all.c | 2 +- qapi/event.json | 6 ++++-- qom/cpu.c | 11 +++++++++++ target/i386/cpu.c | 1 + target/s390x/kvm.c | 4 ++-- vl.c | 11 ++++++++--- 10 files changed, 41 insertions(+), 11 deletions(-) diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 0ac1e6a..57da7f2 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -42,7 +42,7 @@ static void handle_event(int event) } =20 if (event & PVPANIC_PANICKED) { - qemu_system_guest_panicked(); + qemu_system_guest_panicked(NULL); return; } } diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index bb19944..619f32c 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -334,7 +334,8 @@ static void rtas_ibm_os_term(PowerPCCPU *cpu, { target_ulong ret =3D 0; =20 - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, false, NULL, + &error_abort); =20 rtas_st(rets, 0, ret); } diff --git a/include/qom/cpu.h b/include/qom/cpu.h index ca4d0fb..f95a6c3 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -156,6 +156,7 @@ typedef struct CPUClass { uint8_t *buf, int len, bool is_write); void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprint= f, int flags); + GuestPanicInformation* (*get_crash_info)(CPUState *cpu); void (*dump_statistics)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags); int64_t (*get_arch_id)(CPUState *cpu); @@ -469,6 +470,15 @@ int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, = CPUState *cpu, void *opaque); =20 /** + * cpu_get_crash_info: + * @cpu: The CPU to get crash information for + * + * Gets the previously saved crash information. + * Caller is responsible for freeing the data. + */ +GuestPanicInformation *cpu_get_crash_info(CPUState *cpu); + +/** * CPUDumpFlags: * @CPU_DUMP_CODE: * @CPU_DUMP_FPU: dump FPU register state, not just integer diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 4d50694..2c39bed 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -64,7 +64,7 @@ int qemu_shutdown_requested_get(void); int qemu_reset_requested_get(void); void qemu_system_killed(int signal, pid_t pid); void qemu_system_reset(bool report); -void qemu_system_guest_panicked(void); +void qemu_system_guest_panicked(GuestPanicInformation *info); size_t qemu_target_page_bits(void); =20 void qemu_add_exit_notifier(Notifier *notify); diff --git a/kvm-all.c b/kvm-all.c index 64f46c8..0c94637 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -2002,7 +2002,7 @@ int kvm_cpu_exec(CPUState *cpu) case KVM_SYSTEM_EVENT_CRASH: kvm_cpu_synchronize_state(cpu); qemu_mutex_lock_iothread(); - qemu_system_guest_panicked(); + qemu_system_guest_panicked(cpu_get_crash_info(cpu)); qemu_mutex_unlock_iothread(); ret =3D 0; break; diff --git a/qapi/event.json b/qapi/event.json index 7bf539b..970ff02 100644 --- a/qapi/event.json +++ b/qapi/event.json @@ -488,7 +488,9 @@ # # @action: action that has been taken, currently always "pause" # -# Since: 1.5 +# @info: optional information about a panic +# +# Since: 1.5 (@info since 2.9) # # Example: # @@ -497,7 +499,7 @@ # ## { 'event': 'GUEST_PANICKED', - 'data': { 'action': 'GuestPanicAction' } } + 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation'= } } =20 ## # @QUORUM_FAILURE: diff --git a/qom/cpu.c b/qom/cpu.c index d57faf3..5158f31 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -218,6 +218,17 @@ static bool cpu_common_exec_interrupt(CPUState *cpu, i= nt int_req) return false; } =20 +GuestPanicInformation *cpu_get_crash_info(CPUState *cpu) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + GuestPanicInformation *res =3D NULL; + + if (cc->get_crash_info) { + res =3D cc->get_crash_info(cpu); + } + return res; +} + void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags) { diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 71aa91f..fd7add2 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3734,6 +3734,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc= , void *data) cc->do_interrupt =3D x86_cpu_do_interrupt; cc->cpu_exec_interrupt =3D x86_cpu_exec_interrupt; cc->dump_state =3D x86_cpu_dump_state; + cc->get_crash_info =3D x86_cpu_get_crash_info; cc->set_pc =3D x86_cpu_set_pc; cc->synchronize_from_tb =3D x86_cpu_synchronize_from_tb; cc->gdb_read_register =3D x86_cpu_gdb_read_register; diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 6ed3876..2536780 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1864,7 +1864,7 @@ static void unmanageable_intercept(S390CPU *cpu, cons= t char *str, int pswoffset) 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(); + qemu_system_guest_panicked(NULL); } =20 static int handle_intercept(S390CPU *cpu) @@ -1897,7 +1897,7 @@ static int handle_intercept(S390CPU *cpu) if (is_special_wait_psw(cs)) { qemu_system_shutdown_request(); } else { - qemu_system_guest_panicked(); + qemu_system_guest_panicked(NULL); } } r =3D EXCP_HALTED; diff --git a/vl.c b/vl.c index b4eaf03..d68254b 100644 --- a/vl.c +++ b/vl.c @@ -1707,18 +1707,23 @@ void qemu_system_reset(bool report) cpu_synchronize_all_post_reset(); } =20 -void qemu_system_guest_panicked(void) +void qemu_system_guest_panicked(GuestPanicInformation *info) { if (current_cpu) { current_cpu->crash_occurred =3D true; } - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, + !!info, info, &error_abort); vm_stop(RUN_STATE_GUEST_PANICKED); if (!no_shutdown) { qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF, - &error_abort); + !!info, info, &error_abort); qemu_system_shutdown_request(); } + + if (info) { + qapi_free_GuestPanicInformation(info); + } } =20 void qemu_system_reset_request(void) --=20 2.7.4 From nobody Mon Apr 29 20:05:11 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.zoho.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 1487053847259229.76675616720627; Mon, 13 Feb 2017 22:30:47 -0800 (PST) Received: from localhost ([::1]:32983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdWdR-0008Sn-NY for importer@patchew.org; Tue, 14 Feb 2017 01:30:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdWYO-0004Hz-O4 for qemu-devel@nongnu.org; Tue, 14 Feb 2017 01:25:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdWYL-0006V0-Lh for qemu-devel@nongnu.org; Tue, 14 Feb 2017 01:25:32 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:16333 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cdWYL-0006TC-9d for qemu-devel@nongnu.org; Tue, 14 Feb 2017 01:25:29 -0500 Received: from iris.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v1E6POCk011943; Tue, 14 Feb 2017 09:25:26 +0300 (MSK) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Date: Tue, 14 Feb 2017 09:25:24 +0300 Message-Id: <1487053524-18674-4-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487053524-18674-1-git-send-email-den@openvz.org> References: <1487053524-18674-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH v4 3/3] vl: log available 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: "Denis V . Lunev" , Anton Nefedov 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: Anton Nefedov There is a suitable log mask for the purpose. Signed-off-by: Anton Nefedov Signed-off-by: Denis V. Lunev --- vl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vl.c b/vl.c index d68254b..903c46d 100644 --- a/vl.c +++ b/vl.c @@ -1709,6 +1709,8 @@ void qemu_system_reset(bool report) =20 void qemu_system_guest_panicked(GuestPanicInformation *info) { + qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed\n"); + if (current_cpu) { current_cpu->crash_occurred =3D true; } @@ -1722,6 +1724,15 @@ void qemu_system_guest_panicked(GuestPanicInformatio= n *info) } =20 if (info) { + if (info->type =3D=3D GUEST_PANIC_INFORMATION_KIND_HYPER_V) { + qemu_log_mask(LOG_GUEST_ERROR, "HV crash parameters: (%#"PRIx64 + " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n= ", + info->u.hyper_v.data->arg1, + info->u.hyper_v.data->arg2, + info->u.hyper_v.data->arg3, + info->u.hyper_v.data->arg4, + info->u.hyper_v.data->arg5); + } qapi_free_GuestPanicInformation(info); } } --=20 2.7.4