Skip to content

Commit

Permalink
accel/tcg: Test CPUJumpCache in tb_jmp_cache_clear_page
Browse files Browse the repository at this point in the history
After commit 4e4fa6c ("accel/tcg: Complete cpu initialization
before registration"), it looks the CPUJumpCache pointer can be NULL.
This causes a SIGSEV when running debug-wp-migration kvm unit test.

At the first place it should be clarified why this TCG code is called
with KVM acceleration. This may hide another bug.

Fixes: 4e4fa6c ("accel/tcg: Complete cpu initialization before registration")
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Message-Id: <20230203171510.2867451-1-eric.auger@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
eauger authored and rth7680 committed Feb 4, 2023
1 parent 579510e commit 99ab4d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion accel/tcg/cputlb.c
Expand Up @@ -100,9 +100,14 @@ static void tlb_window_reset(CPUTLBDesc *desc, int64_t ns,

static void tb_jmp_cache_clear_page(CPUState *cpu, target_ulong page_addr)
{
int i, i0 = tb_jmp_cache_hash_page(page_addr);
CPUJumpCache *jc = cpu->tb_jmp_cache;
int i, i0;

if (unlikely(!jc)) {
return;
}

i0 = tb_jmp_cache_hash_page(page_addr);
for (i = 0; i < TB_JMP_PAGE_SIZE; i++) {
qatomic_set(&jc->array[i0 + i].tb, NULL);
}
Expand Down

0 comments on commit 99ab4d5

Please sign in to comment.