Skip to content

Commit 22c5f44

Browse files
committed
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190211' into staging
Fix dynamic tlb resize Fix x86 host vector saturation Diagnose missing tcg labels # gpg: Signature made Mon 11 Feb 2019 16:57:52 GMT # gpg: using RSA key 64DF38E8AF7E215F # gpg: Good signature from "Richard Henderson <[email protected]>" [full] # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F * remotes/rth/tags/pull-tcg-20190211: cputlb: update TLB entry/index after tlb_fill exec-all: document that tlb_fill can trigger a TLB resize tcg/i386: fix unsigned vector saturating arithmetic tcg: Diagnose referenced labels that have not been emitted Signed-off-by: Peter Maydell <[email protected]>
2 parents a044e3d + 6d967cb commit 22c5f44

File tree

7 files changed

+52
-5
lines changed

7 files changed

+52
-5
lines changed

accel/tcg/cputlb.c

+4
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,8 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr)
10451045
if (unlikely(!tlb_hit(entry->addr_code, addr))) {
10461046
if (!VICTIM_TLB_HIT(addr_code, addr)) {
10471047
tlb_fill(ENV_GET_CPU(env), addr, 0, MMU_INST_FETCH, mmu_idx, 0);
1048+
index = tlb_index(env, mmu_idx, addr);
1049+
entry = tlb_entry(env, mmu_idx, addr);
10481050
}
10491051
assert(tlb_hit(entry->addr_code, addr));
10501052
}
@@ -1125,6 +1127,8 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
11251127
if (!VICTIM_TLB_HIT(addr_write, addr)) {
11261128
tlb_fill(ENV_GET_CPU(env), addr, 1 << s_bits, MMU_DATA_STORE,
11271129
mmu_idx, retaddr);
1130+
index = tlb_index(env, mmu_idx, addr);
1131+
tlbe = tlb_entry(env, mmu_idx, addr);
11281132
}
11291133
tlb_addr = tlb_addr_write(tlbe) & ~TLB_INVALID_MASK;
11301134
}

accel/tcg/softmmu_template.h

+8
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_ulong addr,
129129
if (!VICTIM_TLB_HIT(ADDR_READ, addr)) {
130130
tlb_fill(ENV_GET_CPU(env), addr, DATA_SIZE, READ_ACCESS_TYPE,
131131
mmu_idx, retaddr);
132+
index = tlb_index(env, mmu_idx, addr);
133+
entry = tlb_entry(env, mmu_idx, addr);
132134
}
133135
tlb_addr = entry->ADDR_READ;
134136
}
@@ -198,6 +200,8 @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target_ulong addr,
198200
if (!VICTIM_TLB_HIT(ADDR_READ, addr)) {
199201
tlb_fill(ENV_GET_CPU(env), addr, DATA_SIZE, READ_ACCESS_TYPE,
200202
mmu_idx, retaddr);
203+
index = tlb_index(env, mmu_idx, addr);
204+
entry = tlb_entry(env, mmu_idx, addr);
201205
}
202206
tlb_addr = entry->ADDR_READ;
203207
}
@@ -294,6 +298,8 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val,
294298
if (!VICTIM_TLB_HIT(addr_write, addr)) {
295299
tlb_fill(ENV_GET_CPU(env), addr, DATA_SIZE, MMU_DATA_STORE,
296300
mmu_idx, retaddr);
301+
index = tlb_index(env, mmu_idx, addr);
302+
entry = tlb_entry(env, mmu_idx, addr);
297303
}
298304
tlb_addr = tlb_addr_write(entry) & ~TLB_INVALID_MASK;
299305
}
@@ -372,6 +378,8 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val,
372378
if (!VICTIM_TLB_HIT(addr_write, addr)) {
373379
tlb_fill(ENV_GET_CPU(env), addr, DATA_SIZE, MMU_DATA_STORE,
374380
mmu_idx, retaddr);
381+
index = tlb_index(env, mmu_idx, addr);
382+
entry = tlb_entry(env, mmu_idx, addr);
375383
}
376384
tlb_addr = tlb_addr_write(entry) & ~TLB_INVALID_MASK;
377385
}

include/exec/exec-all.h

+5
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,11 @@ static inline void assert_no_pages_locked(void)
475475
struct MemoryRegionSection *iotlb_to_section(CPUState *cpu,
476476
hwaddr index, MemTxAttrs attrs);
477477

478+
/*
479+
* Note: tlb_fill() can trigger a resize of the TLB. This means that all of the
480+
* caller's prior references to the TLB table (e.g. CPUTLBEntry pointers) must
481+
* be discarded and looked up again (e.g. via tlb_entry()).
482+
*/
478483
void tlb_fill(CPUState *cpu, target_ulong addr, int size,
479484
MMUAccessType access_type, int mmu_idx, uintptr_t retaddr);
480485

