[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 27/30] target/ppc: check tb_env != 0 before printing TBU/TBL/DECR
From: |
Daniel Henrique Barboza |
Subject: |
[PULL 27/30] target/ppc: check tb_env != 0 before printing TBU/TBL/DECR |
Date: |
Mon, 18 Jul 2022 14:22:05 -0300 |
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
When using "-machine none", env->tb_env is not allocated, causing the
segmentation fault reported in issue #85 (launchpad bug #811683). To
avoid this problem, check if the pointer != NULL before calling the
methods to print TBU/TBL/DECR.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/85
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20220714172343.80539-1-matheus.ferst@eldorado.org.br>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
target/ppc/cpu_init.c | 18 ++++++++----------
target/ppc/monitor.c | 9 +++++++++
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index 4f2355e941..d1493a660c 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -7471,17 +7471,15 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, int
flags)
"%08x iidx %d didx %d\n",
env->msr, env->spr[SPR_HID0], env->hflags,
cpu_mmu_index(env, true), cpu_mmu_index(env, false));
-#if !defined(NO_TIMER_DUMP)
- qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
#if !defined(CONFIG_USER_ONLY)
- " DECR " TARGET_FMT_lu
-#endif
- "\n",
- cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
-#if !defined(CONFIG_USER_ONLY)
- , cpu_ppc_load_decr(env)
-#endif
- );
+ if (env->tb_env) {
+ qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
+ " DECR " TARGET_FMT_lu "\n", cpu_ppc_load_tbu(env),
+ cpu_ppc_load_tbl(env), cpu_ppc_load_decr(env));
+ }
+#else
+ qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 "\n", cpu_ppc_load_tbu(env),
+ cpu_ppc_load_tbl(env));
#endif
for (i = 0; i < 32; i++) {
if ((i & (RGPL - 1)) == 0) {
diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c
index 0b805ef6e9..8250b1304e 100644
--- a/target/ppc/monitor.c
+++ b/target/ppc/monitor.c
@@ -55,6 +55,9 @@ static target_long monitor_get_decr(Monitor *mon, const
struct MonitorDef *md,
int val)
{
CPUArchState *env = mon_get_cpu_env(mon);
+ if (!env->tb_env) {
+ return 0;
+ }
return cpu_ppc_load_decr(env);
}
@@ -62,6 +65,9 @@ static target_long monitor_get_tbu(Monitor *mon, const struct
MonitorDef *md,
int val)
{
CPUArchState *env = mon_get_cpu_env(mon);
+ if (!env->tb_env) {
+ return 0;
+ }
return cpu_ppc_load_tbu(env);
}
@@ -69,6 +75,9 @@ static target_long monitor_get_tbl(Monitor *mon, const struct
MonitorDef *md,
int val)
{
CPUArchState *env = mon_get_cpu_env(mon);
+ if (!env->tb_env) {
+ return 0;
+ }
return cpu_ppc_load_tbl(env);
}
--
2.36.1
- [PULL 16/30] target/ppc: receive DisasContext explicitly in GEN_PRIV, (continued)
- [PULL 16/30] target/ppc: receive DisasContext explicitly in GEN_PRIV, Daniel Henrique Barboza, 2022/07/18
- [PULL 14/30] target/ppc: Move tlbie[l] to decode tree, Daniel Henrique Barboza, 2022/07/18
- [PULL 20/30] target/ppc: Move slbia to decodetree, Daniel Henrique Barboza, 2022/07/18
- [PULL 17/30] target/ppc: add macros to check privilege level, Daniel Henrique Barboza, 2022/07/18
- [PULL 21/30] target/ppc: Move slbmte to decodetree, Daniel Henrique Barboza, 2022/07/18
- [PULL 24/30] target/ppc: Move slbfee to decodetree, Daniel Henrique Barboza, 2022/07/18
- [PULL 19/30] target/ppc: Move slbieg to decodetree, Daniel Henrique Barboza, 2022/07/18
- [PULL 18/30] target/ppc: Move slbie to decodetree, Daniel Henrique Barboza, 2022/07/18
- [PULL 29/30] target/ppc: Improve Radix xlate level validation, Daniel Henrique Barboza, 2022/07/18
- [PULL 23/30] target/ppc: Move slbmfee to decodetree, Daniel Henrique Barboza, 2022/07/18
- [PULL 27/30] target/ppc: check tb_env != 0 before printing TBU/TBL/DECR,
Daniel Henrique Barboza <=
- [PULL 22/30] target/ppc: Move slbmfev to decodetree, Daniel Henrique Barboza, 2022/07/18
- [PULL 26/30] target/ppc: Implement slbiag, Daniel Henrique Barboza, 2022/07/18
- [PULL 25/30] target/ppc: Move slbsync to decodetree, Daniel Henrique Barboza, 2022/07/18
- [PULL 30/30] target/ppc: Check page dir/table base alignment, Daniel Henrique Barboza, 2022/07/18
- [PULL 28/30] ppc: Check partition and process table alignment, Daniel Henrique Barboza, 2022/07/18
- Re: [PULL 00/30] ppc queue, Peter Maydell, 2022/07/19