From: Kouya Shimura Subject: [PATCH] vmx: fix single stepping on debugger Date: Tue, 11 Nov 2008 10:28:05 +0900 Message-ID: <7kd4h3dpax.fsf@pingu.sky.yk.fujitsu.co.jp> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="4+768ljsBF" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --4+768ljsBF Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit The debuggee domain will die with unexpected trap on single stepping of emulated instruction. Signed-off-by: Kouya Shimura --4+768ljsBF Content-Type: text/x-patch Content-Disposition: inline; filename="vmx_single_step.patch" Content-Transfer-Encoding: 7bit diff -r 5fd51e1e9c79 xen/arch/x86/hvm/vmx/realmode.c --- a/xen/arch/x86/hvm/vmx/realmode.c Wed Nov 05 10:57:21 2008 +0000 +++ b/xen/arch/x86/hvm/vmx/realmode.c Tue Nov 11 09:45:52 2008 +0900 @@ -148,6 +148,14 @@ static void realmode_emulate_one(struct hvmemul_ctxt->exn_insn_len = 0; } + if ( curr->domain->debugger_attached && + ( hvmemul_ctxt->exn_vector == TRAP_debug || + hvmemul_ctxt->exn_vector == TRAP_int3 ) ) + { + domain_pause_for_debugger(); + return; + } + if ( curr->arch.hvm_vcpu.guest_cr[0] & X86_CR0_PE ) { gdprintk(XENLOG_ERR, "Exception %02x in protected mode.\n", diff -r 5fd51e1e9c79 xen/arch/x86/hvm/vmx/vmx.c --- a/xen/arch/x86/hvm/vmx/vmx.c Wed Nov 05 10:57:21 2008 +0000 +++ b/xen/arch/x86/hvm/vmx/vmx.c Tue Nov 11 09:45:52 2008 +0900 @@ -1154,8 +1154,6 @@ static void vmx_inject_exception( { struct vcpu *curr = current; - vmx_inject_hw_exception(curr, trapnr, errcode); - if ( trapnr == TRAP_page_fault ) curr->arch.hvm_vcpu.guest_cr[2] = cr2; @@ -1164,7 +1162,14 @@ static void vmx_inject_exception( { __restore_debug_registers(curr); write_debugreg(6, read_debugreg(6) | 0x4000); + if ( curr->domain->debugger_attached ) + { + domain_pause_for_debugger(); + return; + } } + + vmx_inject_hw_exception(curr, trapnr, errcode); } static int vmx_event_pending(struct vcpu *v) --4+768ljsBF Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --4+768ljsBF--