tcg/i386/tcg-target.inc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2615,7 +2615,7 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc,
26152615
OPC_PADDSB, OPC_PADDSW, OPC_UD2, OPC_UD2
26162616
};
26172617
static int const usadd_insn[4] = {
2618-
OPC_PADDSB, OPC_PADDSW, OPC_UD2, OPC_UD2
2618+
OPC_PADDUB, OPC_PADDUW, OPC_UD2, OPC_UD2
26192619
};
26202620
static int const sub_insn[4] = {
26212621
OPC_PSUBB, OPC_PSUBW, OPC_PSUBD, OPC_PSUBQ
@@ -2624,7 +2624,7 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc,
26242624
OPC_PSUBSB, OPC_PSUBSW, OPC_UD2, OPC_UD2
26252625
};
26262626
static int const ussub_insn[4] = {
2627-
OPC_PSUBSB, OPC_PSUBSW, OPC_UD2, OPC_UD2
2627+
OPC_PSUBUB, OPC_PSUBUW, OPC_UD2, OPC_UD2
26282628
};
26292629
static int const mul_insn[4] = {
26302630
OPC_UD2, OPC_PMULLW, OPC_PMULLD, OPC_UD2

tcg/tcg-op.h

+1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ static inline void tcg_gen_op6ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
255255

256256
static inline void gen_set_label(TCGLabel *l)
257257
{
258+
l->present = 1;
258259
tcg_gen_op1(INDEX_op_set_label, label_arg(l));
259260
}
260261

tcg/tcg.c

+23
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ TCGLabel *gen_new_label(void)
305305
*l = (TCGLabel){
306306
.id = s->nb_labels++
307307
};
308+
#ifdef CONFIG_DEBUG_TCG
309+
QSIMPLEQ_INSERT_TAIL(&s->labels, l, next);
310+
#endif
308311

309312
return l;
310313
}
@@ -1092,6 +1095,9 @@ void tcg_func_start(TCGContext *s)
10921095

10931096
QTAILQ_INIT(&s->ops);
10941097
QTAILQ_INIT(&s->free_ops);
1098+
#ifdef CONFIG_DEBUG_TCG
1099+
QSIMPLEQ_INIT(&s->labels);
1100+
#endif
10951101
}
10961102

10971103
static inline TCGTemp *tcg_temp_alloc(TCGContext *s)
@@ -3841,6 +3847,23 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
38413847
}
38423848
#endif
38433849

3850+
#ifdef CONFIG_DEBUG_TCG
3851+
/* Ensure all labels referenced have been emitted. */
3852+
{
3853+
TCGLabel *l;
3854+
bool error = false;
3855+
3856+
QSIMPLEQ_FOREACH(l, &s->labels, next) {
3857+
if (unlikely(!l->present) && l->refs) {
3858+
qemu_log_mask(CPU_LOG_TB_OP,
3859+
"$L%d referenced but not present.\n", l->id);
3860+
error = true;
3861+
}
3862+
}
3863+
assert(!error);
3864+
}
3865+
#endif
3866+
38443867
#ifdef CONFIG_PROFILER
38453868
atomic_set(&prof->opt_time, prof->opt_time - profile_getclock());
38463869
#endif

tcg/tcg.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,21 @@ typedef struct TCGRelocation {
244244
intptr_t addend;
245245
} TCGRelocation;
246246

247-
typedef struct TCGLabel {
247+
typedef struct TCGLabel TCGLabel;
248+
struct TCGLabel {
249+
unsigned present : 1;
248250
unsigned has_value : 1;
249-
unsigned id : 15;
251+
unsigned id : 14;
250252
unsigned refs : 16;
251253
union {
252254
uintptr_t value;
253255
tcg_insn_unit *value_ptr;
254256
TCGRelocation *first_reloc;
255257
} u;
256-
} TCGLabel;
258+
#ifdef CONFIG_DEBUG_TCG
259+
QSIMPLEQ_ENTRY(TCGLabel) next;
260+
#endif
261+
};
257262

258263
typedef struct TCGPool {
259264
struct TCGPool *next;
@@ -685,6 +690,7 @@ struct TCGContext {
685690
#endif
686691

687692
#ifdef CONFIG_DEBUG_TCG
693+
QSIMPLEQ_HEAD(, TCGLabel) labels;
688694
int temps_in_use;
689695
int goto_tb_issue_mask;
690696
#endif

0 commit comments

Comments
 (0)