[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 4/8] tcg-arm: Use QEMU_BUILD_BUG_ON to verify con
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v2 4/8] tcg-arm: Use QEMU_BUILD_BUG_ON to verify constraints on tlb |
Date: |
Fri, 30 Aug 2013 10:47:13 -0700 |
One of the two constraints we already checked via #if, but
the tlb offset distance was only checked at runtime.
Signed-off-by: Richard Henderson <address@hidden>
---
tcg/arm/tcg-target.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c
index 17e256a..f9311ac 100644
--- a/tcg/arm/tcg-target.c
+++ b/tcg/arm/tcg-target.c
@@ -1162,6 +1162,15 @@ static TCGReg tcg_out_arg_reg64(TCGContext *s, TCGReg
argreg,
#define TLB_SHIFT (CPU_TLB_ENTRY_BITS + CPU_TLB_BITS)
+/* We're expecting to use an 8-bit immediate and to mask. */
+QEMU_BUILD_BUG_ON(CPU_TLB_BITS > 8);
+
+/* We're expecting to use an 8-bit immediate add + 8-bit ldrd offset.
+ Using the offset of the second entry in the last tlb table ensures
+ that we can index all of the elements of the first entry. */
+QEMU_BUILD_BUG_ON(offsetof(CPUArchState, tlb_table[NB_MMU_MODES - 1][1])
+ > 0xffff);
+
/* Load and compare a TLB entry, leaving the flags set. Leaves R2 pointing
to the tlb entry. Clobbers R1 and TMP. */
@@ -1189,14 +1198,10 @@ static void tcg_out_tlb_read(TCGContext *s, TCGReg
addrlo, TCGReg addrhi,
* ldr r0, [r2, r0]! (3)
* cmp r0, tmp (4)
*/
-# if CPU_TLB_BITS > 8
-# error
-# endif
tcg_out_dat_reg(s, COND_AL, ARITH_MOV, TCG_REG_TMP,
0, addrlo, SHIFT_IMM_LSR(TARGET_PAGE_BITS));
- /* We assume that the offset is contained within 16 bits. */
- assert((tlb_offset & ~0xffff) == 0);
+ /* We checked that the offset is contained within 16 bits above. */
if (tlb_offset > 0xff) {
tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R2, base,
(24 << 7) | (tlb_offset >> 8));
--
1.8.1.4
- [Qemu-devel] [PATCH v2 0/8] tcg-arm ldst improvements, Richard Henderson, 2013/08/30
- [Qemu-devel] [PATCH v2 1/8] tcg-arm: Use ldrd/strd for appropriate qemu_ld/st64, Richard Henderson, 2013/08/30
- [Qemu-devel] [PATCH v2 3/8] tcg-arm: Use strd for tcg_out_arg_reg64, Richard Henderson, 2013/08/30
- [Qemu-devel] [PATCH v2 4/8] tcg-arm: Use QEMU_BUILD_BUG_ON to verify constraints on tlb,
Richard Henderson <=
- [Qemu-devel] [PATCH v2 2/8] tcg-arm: Rearrange slow-path qemu_ld/st, Richard Henderson, 2013/08/30
- [Qemu-devel] [PATCH v2 5/8] tcg-arm: Move load of tlb addend into tcg_out_tlb_read, Richard Henderson, 2013/08/30
- [Qemu-devel] [PATCH v2 6/8] tcg-arm: Return register containing tlb addend, Richard Henderson, 2013/08/30
- [Qemu-devel] [PATCH v2 7/8] tcg-arm: Remove restriction on qemu_ld output register, Richard Henderson, 2013/08/30
- [Qemu-devel] [PATCH v2 8/8] tcg-arm: Move the tlb addend load earlier, Richard Henderson, 2013/08/30