From: "Jan Beulich" Subject: Re: [V0 PATCH] SVM: set/unset TF flag for single_step Date: Thu, 03 Jul 2014 07:33:29 +0100 Message-ID: <53B51559020000780001FEF6@mail.emea.novell.com> References: <4c14b668-c76b-4a82-9236-9ed6840aefaa@default> <53B3E130020000780001F57D@mail.emea.novell.com> <20140702145238.68265fa0@mantra.us.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X2aaI-0003zY-S4 for xen-devel@lists.xenproject.org; Thu, 03 Jul 2014 06:33:30 +0000 In-Reply-To: <20140702145238.68265fa0@mantra.us.oracle.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Mukesh Rathor Cc: xen-devel@lists.xenproject.org, Boris Ostrovsky , keir.xen@gmail.com, Aravind.Gopalakrishnan@amd.com, suravee.suthikulpanit@amd.com List-Id: xen-devel@lists.xenproject.org >>> On 02.07.14 at 23:52, wrote: > On Wed, 02 Jul 2014 09:38:40 +0100 > "Jan Beulich" wrote: > >> >>> On 02.07.14 at 05:36, wrote: >> >> --- a/xen/arch/x86/hvm/svm/svm.c >> >> +++ b/xen/arch/x86/hvm/svm/svm.c >> >> @@ -2350,6 +2350,8 @@ void svm_vmexit_handler(struct cpu_user_regs >> >> *regs) >> >> case VMEXIT_EXCEPTION_DB: >> >> if ( !v->domain->debugger_attached ) >> >> goto exit_and_crash; >> >> + else >> >> + regs->eflags &= ~X86_EFLAGS_TF; >> >> domain_pause_for_debugger(); >> >> break; >> > >> > >> > I poked around debugger code and it looks to me that >> > tools/debugger/gdbsx/xg:_change_TF() manages this flag. > > _change_TF() only manages TF if XEN_DOMCTL_debug_op fails. Moreover, TF > handling is intended for PV. For HVM, xen provides > XEN_DOMCTL_debug_op which sets v->arch.hvm_vcpu.single_step. Maybe this is how things are expected to work right now (I admit to know very little about the specific debugger interface in Xen), but conceptually this is wrong (and I say this having written a number of kernel debuggers outside of Xen): Since the next thing done in the code path above is pausing the domain for debugging, and since the debugger ought to have control over the entire register state, it clearly has the power of setting TF to its liking, and hence no action on it should be needed here. Jan