[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] vmx: Fix single step on debugger
The hvm domain which is being debugged sometimes crashes with the following message: (XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state (0). (XEN) ************* VMCS Area ************** (XEN) *** Guest State *** (XEN) CR0: actual=0x000000008005003b, shadow=0x000000008005003b, gh_mask=ffffffffffffffff ...[snip]... (XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000 (XEN) *** Host State *** (XEN) RSP = 0xffff828c8024ffa0 RIP = 0xffff828c801885b0 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c8028a200 (XEN) GDTBase=ffff828c800f3000 IDTBase=ffff828c8028db20 (XEN) CR0=000000008005003b CR3=00000001315b9000 CR4=00000000000026b0 (XEN) Sysenter RSP=ffff828c8024ffd0 CS:RIP=e008:ffff828c801af290 (XEN) *** Control State *** (XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000013ff ExitControls=0003efff (XEN) ExceptionBitmap=0004400a (XEN) VMEntry: intr_info=00000031 errcode=00000004 ilen=00000000 (XEN) VMExit: intr_info=80000301 errcode=00000400 ilen=00000000 (XEN) reason=80000021 qualification=00000000 (XEN) IDTVectoring: info=00000000 errcode=00000000 (XEN) TPR Threshold = 0x00 (XEN) EPT pointer = 0x0000000000000000 (XEN) Virtual processor ID = 0x0000 (XEN) ************************************** (XEN) domain_crash called from vmx.c:2207 (XEN) Domain 14 (vcpu#0) crashed on cpu#0: Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx> diff -r 8c35da364ab3 xen/arch/x86/hvm/vmx/vmx.c --- a/xen/arch/x86/hvm/vmx/vmx.c Thu Dec 18 17:18:28 2008 +0000 +++ b/xen/arch/x86/hvm/vmx/vmx.c Fri Dec 19 18:22:29 2008 +0900 @@ -1314,8 +1314,41 @@ static void vmx_set_uc_mode(struct vcpu static void vmx_set_info_guest(struct vcpu *v) { + unsigned long intrblty; + unsigned long activity; + unsigned long debugctl; + vmx_vmcs_enter(v); + __vmwrite(GUEST_DR7, v->arch.guest_context.debugreg[7]); + + /* + * Setting X86_EFLAGS_TF may cause VM entry to fail. + * See SDM 3B 22.3.1.5. + */ + if ( v->arch.guest_context.user_regs.eflags & X86_EFLAGS_TF ) + { + intrblty = __vmread(GUEST_INTERRUPTIBILITY_INFO); + activity = __vmread(GUEST_ACTIVITY_STATE); + + if ( (intrblty & (VMX_INTR_SHADOW_STI|VMX_INTR_SHADOW_MOV_SS)) || + (activity == VMX_ACTIVITY_STATE_HLT) ) + { + debugctl = __vmread(GUEST_IA32_DEBUGCTL); + debugctl |= VMX_IA32_DEBUGCTL_BTF; + __vmwrite(GUEST_IA32_DEBUGCTL, debugctl); + } + } + else + { + debugctl = __vmread(GUEST_IA32_DEBUGCTL); + if ( debugctl & VMX_IA32_DEBUGCTL_BTF ) + { + debugctl &= ~VMX_IA32_DEBUGCTL_BTF; + __vmwrite(GUEST_IA32_DEBUGCTL, debugctl); + } + } + vmx_vmcs_exit(v); } diff -r 8c35da364ab3 xen/include/asm-x86/hvm/vmx/vmcs.h --- a/xen/include/asm-x86/hvm/vmx/vmcs.h Thu Dec 18 17:18:28 2008 +0000 +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h Fri Dec 19 18:22:29 2008 +0900 @@ -196,6 +196,16 @@ extern bool_t cpu_has_vmx_ins_outs_instr #define VMX_INTR_SHADOW_SMI 0x00000004 #define VMX_INTR_SHADOW_NMI 0x00000008 +enum guest_activity_state { + VMX_ACTIVITY_STATE_ACTIVE = 0, + VMX_ACTIVITY_STATE_HLT = 1, + VMX_ACTIVITY_STATE_SHUTDOWN = 2, + VMX_ACTIVITY_STATE_WAIT_FOR_SIPI = 3, +}; + +/* GUEST_IA32_DEBUGCTL flags */ +#define VMX_IA32_DEBUGCTL_BTF 0x00000002 // single-step on branches + /* VMCS field encodings. */ enum vmcs_field { VIRTUAL_PROCESSOR_ID = 0x00000000, _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |