target/ppc: Use proper logging function for possible guest errors

fprintf() and qemu_log_separate() are frowned upon these days for printing
logging information in QEMU. Accessing the wrong SPRs indicates wrong guest
behaviour in most cases, and we've got a proper way to log such situations,
which is the qemu_log_mask(LOG_GUEST_ERROR, ...) function. So use this
function now for logging the bad SPR accesses instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Thomas Huth 2018-05-28 20:11:19 +02:00 committed by David Gibson
parent e20c63140a
commit 3108533829
1 changed files with 12 additions and 25 deletions

View File

@ -3933,13 +3933,9 @@ static inline void gen_op_mfspr(DisasContext *ctx)
* allowing userland application to read the PVR * allowing userland application to read the PVR
*/ */
if (sprn != SPR_PVR) { if (sprn != SPR_PVR) {
fprintf(stderr, "Trying to read privileged spr %d (0x%03x) at " qemu_log_mask(LOG_GUEST_ERROR, "Trying to read privileged spr "
TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4); "%d (0x%03x) at " TARGET_FMT_lx "\n", sprn, sprn,
if (qemu_log_separate()) { ctx->base.pc_next - 4);
qemu_log("Trying to read privileged spr %d (0x%03x) at "
TARGET_FMT_lx "\n", sprn, sprn,
ctx->base.pc_next - 4);
}
} }
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG); gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG);
} }
@ -3951,12 +3947,9 @@ static inline void gen_op_mfspr(DisasContext *ctx)
return; return;
} }
/* Not defined */ /* Not defined */
fprintf(stderr, "Trying to read invalid spr %d (0x%03x) at " qemu_log_mask(LOG_GUEST_ERROR,
TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4); "Trying to read invalid spr %d (0x%03x) at "
if (qemu_log_separate()) { TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4);
qemu_log("Trying to read invalid spr %d (0x%03x) at "
TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4);
}
/* The behaviour depends on MSR:PR and SPR# bit 0x10, /* The behaviour depends on MSR:PR and SPR# bit 0x10,
* it can generate a priv, a hv emu or a no-op * it can generate a priv, a hv emu or a no-op
@ -4097,12 +4090,9 @@ static void gen_mtspr(DisasContext *ctx)
(*write_cb)(ctx, sprn, rS(ctx->opcode)); (*write_cb)(ctx, sprn, rS(ctx->opcode));
} else { } else {
/* Privilege exception */ /* Privilege exception */
fprintf(stderr, "Trying to write privileged spr %d (0x%03x) at " qemu_log_mask(LOG_GUEST_ERROR, "Trying to write privileged spr "
TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4); "%d (0x%03x) at " TARGET_FMT_lx "\n", sprn, sprn,
if (qemu_log_separate()) { ctx->base.pc_next - 4);
qemu_log("Trying to write privileged spr %d (0x%03x) at "
TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4);
}
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG); gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG);
} }
} else { } else {
@ -4114,12 +4104,9 @@ static void gen_mtspr(DisasContext *ctx)
} }
/* Not defined */ /* Not defined */
if (qemu_log_separate()) { qemu_log_mask(LOG_GUEST_ERROR,
qemu_log("Trying to write invalid spr %d (0x%03x) at " "Trying to write invalid spr %d (0x%03x) at "
TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4); TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4);
}
fprintf(stderr, "Trying to write invalid spr %d (0x%03x) at "
TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - 4);
/* The behaviour depends on MSR:PR and SPR# bit 0x10, /* The behaviour depends on MSR:PR and SPR# bit 0x10,