From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TthV2-0005hG-Ng for qemu-devel@nongnu.org; Fri, 11 Jan 2013 11:30:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TthUx-00082Q-Tn for qemu-devel@nongnu.org; Fri, 11 Jan 2013 11:30:32 -0500 Received: from cantor2.suse.de ([195.135.220.15]:41185 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TthUx-000826-HN for qemu-devel@nongnu.org; Fri, 11 Jan 2013 11:30:27 -0500 Message-ID: <50F03E1D.2030408@suse.de> Date: Fri, 11 Jan 2013 17:30:21 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1355106144-30846-1-git-send-email-lig.fnst@cn.fujitsu.com> <1355106144-30846-3-git-send-email-lig.fnst@cn.fujitsu.com> In-Reply-To: <1355106144-30846-3-git-send-email-lig.fnst@cn.fujitsu.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 3/3] target-i386:slightly refactor dr7 related function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: liguang Cc: Peter Maydell , imammedo@redhat.com, Jan Kiszka , ehabkost@redhat.com, qemu-devel@nongnu.org This is lacking a proper description of the slight refactoring. Am 10.12.2012 03:22, schrieb liguang: > Signed-off-by: liguang > --- > target-i386/helper.c | 74 +++++++++++++++++++++++++++++--------= ------- > target-i386/machine.c | 5 ++- > target-i386/misc_helper.c | 4 +- > target-i386/seg_helper.c | 7 ++-- > 4 files changed, 58 insertions(+), 32 deletions(-) >=20 > diff --git a/target-i386/helper.c b/target-i386/helper.c > index bf206cf..62746c5 100644 > --- a/target-i386/helper.c > +++ b/target-i386/helper.c > @@ -966,30 +966,33 @@ hwaddr cpu_get_phys_page_debug(CPUX86State *env, = target_ulong addr) > =20 > void hw_breakpoint_insert(CPUX86State *env, int index) > { > - int type, err =3D 0; > + int type =3D 0, err =3D 0; > =20 > switch (hw_breakpoint_type(env->dr[7], index)) { > - case 0: > - if (hw_breakpoint_enabled(env->dr[7], index)) > + case DR7_TYPE_BP_INST: > + if (hw_breakpoint_enabled(env->dr[7], index)) { > err =3D cpu_breakpoint_insert(env, env->dr[index], BP_CPU, > &env->cpu_breakpoint[index]); > + } > break; > - case 1: > + case DR7_TYPE_DATA_WR: > type =3D BP_CPU | BP_MEM_WRITE; > - goto insert_wp; > - case 2: > - /* No support for I/O watchpoints yet */ > break; > - case 3: > + case DR7_TYPE_DATA_RW: > type =3D BP_CPU | BP_MEM_ACCESS; > - insert_wp: > + break; > + case DR7_TYPE_IO_RW: Tab should be four spaces. > + /* No support for I/O watchpoints yet */ > + break; > + } > + if (type) { Another tab. > err =3D cpu_watchpoint_insert(env, env->dr[index], > hw_breakpoint_len(env->dr[7], inde= x), > type, &env->cpu_watchpoint[index])= ; > - break; > } > - if (err) > + if (err) { > env->cpu_breakpoint[index] =3D NULL; > + } > } > =20 > void hw_breakpoint_remove(CPUX86State *env, int index) > @@ -997,15 +1000,16 @@ void hw_breakpoint_remove(CPUX86State *env, int = index) > if (!env->cpu_breakpoint[index]) > return; > switch (hw_breakpoint_type(env->dr[7], index)) { > - case 0: > - if (hw_breakpoint_enabled(env->dr[7], index)) > + case DR7_TYPE_BP_INST: > + if (hw_breakpoint_enabled(env->dr[7], index)) { > cpu_breakpoint_remove_by_ref(env, env->cpu_breakpoint[inde= x]); > + } > break; > - case 1: > - case 3: > + case DR7_TYPE_DATA_RW: > + case DR7_TYPE_DATA_WR: > cpu_watchpoint_remove_by_ref(env, env->cpu_watchpoint[index]); > break; > - case 2: > + case DR7_TYPE_IO_RW: > /* No support for I/O watchpoints yet */ > break; > } > @@ -1014,22 +1018,42 @@ void hw_breakpoint_remove(CPUX86State *env, int= index) > int check_hw_breakpoints(CPUX86State *env, int force_dr6_update) > { > target_ulong dr6; > - int reg, type; > + int index; > int hit_enabled =3D 0; > + bool bp_match =3D false; > + bool wp_match =3D false; > =20 > dr6 =3D env->dr[6] & ~0xf; > - for (reg =3D 0; reg < 4; reg++) { > - type =3D hw_breakpoint_type(env->dr[7], reg); > - if ((type =3D=3D 0 && env->dr[reg] =3D=3D env->eip) || > - ((type & 1) && env->cpu_watchpoint[reg] && > - (env->cpu_watchpoint[reg]->flags & BP_WATCHPOINT_HIT))) { > - dr6 |=3D 1 << reg; > - if (hw_breakpoint_enabled(env->dr[7], reg)) > + for (index =3D 0; index < DR7_MAX_BP; index++) { > + switch (hw_breakpoint_type(env->dr[7], index)) { > + case DR7_TYPE_BP_INST: > + if (env->dr[index] =3D=3D env->eip) { > + bp_match =3D true; > + } > + break; > + case DR7_TYPE_DATA_WR: > + case DR7_TYPE_DATA_RW: > + if (env->cpu_watchpoint[index] && > + env->cpu_watchpoint[index]->flags & BP_WATCHPOINT_HIT)= { > + wp_match =3D true; > + } > + break; > + case DR7_TYPE_IO_RW: > + break; > + } > + if (bp_match || wp_match) { > + dr6 |=3D 1 << index; > + if (hw_breakpoint_enabled(env->dr[7], index)) { > hit_enabled =3D 1; > + } > + bp_match =3D false; > + wp_match =3D false; > } > } > - if (hit_enabled || force_dr6_update) > + if (hit_enabled || force_dr6_update) { > env->dr[6] =3D dr6; > + } > + > return hit_enabled; > } > =20 > diff --git a/target-i386/machine.c b/target-i386/machine.c > index 4771508..67131a4 100644 > --- a/target-i386/machine.c > +++ b/target-i386/machine.c > @@ -265,10 +265,11 @@ static int cpu_post_load(void *opaque, int versio= n_id) > =20 > cpu_breakpoint_remove_all(env, BP_CPU); > cpu_watchpoint_remove_all(env, BP_CPU); > - for (i =3D 0; i < 4; i++) > + for (i =3D 0; i < DR7_MAX_BP; i++) { This trivial change could be in 1/3. > hw_breakpoint_insert(env, i); > - > + } Tab. > tlb_flush(env, 1); > + > return 0; > } > =20 > diff --git a/target-i386/misc_helper.c b/target-i386/misc_helper.c > index a020379..5ee0863 100644 > --- a/target-i386/misc_helper.c > +++ b/target-i386/misc_helper.c > @@ -197,11 +197,11 @@ void helper_movl_drN_T0(CPUX86State *env, int reg= , target_ulong t0) > env->dr[reg] =3D t0; > hw_breakpoint_insert(env, reg); > } else if (reg =3D=3D 7) { > - for (i =3D 0; i < 4; i++) { > + for (i =3D 0; i < DR7_MAX_BP; i++) { > hw_breakpoint_remove(env, i); > } > env->dr[7] =3D t0; > - for (i =3D 0; i < 4; i++) { > + for (i =3D 0; i < DR7_MAX_BP; i++) { > hw_breakpoint_insert(env, i); > } > } else { Move both into 1/3? > diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c > index ff93374..306e9d1 100644 > --- a/target-i386/seg_helper.c > +++ b/target-i386/seg_helper.c > @@ -465,9 +465,10 @@ static void switch_tss(CPUX86State *env, int tss_s= elector, > =20 > #ifndef CONFIG_USER_ONLY > /* reset local breakpoints */ > - if (env->dr[7] & 0x55) { > - for (i =3D 0; i < 4; i++) { > - if (hw_breakpoint_enabled(env->dr[7], i) =3D=3D 0x1) { > + if (env->dr[7] & DR7_LOCAL_BP_MASK) { > + for (i =3D 0; i < DR7_MAX_BP; i++) { 1/3? > + if (hw_local_breakpoint_enabled(env->dr[7], i) && > + !hw_global_breakpoint_enabled(env->dr[7], i)) { > hw_breakpoint_remove(env, i); > } > } Regards, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg