From patchwork Tue Oct 20 07:50:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Lalancette X-Patchwork-Id: 54900 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9K7ooDk025567 for ; Tue, 20 Oct 2009 07:50:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751076AbZJTHun (ORCPT ); Tue, 20 Oct 2009 03:50:43 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751095AbZJTHun (ORCPT ); Tue, 20 Oct 2009 03:50:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47278 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750976AbZJTHun (ORCPT ); Tue, 20 Oct 2009 03:50:43 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9K7olbj008021 for ; Tue, 20 Oct 2009 03:50:48 -0400 Received: from localhost.localdomain (vpn-12-49.rdu.redhat.com [10.11.12.49]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9K7oknk000430; Tue, 20 Oct 2009 03:50:46 -0400 From: Chris Lalancette To: kvm@vger.kernel.org Cc: Chris Lalancette Subject: [PATCH] Print Guest VMCS state on vmexit failure Date: Tue, 20 Oct 2009 09:50:45 +0200 Message-Id: <1256025045-4972-1-git-send-email-clalance@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 311afd4..37b1682 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3452,6 +3452,14 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = { static const int kvm_vmx_max_exit_handlers = ARRAY_SIZE(kvm_vmx_exit_handlers); +#define PRINT_GUEST_SEGMENT(seg) do { \ + printk(KERN_DEBUG #seg ": SELECTOR 0x%lx, BASE 0x%lx, LIMIT 0x%lx, AR 0x%lx\n", \ + vmcs_readl(GUEST_##seg##_SELECTOR), \ + vmcs_readl(GUEST_##seg##_BASE), \ + vmcs_readl(GUEST_##seg##_LIMIT), \ + vmcs_readl(GUEST_##seg##_AR_BYTES)); \ + while(0) + /* * The guest has exited. See if we can fix it or if we need userspace * assistance. @@ -3512,6 +3520,36 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu) else { vcpu->run->exit_reason = KVM_EXIT_UNKNOWN; vcpu->run->hw.hardware_exit_reason = exit_reason; + + printk(KERN_DEBUG "GUEST STATE:\n"); + printk(KERN_DEBUG "CR0: 0x%lx\n", vmcs_readl(GUEST_CR0)); + printk(KERN_DEBUG "CR3: 0x%lx\n", vmcs_readl(GUEST_CR3)); + printk(KERN_DEBUG "CR4: 0x%lx\n", vmcs_readl(GUEST_CR4)); + printk(KERN_DEBUG "VMENTRY CONTROL: 0x%lx\n", + vmcs_readl(VM_ENTRY_CONTROLS)); + printk(KERN_DEBUG "DR7: 0x%lx\n", vmcs_readl(GUEST_DR7)); + printk(KERN_DEBUG "SYSENTER ESP: 0x%lx\n", + vmcs_readl(GUEST_SYSENTER_ESP)); + printk(KERN_DEBUG "SYSENTER EIP: 0x%lx\n", + vmcs_readl(GUEST_SYSENTER_EIP)); + + PRINT_GUEST_SEGMENT(CS); + PRINT_GUEST_SEGMENT(SS); + PRINT_GUEST_SEGMENT(DS); + PRINT_GUEST_SEGMENT(ES); + PRINT_GUEST_SEGMENT(FS); + PRINT_GUEST_SEGMENT(GS); + PRINT_GUEST_SEGMENT(TR); + PRINT_GUEST_SEGMENT(LDTR); + + printk(KERN_DEBUG "GDTR: BASE 0x%lx, LIMIT 0x%lx", + vmcs_readl(GUEST_GDTR_BASE), + vmcs_readl(GUEST_GDTR_LIMIT)); + printk(KERN_DEBUG "IDTR: BASE 0x%lx, LIMIT 0x%lx", + vmcs_readl(GUEST_IDTR_BASE), + vmcs_readl(GUEST_IDTR_LIMIT)); + printk(KERN_DEBUG "RIP: 0x%lx\n",vmcs_readl(GUEST_RIP)); + printk(KERN_DEBUG "RFLAGS: 0x%lx\n",vmcs_readl(GUEST_RFLAGS)); } return 0; }