qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] tcg/i386: 'nop' instruction with 'lock' prefix


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH] tcg/i386: 'nop' instruction with 'lock' prefix is illegal
Date: Sun, 14 May 2017 14:12:30 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0

On 05/13/2017 08:58 AM, Pranith Kumar wrote:
The instruction "lock nopl (%rax)" should raise an exception. However,
we don't do that since we do not check for lock prefix for nop
instructions. The following patch adds this check and makes the
behavior similar to hardware.

Signed-off-by: Pranith Kumar <address@hidden>
---
  target/i386/translate.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/target/i386/translate.c b/target/i386/translate.c
index 1d1372fb43..76f4ccd3b4 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -7881,6 +7881,9 @@ static target_ulong disas_insn(CPUX86State *env, 
DisasContext *s,
          gen_nop_modrm(env, s, modrm);
          break;
      case 0x119: case 0x11c ... 0x11f: /* nop (multi byte) */
+        if (prefixes & PREFIX_LOCK) {
+            goto illegal_op;
+        }
          modrm = cpu_ldub_code(env, s->pc++);
          gen_nop_modrm(env, s, modrm);
          break;

Surely you'd also want to make this change for 0x11a and 0x11b. Which would also simplify that code a bit.

That said, there's *lots* of missing LOCK prefix checks. What brings this one in particular to your attention?


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]