From: "Jan Beulich" Subject: Re: Single step in HVM domU on Intel machine may see wrong DB6 Date: Tue, 11 Mar 2014 07:56:31 +0000 Message-ID: <531ECFBF0200007800122A8B@nat28.tlf.novell.com> References: <5305BE9F.2090600@ts.fujitsu.com> <5306E5D3.6000302@ts.fujitsu.com> <530E1D9E020000780011F938@nat28.tlf.novell.com> <530F00C7020000780011FBA1@nat28.tlf.novell.com> <5316E8E5020000780012117B@nat28.tlf.novell.com> <53199B850200007800121D46@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WNHYB-0007IR-1E for xen-devel@lists.xenproject.org; Tue, 11 Mar 2014 07:56:35 +0000 In-Reply-To: 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: Yang Z Zhang Cc: xen-devel , JuergenGross , Eddie Dong , Jun Nakajima List-Id: xen-devel@lists.xenproject.org >>> On 11.03.14 at 03:10, "Zhang, Yang Z" wrote: > Jan Beulich wrote on 2014-03-07: >>>>> On 07.03.14 at 06:10, "Zhang, Yang Z" wrote: >>> @@ -2689,10 +2698,18 @@ 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(); + exit_qualification |= >>> 0xffff0ff0; >> >> Is this really needed? > > Yes. The reserved bits need to set to 1 in DB6. But it is cleared in > exit_qualification. In which case I'd strongly suggest adding a respective #define to debugreg.h and using it here. >>> + if ( v->domain->debugger_attached ) >>> + { >>> + write_debugreg(6, exit_qualification); >>> + domain_pause_for_debugger(); >>> + } >>> + else >>> + { >>> + __restore_debug_registers(v); >>> + write_debugreg(6, exit_qualification | >> read_debugreg(6)); >> >> I still wonder whether it wouldn't be more efficient to simply or >> exit_qualification into v->arch.debugreg[6] before calling >> __restore_debug_registers(). >> > > __restore_debug_registers() only copy the v->arch.debugreg[6] into hardware > DB6 when flag_dr_dirty is cleared. So as I mentioned before, the hardware DB > register will hold the latest value if flag_dr_dirty is set and we should > write hardware DB6 directly. Except that, as per the earlier discussion, the intercept should not occur when flag_dr_dirty is set, as it ought to have got disabled when setting the flag while restoring debug registers. Jan