qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] ae06cb: gen-icount: add missing inline to gen


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] ae06cb: gen-icount: add missing inline to gen_tb_end
Date: Mon, 03 Jul 2017 03:07:00 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: ae06cb46b2d3d27ccad92ad962afda68ad1286a9
      
https://github.com/qemu/qemu/commit/ae06cb46b2d3d27ccad92ad962afda68ad1286a9
  Author: Emilio G. Cota <address@hidden>
  Date:   2017-06-30 (Fri, 30 Jun 2017)

  Changed paths:
    M include/exec/gen-icount.h

  Log Message:
  -----------
  gen-icount: add missing inline to gen_tb_end

Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>


  Commit: 53f6672bcf57d82b794a2cc3a3469be7d35c8653
      
https://github.com/qemu/qemu/commit/53f6672bcf57d82b794a2cc3a3469be7d35c8653
  Author: Emilio G. Cota <address@hidden>
  Date:   2017-06-30 (Fri, 30 Jun 2017)

  Changed paths:
    M include/exec/gen-icount.h

  Log Message:
  -----------
  gen-icount: use tcg_ctx.tcg_env instead of cpu_env

We are relying on cpu_env being defined as a global, yet most
targets (i.e. all but arm/a64) have it defined as a local variable.
Luckily all of them use the same "cpu_env" name, but really
compilation shouldn't break if the name of that local variable
changed.

Fix it by using tcg_ctx.tcg_env, which all targets set in their
translate_init function. This change also helps paving the way
for the upcoming "translation loop common to all targets" work.

Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>


  Commit: f3ced3c59287dabc253f83f0c70aa4934470c15e
      
https://github.com/qemu/qemu/commit/f3ced3c59287dabc253f83f0c70aa4934470c15e
  Author: Emilio G. Cota <address@hidden>
  Date:   2017-06-30 (Fri, 30 Jun 2017)

  Changed paths:
    M accel/tcg/cputlb.c
    M accel/tcg/translate-all.c
    M include/qom/cpu.h
    M qom/cpu.c

  Log Message:
  -----------
  tcg: consistently access cpu->tb_jmp_cache atomically

Some code paths can lead to atomic accesses racing with memset()
on cpu->tb_jmp_cache, which can result in torn reads/writes
and is undefined behaviour in C11.

These torn accesses are unlikely to show up as bugs, but from code
inspection they seem possible. For example, tb_phys_invalidate does:
    /* remove the TB from the hash list */
    h = tb_jmp_cache_hash_func(tb->pc);
    CPU_FOREACH(cpu) {
  if (atomic_read(&cpu->tb_jmp_cache[h]) == tb) {
      atomic_set(&cpu->tb_jmp_cache[h], NULL);
  }
    }
Here atomic_set might race with a concurrent memset (such as the
ones scheduled via "unsafe" async work, e.g. tlb_flush_page) and
therefore we might end up with a torn pointer (or who knows what,
because we are under undefined behaviour).

This patch converts parallel accesses to cpu->tb_jmp_cache to use
atomic primitives, thereby bringing these accesses back to defined
behaviour. The price to pay is to potentially execute more instructions
when clearing cpu->tb_jmp_cache, but given how infrequently they happen
and the small size of the cache, the performance impact I have measured
is within noise range when booting debian-arm.

Note that under "safe async" work (e.g. do_tb_flush) we could use memset
because no other vcpus are running. However I'm keeping these accesses
atomic as well to keep things simple and to avoid confusing analysis
tools such as ThreadSanitizer.

Reviewed-by: Paolo Bonzini <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>


  Commit: fd479c60f5766f7fb247ad146b9e3c33d03d2055
      
https://github.com/qemu/qemu/commit/fd479c60f5766f7fb247ad146b9e3c33d03d2055
  Author: Peter Maydell <address@hidden>
  Date:   2017-07-03 (Mon, 03 Jul 2017)

  Changed paths:
    M accel/tcg/cputlb.c
    M accel/tcg/translate-all.c
    M include/exec/gen-icount.h
    M include/qom/cpu.h
    M qom/cpu.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20170603' into staging

Queued TCG patches

# gpg: Signature made Fri 30 Jun 2017 20:03:53 BST
# gpg:                using RSA key 0xAD1270CC4DD0279B
# gpg: Good signature from "Richard Henderson <address@hidden>"
# gpg:                 aka "Richard Henderson <address@hidden>"
# gpg:                 aka "Richard Henderson <address@hidden>"
# Primary key fingerprint: 9CB1 8DDA F8E8 49AD 2AFC  16A4 AD12 70CC 4DD0 279B

* remotes/rth/tags/pull-tcg-20170603:
  tcg: consistently access cpu->tb_jmp_cache atomically
  gen-icount: use tcg_ctx.tcg_env instead of cpu_env
  gen-icount: add missing inline to gen_tb_end

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/82d76dc7fc19...fd479c60f576

reply via email to

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