diff mbox

[1/2] target-i386: tcg: Accept clwb instruction

Message ID 1446672286-9136-2-git-send-email-ehabkost@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eduardo Habkost Nov. 4, 2015, 9:24 p.m. UTC
Accept the clwb instruction (66 0F AE /6) if its corresponding feature
flag is enabled on CPUID[7].

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/translate.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Richard Henderson Nov. 6, 2015, 11:04 a.m. UTC | #1
On 11/04/2015 10:24 PM, Eduardo Habkost wrote:
> Accept the clwb instruction (66 0F AE /6) if its corresponding feature
> flag is enabled on CPUID[7].
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>   target-i386/translate.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/target-i386/translate.c b/target-i386/translate.c
> index b400d24..bac1685 100644
> --- a/target-i386/translate.c
> +++ b/target-i386/translate.c
> @@ -7716,10 +7716,21 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
>               }
>               break;
>           case 5: /* lfence */
> -        case 6: /* mfence */
>               if ((modrm & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE2))
>                   goto illegal_op;
>               break;
> +        case 6: /* mfence/clwb */
> +            if (s->prefix & PREFIX_DATA) {
> +                /* clwb */
> +                if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_CLWB))
> +                    goto illegal_op;
> +                gen_lea_modrm(env, s, modrm);

You should use gen_nop_modrm here, since we're not going to do anything with 
the address.  Otherwise,

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eduardo Habkost Nov. 6, 2015, 1:59 p.m. UTC | #2
On Fri, Nov 06, 2015 at 12:04:56PM +0100, Richard Henderson wrote:
> On 11/04/2015 10:24 PM, Eduardo Habkost wrote:
> >Accept the clwb instruction (66 0F AE /6) if its corresponding feature
> >flag is enabled on CPUID[7].
> >
> >Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> >---
> >  target-i386/translate.c | 13 ++++++++++++-
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> >
> >diff --git a/target-i386/translate.c b/target-i386/translate.c
> >index b400d24..bac1685 100644
> >--- a/target-i386/translate.c
> >+++ b/target-i386/translate.c
> >@@ -7716,10 +7716,21 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
> >              }
> >              break;
> >          case 5: /* lfence */
> >-        case 6: /* mfence */
> >              if ((modrm & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE2))
> >                  goto illegal_op;
> >              break;
> >+        case 6: /* mfence/clwb */
> >+            if (s->prefix & PREFIX_DATA) {
> >+                /* clwb */
> >+                if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_CLWB))
> >+                    goto illegal_op;
> >+                gen_lea_modrm(env, s, modrm);
> 
> You should use gen_nop_modrm here, since we're not going to do anything with
> the address.  Otherwise,
> 
> Reviewed-by: Richard Henderson <rth@twiddle.net>

Thanks! BTW, clflush uses gen_lea_modrm() too, does it do anything with
the address somewhere else?
Richard Henderson Nov. 6, 2015, 2:13 p.m. UTC | #3
On 11/06/2015 02:59 PM, Eduardo Habkost wrote:
> Thanks! BTW, clflush uses gen_lea_modrm() too, does it do anything with
> the address somewhere else?

Nope.  It probably pre-dates the introduction of gen_nop_modrm.


r~
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/target-i386/translate.c b/target-i386/translate.c
index b400d24..bac1685 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -7716,10 +7716,21 @@  static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
             }
             break;
         case 5: /* lfence */
-        case 6: /* mfence */
             if ((modrm & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE2))
                 goto illegal_op;
             break;
+        case 6: /* mfence/clwb */
+            if (s->prefix & PREFIX_DATA) {
+                /* clwb */
+                if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_CLWB))
+                    goto illegal_op;
+                gen_lea_modrm(env, s, modrm);
+            } else {
+                /* mfence */
+                if ((modrm & 0xc7) != 0xc0 || !(s->cpuid_features & CPUID_SSE2))
+                    goto illegal_op;
+            }
+            break;
         case 7: /* sfence / clflush */
             if ((modrm & 0xc7) == 0xc0) {
                 /* sfence */