[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 4/6] openpic: don't crash on a register access without
From: |
Scott Wood |
Subject: |
[Qemu-ppc] [PATCH 4/6] openpic: don't crash on a register access without a CPU context |
Date: |
Thu, 13 Dec 2012 20:12:02 -0600 |
If we access a register via the QEMU memory inspection commands (e.g.
"xp") rather than from guest code, we won't have a CPU context.
Gracefully fail to access the register in that case, rather than
crashing.
Signed-off-by: Scott Wood <address@hidden>
---
hw/openpic.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/hw/openpic.c b/hw/openpic.c
index 8c3f04d..c57a168 100644
--- a/hw/openpic.c
+++ b/hw/openpic.c
@@ -161,7 +161,11 @@ static inline int test_bit(uint32_t *field, int bit)
static int get_current_cpu(void)
{
- return cpu_single_env->cpu_index;
+ if (!cpu_single_env) {
+ return -1;
+ }
+
+ return cpu_single_env->cpu_index;
}
static uint32_t openpic_cpu_read_internal(void *opaque, hwaddr addr,
@@ -797,6 +801,11 @@ static void openpic_cpu_write_internal(void *opaque,
hwaddr addr,
DPRINTF("%s: cpu %d addr " TARGET_FMT_plx " <= %08x\n", __func__, idx,
addr, val);
+
+ if (idx < 0) {
+ return;
+ }
+
if (addr & 0xF)
return;
dst = &opp->dst[idx];
@@ -862,6 +871,11 @@ static uint32_t openpic_cpu_read_internal(void *opaque,
hwaddr addr,
DPRINTF("%s: cpu %d addr " TARGET_FMT_plx "\n", __func__, idx, addr);
retval = 0xFFFFFFFF;
+
+ if (idx < 0) {
+ return retval;
+ }
+
if (addr & 0xF)
return retval;
dst = &opp->dst[idx];
--
1.7.9.5
[Qemu-ppc] [PATCH 5/6] openpic: BRR1 is not a CPU-specific register., Scott Wood, 2012/12/13
[Qemu-ppc] [PATCH 2/6] openpic: remove pcsr (CPU sensitivity register), Scott Wood, 2012/12/13
[Qemu-ppc] [PATCH 6/6] openpic: s/opp->nb_irqs -1/opp->nb_cpus - 1/, Scott Wood, 2012/12/13
[Qemu-ppc] [PATCH 3/6] openpic: support large vectors on FSL mpic, Scott Wood, 2012/12/13