qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 05/11] tcg/i386: Make direct jump patching threa


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH 05/11] tcg/i386: Make direct jump patching thread-safe
Date: Wed, 20 Apr 2016 08:04:34 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1

On 04/20/2016 02:55 AM, Alex Bennée wrote:
+static void tcg_out_nopn(TCGContext *s, int n)
+{
+    static const uint8_t nop1[] = { 0x90 };
+    static const uint8_t nop2[] = { 0x66, 0x90 };
+    static const uint8_t nop3[] = { 0x8d, 0x76, 0x00 };
+    static const uint8_t *const nopn[] = { nop1, nop2, nop3 };
+    int i;
+    assert(n <= ARRAY_SIZE(nopn));
+    for (i = 0; i < n; ++i) {
+        tcg_out8(s, nopn[n - 1][i]);
+    }
+}

*shudder* I recall x86 instruction encoding is weird. Maybe a comment
  for the function to describe the 3 forms of NOP we have here?

I think I'd prefer to drop the tables and do

  /* Emit 1 or 2 operand size prefixes for the standard one byte nop,
     xchg %eax,%eax, forming xchg %ax,%ax.  All cores accept the
     duplicate prefix, and all of the interesting recent cores can
     decode and discard the duplicates in a single cycle.  */
  for (i = 1; i < n; ++i) {
    tcg_out8(s, 0x66);
  }
  tcg_out8(s, 0x90);


r~



reply via email to

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