diff mbox

[v2,11/45] exec-all: bring tb->invalid into tb->cflags

Message ID 1500235468-15341-12-git-send-email-cota@braap.org
State New
Headers show

Commit Message

Emilio Cota July 16, 2017, 8:03 p.m. UTC
This gets rid of a hole in struct TranslationBlock.

Signed-off-by: Emilio G. Cota <cota@braap.org>
---
 include/exec/exec-all.h   | 3 +--
 accel/tcg/cpu-exec.c      | 2 +-
 accel/tcg/translate-all.c | 3 +--
 3 files changed, 3 insertions(+), 5 deletions(-)

Comments

Richard Henderson July 17, 2017, 11:07 p.m. UTC | #1
On 07/16/2017 10:03 AM, Emilio G. Cota wrote:
> -    tb->invalid = true;
> +    tb->cflags |= CF_INVALID;

Modulo the store_release comment for the last patch,

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


r~
Emilio Cota July 18, 2017, 12:28 a.m. UTC | #2
On Mon, Jul 17, 2017 at 13:07:53 -1000, Richard Henderson wrote:
> On 07/16/2017 10:03 AM, Emilio G. Cota wrote:
> >-    tb->invalid = true;
> >+    tb->cflags |= CF_INVALID;
> 
> Modulo the store_release comment for the last patch,

same thing: note tb_lock is always held when checking the flag, and also
on removal.

		E.
diff mbox

Patch

diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 28e3a24..78a1714 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -326,12 +326,11 @@  struct TranslationBlock {
 #define CF_NOCACHE     0x10000 /* To be freed after execution */
 #define CF_USE_ICOUNT  0x20000
 #define CF_IGNORE_ICOUNT 0x40000 /* Do not generate icount code */
+#define CF_INVALID     0x80000 /* Protected by tb_lock */
 
     /* Per-vCPU dynamic tracing state used to generate this TB */
     uint32_t trace_vcpu_dstate;
 
-    uint16_t invalid;
-
     void *tc_ptr;    /* pointer to the translated code */
     uint8_t *tc_search;  /* pointer to search data */
     /* original tb when cflags has CF_NOCACHE */
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 9b5ce13..34841cd 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -387,7 +387,7 @@  static inline TranslationBlock *tb_find(CPUState *cpu,
             tb_lock();
             acquired_tb_lock = true;
         }
-        if (!tb->invalid) {
+        if (!(tb->cflags & CF_INVALID)) {
             tb_add_jump(last_tb, tb_exit, tb);
         }
     }
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 6d4c05f..53fbb06 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -1082,7 +1082,7 @@  void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
      * Mark the TB as invalid *after* it's been removed from tb_hash, which
      * eliminates the need to check this bit on lookups.
      */
-    tb->invalid = true;
+    tb->cflags |= CF_INVALID;
 
     /* remove the TB from the page list */
     if (tb->page_addr[0] != page_addr) {
@@ -1273,7 +1273,6 @@  TranslationBlock *tb_gen_code(CPUState *cpu,
     tb->flags = flags;
     tb->cflags = cflags;
     tb->trace_vcpu_dstate = *cpu->trace_dstate;
-    tb->invalid = false;
 
 #ifdef CONFIG_PROFILER
     tcg_ctx.tb_count1++; /* includes aborted translations because of