Skip to contentSkip to conversation

tcg: Remove redundant tcg_target_init checks

PATCH In review Richard Henderson 3 participants 6 messages Jun 4, 2013 – Jun 5, 2013

lore
Share & tools
lore
#0 lore raw

cover tcg: Remove redundant tcg_target_init checks

Reviewing the tcg/aarch64 patch set, and comparing that to existing hosts made me remember that I've wanted to do this for quite some time.

r~

Richard Henderson (2):
tcg: Use QEMU_BUILD_BUG_ON for CPU_TLB_ENTRY_BITS
tcg: Remove redundant tcg_target_init checks

 include/exec/cpu-defs.h | 2 +-
 tcg/arm/tcg-target.c    | 6 ------
 tcg/i386/tcg-target.c   | 6 ------
 tcg/s390/tcg-target.c   | 7 -------
 4 files changed, 1 insertion(+), 20 deletions(-)
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/2 tcg: Use QEMU_BUILD_BUG_ON for CPU_TLB_ENTRY_BITS

Rather than a hand-coded version of the same thing.

---
 include/exec/cpu-defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/exec/cpu-defs.h +1 -1
index d8c64e9..2e5a9ba 100644
@@ -99,7 +99,7 @@ typedef struct CPUTLBEntry {
                    sizeof(uintptr_t))];
 } CPUTLBEntry;
 
-extern int CPUTLBEntry_wrong_size[sizeof(CPUTLBEntry) == (1 << CPU_TLB_ENTRY_BITS) ? 1 : -1];
+QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS));
 
 #define CPU_COMMON_TLB \
     /* The meaning of the MMU modes is defined in the target code. */   \
Signature · 1 line
1.8.1.4
#3 lore raw

PATCH 2/2 tcg: Remove redundant tcg_target_init checks

In reply to Richard Henderson

We've got a compile-time check for the condition in exec/cpu-defs.h.

---
 tcg/arm/tcg-target.c  | 6 ------
 tcg/i386/tcg-target.c | 6 ------
 tcg/s390/tcg-target.c | 7 -------
 3 files changed, 19 deletions(-)
tcg/arm/tcg-target.c +0 -6
index 3d43412..6be736b 100644
@@ -2053,12 +2053,6 @@ static const TCGTargetOpDef arm_op_defs[] = {
 
 static void tcg_target_init(TCGContext *s)
 {
-#if !defined(CONFIG_USER_ONLY)
-    /* fail safe */
-    if ((1 << CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry))
-        tcg_abort();
-#endif
-
     tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);
     tcg_regset_set32(tcg_target_call_clobber_regs, 0,
                      (1 << TCG_REG_R0) |
tcg/i386/tcg-target.c +0 -6
index 9eec06c..9e95477 100644
@@ -2283,12 +2283,6 @@ static void tcg_target_init(TCGContext *s)
     }
 #endif
 
-#if !defined(CONFIG_USER_ONLY)
-    /* fail safe */
-    if ((1 << CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry))
-        tcg_abort();
-#endif
-
     if (TCG_TARGET_REG_BITS == 64) {
         tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);
         tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffff);
tcg/s390/tcg-target.c +0 -7
index 7d6f777..f229f1c 100644
@@ -2324,13 +2324,6 @@ static void query_facilities(void)
 
 static void tcg_target_init(TCGContext *s)
 {
-#if !defined(CONFIG_USER_ONLY)
-    /* fail safe */
-    if ((1 << CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry)) {
-        tcg_abort();
-    }
-#endif
-
     query_facilities();
 
     tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);
Signature · 1 line
1.8.1.4
Reviewed-by on the v1 series
#5 lore raw
In reply to Richard Henderson

Am 04.06.2013 18:58, schrieb Richard Henderson:

Quoted 5 lines

Reviewing the tcg/aarch64 patch set, and comparing that to existing hosts made me remember that I've wanted to do this for quite some time.

Quoted 7 lines

r~

Richard Henderson (2):
tcg: Use QEMU_BUILD_BUG_ON for CPU_TLB_ENTRY_BITS
tcg: Remove redundant tcg_target_init checks

Andreas

Quoted 7 lines
 include/exec/cpu-defs.h | 2 +-
 tcg/arm/tcg-target.c    | 6 ------
 tcg/i386/tcg-target.c   | 6 ------
 tcg/s390/tcg-target.c   | 7 -------
 4 files changed, 1 insertion(+), 20 deletions(-)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] tcg: Use QEMU_BUILD_BUG_ON for CPU_TLB_ENTRY_BITS

In reply to Richard Henderson
Quoted 20 lines · 在 2013-06-04二的 09:58 -0700,Richard Henderson写道:

Rather than a hand-coded version of the same thing.

---
 include/exec/cpu-defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/exec/cpu-defs.h +1 -1
index d8c64e9..2e5a9ba 100644
@@ -99,7 +99,7 @@ typedef struct CPUTLBEntry {
                    sizeof(uintptr_t))];
 } CPUTLBEntry;
 
-extern int CPUTLBEntry_wrong_size[sizeof(CPUTLBEntry) == (1 << CPU_TLB_ENTRY_BITS) ? 1 : -1];
+QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS));
 
 #define CPU_COMMON_TLB \
     /* The meaning of the MMU modes is defined in the target code. */   \
Reviewed-by on v1 2/2
#4 lore raw
In reply to Richard Henderson
Quoted 61 lines · 在 2013-06-04二的 09:58 -0700,Richard Henderson写道:

We've got a compile-time check for the condition in exec/cpu-defs.h.

---
 tcg/arm/tcg-target.c  | 6 ------
 tcg/i386/tcg-target.c | 6 ------
 tcg/s390/tcg-target.c | 7 -------
 3 files changed, 19 deletions(-)
tcg/arm/tcg-target.c +0 -6
index 3d43412..6be736b 100644
@@ -2053,12 +2053,6 @@ static const TCGTargetOpDef arm_op_defs[] = {
 
 static void tcg_target_init(TCGContext *s)
 {
-#if !defined(CONFIG_USER_ONLY)
-    /* fail safe */
-    if ((1 << CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry))
-        tcg_abort();
-#endif
-
     tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);
     tcg_regset_set32(tcg_target_call_clobber_regs, 0,
                      (1 << TCG_REG_R0) |
tcg/i386/tcg-target.c +0 -6
index 9eec06c..9e95477 100644
@@ -2283,12 +2283,6 @@ static void tcg_target_init(TCGContext *s)
     }
 #endif
 
-#if !defined(CONFIG_USER_ONLY)
-    /* fail safe */
-    if ((1 << CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry))
-        tcg_abort();
-#endif
-
     if (TCG_TARGET_REG_BITS == 64) {
         tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);
         tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0xffff);
tcg/s390/tcg-target.c +0 -7
index 7d6f777..f229f1c 100644
@@ -2324,13 +2324,6 @@ static void query_facilities(void)
 
 static void tcg_target_init(TCGContext *s)
 {
-#if !defined(CONFIG_USER_ONLY)
-    /* fail safe */
-    if ((1 << CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry)) {
-        tcg_abort();
-    }
-#endif
-
     query_facilities();
 
     tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0xffff);