kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Chris Lalancette <clalance@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] Print Guest VMCS state on vmexit failure
Date: Tue, 20 Oct 2009 09:57:46 +0200	[thread overview]
Message-ID: <20091020075746.GI29477@redhat.com> (raw)
In-Reply-To: <1256025045-4972-1-git-send-email-clalance@redhat.com>

On Tue, Oct 20, 2009 at 09:50:45AM +0200, Chris Lalancette wrote:
> If we fail to handle a VMEXIT for some reason, print out a lot
> more debugging information about the state of the GUEST VMCS
> area.  This does not fix a bug, but helps a lot when trying to
> track down the cause of a VMEXIT/VMENTRY failure.
> 
> Signed-off-by: Chris Lalancette <clalance@redhat.com>
> ---
>  arch/x86/kvm/vmx.c |   38 ++++++++++++++++++++++++++++++++++++++
>  1 files changed, 38 insertions(+), 0 deletions(-)
> 
> 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;
Move this to separate function may be?  vmx_handle_exit() will be hard
to read with this blob in the middle.

--
			Gleb.

  reply	other threads:[~2009-10-20  7:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-20  7:50 [PATCH] Print Guest VMCS state on vmexit failure Chris Lalancette
2009-10-20  7:57 ` Gleb Natapov [this message]
2009-10-20  8:01   ` Chris Lalancette
2009-10-20  8:11 ` Avi Kivity
2009-10-20  8:42   ` Chris Lalancette
2009-10-20  8:55     ` Nikola Ciprich
2009-10-20  8:57       ` Chris Lalancette
2009-10-20  9:08         ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091020075746.GI29477@redhat.com \
    --to=gleb@redhat.com \
    --cc=clalance@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).