From patchwork Mon Mar 27 19:25:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 9647411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A248C60328 for ; Mon, 27 Mar 2017 19:26:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98BB328425 for ; Mon, 27 Mar 2017 19:26:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C7592842E; Mon, 27 Mar 2017 19:26:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4381528426 for ; Mon, 27 Mar 2017 19:26:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751716AbdC0T0E (ORCPT ); Mon, 27 Mar 2017 15:26:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49838 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751413AbdC0TZp (ORCPT ); Mon, 27 Mar 2017 15:25:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3FAC8046D; Mon, 27 Mar 2017 19:25:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B3FAC8046D Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jpoimboe@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B3FAC8046D Received: from treble.redhat.com (ovpn-121-27.rdu2.redhat.com [10.10.121.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C6945C886; Mon, 27 Mar 2017 19:25:42 +0000 (UTC) From: Josh Poimboeuf To: Paolo Bonzini , rkrcmar@redhat.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH] kvm/x86/vmx: report KVM_SYSTEM_EVENT_CRASH on triple fault Date: Mon, 27 Mar 2017 14:25:35 -0500 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 27 Mar 2017 19:25:44 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While debugging a kernel issue, I found that QEMU always reboots when an x86 triple fault occurs, which complicates debugging. QEMU and libvirt have a facility for creating a dump when KVM reports KVM_SYSTEM_EVENT_CRASH. So change the VMX triple fault handler to do that. This gives user space the ability to decide whether to dump, pause, shutdown, or reboot. Signed-off-by: Josh Poimboeuf --- arch/x86/kvm/vmx.c | 3 ++- include/trace/events/kvm.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 3acde66..1f2694c 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -5731,7 +5731,8 @@ static int handle_external_interrupt(struct kvm_vcpu *vcpu) static int handle_triple_fault(struct kvm_vcpu *vcpu) { - vcpu->run->exit_reason = KVM_EXIT_SHUTDOWN; + vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT; + vcpu->run->system_event.type = KVM_SYSTEM_EVENT_CRASH; return 0; } diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h index 8ade3eb..200a3d7 100644 --- a/include/trace/events/kvm.h +++ b/include/trace/events/kvm.h @@ -14,7 +14,8 @@ ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR), \ ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\ ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI), ERSN(PAPR_HCALL), \ - ERSN(S390_UCONTROL), ERSN(WATCHDOG), ERSN(S390_TSCH) + ERSN(S390_UCONTROL), ERSN(WATCHDOG), ERSN(S390_TSCH), \ + ERSN(SYSTEM_EVENT) TRACE_EVENT(kvm_userspace_exit, TP_PROTO(__u32 reason, int errno),