From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juergen Gross Subject: Re: Single step in HVM domU on Intel machine may see wrong DB6 Date: Wed, 05 Mar 2014 07:02:04 +0100 Message-ID: <5316BDDC.9020000@ts.fujitsu.com> References: <5305BE9F.2090600@ts.fujitsu.com> <5306E5D3.6000302@ts.fujitsu.com> <530E1D9E020000780011F938@nat28.tlf.novell.com> <530F00C7020000780011FBA1@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WL4u6-0007o6-PX for xen-devel@lists.xenproject.org; Wed, 05 Mar 2014 06:02:07 +0000 In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "Zhang, Yang Z" Cc: xen-devel , "Dong, Eddie" , "Nakajima, Jun" , Jan Beulich List-Id: xen-devel@lists.xenproject.org On 05.03.2014 03:22, Zhang, Yang Z wrote: > Jan Beulich wrote on 2014-02-27: >>>>> On 27.02.14 at 02:31, "Zhang, Yang Z" wrote: >>> Jan Beulich wrote on 2014-02-27: >>>>>>> On 26.02.14 at 06:15, "Zhang, Yang Z" >> wrote: >>>>> @@ -2690,9 +2688,13 @@ void vmx_vmexit_handler(struct >> cpu_user_regs >>>> *regs) >>>>> __vmread(EXIT_QUALIFICATION, &exit_qualification); >>>>> HVMTRACE_1D(TRAP_DEBUG, exit_qualification); >>>>> write_debugreg(6, exit_qualification | 0xffff0ff0); >>>>> - if ( !v->domain->debugger_attached || >>>>> cpu_has_monitor_trap_flag ) - goto exit_and_crash; - >>>>> domain_pause_for_debugger(); + if ( >>>>> v->domain->debugger_attached ) + >>>>> domain_pause_for_debugger(); + else + { + >>>>> __restore_debug_registers(v); + >>>>> hvm_inject_hw_exception(TRAP_debug, >> HVM_DELIVER_NO_ERROR_CODE); + >>>>> } >>>> >>>> I suppose you need to set DR6.BS after restoring the reigsters? >>> >>> Right but is not enough. If flag_dr_dirty is set, we need to restore >>> register from hardware. Conversely, restore is from debugreg and set >>> DR6 to exit_qualification. >> >> After some more thought, I in fact doubt that restoring the debug >> registers is in line with the current model: We should simply set >> DR6.BS in the in-memory copy when the debug registers aren't live yet >> (and it doesn't hurt to always do that). And since DR6 bits generally >> are sticky, I think exit_qualification actually needs to be or-ed into the in-memory copy. > > Will guest be confused to see the DR6.BS always set? You can't set DR6.BS unconditionally! This bit should be set only in case of a debug trap caused by single stepping, of course! At least our BS2000 domU will crash in case of an unmotivated DR6.BS in debug trap handling. Juergen -- Juergen Gross Principal Developer Operating Systems PBG PDG ES&S SWE OS6 Telephone: +49 (0) 89 62060 2932 Fujitsu e-mail: juergen.gross@ts.fujitsu.com Mies-van-der-Rohe-Str. 8 Internet: ts.fujitsu.com D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html