WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] vmx: Fix single step on debugger

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] vmx: Fix single step on debugger
From: Kouya Shimura <kouya@xxxxxxxxxxxxxx>
Date: Thu, 25 Dec 2008 11:53:34 +0900
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 24 Dec 2008 18:54:07 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <C574F9FB.207B2%keir.fraser@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <7kzlipkkf1.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxx> <C574F9FB.207B2%keir.fraser@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Keir Fraser writes:
> On 22/12/2008 02:34, "Kouya Shimura" <kouya@xxxxxxxxxxxxxx> wrote:
> 
> > Indeed, this fix is hacky but it works well for me.
> > 
> > At first, I tried setting GUEST_PENDING_DBG_EXCEPTIONS.BS
> > according to the SDM. As a result, the guest doesn't be killed
> > but never go progress after the STI instruction
> > (i.e. VM exit immediately after VM entry) as long as RFLAGS.TF=1.
> > That is inconvenient for debugging.
> > 
> > Is there any other way?
> 
> If you make it conditional on debugger_attached then I guess you can do what
> you like. I strongly dislike it though.
> 
>  -- Keir
> 

I read the SDM carefully, however, I can't find any solution for this.
Although the monitor trap flag might help, my machine doesn't have such
a feature.

At least, crashing the guest should be avoided.
Attached is the updated patch. I think it might become a little better.

Thanks,
Kouya

Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>

diff -r e2f36d066b7b xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Mon Dec 22 13:48:40 2008 +0000
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Thu Dec 25 11:50:56 2008 +0900
@@ -1314,8 +1314,29 @@
 
 static void vmx_set_info_guest(struct vcpu *v)
 {
+    unsigned long intr_shadow;
+
     vmx_vmcs_enter(v);
+
     __vmwrite(GUEST_DR7, v->arch.guest_context.debugreg[7]);
+
+    /* 
+     * If the interruptibility-state field indicates blocking by STI,
+     * setting the TF flag in the EFLAGS may cause VM entry to fail
+     * and crash the guest. See SDM 3B 22.3.1.5.
+     * Resetting the VMX_INTR_SHADOW_STI flag looks hackish but
+     * to set the GUEST_PENDING_DBG_EXCEPTIONS.BS here incurs
+     * immediately vmexit and hence make no progress.
+     */
+    intr_shadow = __vmread(GUEST_INTERRUPTIBILITY_INFO);
+    if ( v->domain->debugger_attached &&
+         (v->arch.guest_context.user_regs.eflags & X86_EFLAGS_TF) &&
+         (intr_shadow & VMX_INTR_SHADOW_STI) )
+    {
+        intr_shadow &= ~VMX_INTR_SHADOW_STI;
+        __vmwrite(GUEST_INTERRUPTIBILITY_INFO, intr_shadow);
+    }
+
     vmx_vmcs_exit(v);
 }
 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>