Skip to content

Commit

Permalink
qom/cpu: atomically clear the tb_jmp_cache
Browse files Browse the repository at this point in the history
The ThreadSanitizer rightly complains that something initialised with a
normal access is later updated and read atomically.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20160930213106.20186-8-alex.bennee@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
stsquad authored and bonzini committed Oct 4, 2016
1 parent b6b3ccf commit ce7cf6a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion qom/cpu.c
Expand Up @@ -253,6 +253,7 @@ void cpu_reset(CPUState *cpu)
static void cpu_common_reset(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
int i;

if (qemu_loglevel_mask(CPU_LOG_RESET)) {
qemu_log("CPU Reset (CPU %d)\n", cpu->cpu_index);
Expand All @@ -268,7 +269,10 @@ static void cpu_common_reset(CPUState *cpu)
cpu->can_do_io = 1;
cpu->exception_index = -1;
cpu->crash_occurred = false;
memset(cpu->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *));

for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) {
atomic_set(&cpu->tb_jmp_cache[i], NULL);
}
}

static bool cpu_common_has_work(CPUState *cs)
Expand Down

0 comments on commit ce7cf6a

Please sign in to comment.