qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] sh7750: Fix crash when accessing PVR/PRR/CVR
@ 2013-03-26 12:20 Peter Maydell
  2013-03-26 14:35 ` Andreas Färber
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2013-03-26 12:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andreas Färber, patches

Commit b350ab75 causes segfaults on accesses to PVR/PRR/CVR because
it tries to call SUPERH_CPU_GET_CLASS() on a pointer that isn't a
QOM object. Fix this by getting the actual QOM CPU object first.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Tested with the r2d image/instructions from
https://oss.renesas.com/modules/document/?Getting%20Started%20with%20SH4%20and%20QEMU

 hw/sh4/sh7750.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/sh4/sh7750.c b/hw/sh4/sh7750.c
index e4d37ad..3580c87 100644
--- a/hw/sh4/sh7750.c
+++ b/hw/sh4/sh7750.c
@@ -289,13 +289,13 @@ static uint32_t sh7750_mem_readl(void *opaque, hwaddr addr)
     case SH7750_CCR_A7:
 	return s->ccr;
     case 0x1f000030:		/* Processor version */
-        scc = SUPERH_CPU_GET_CLASS(s->cpu);
+        scc = SUPERH_CPU_GET_CLASS(ENV_GET_CPU(s->cpu));
         return scc->pvr;
     case 0x1f000040:		/* Cache version */
-        scc = SUPERH_CPU_GET_CLASS(s->cpu);
+        scc = SUPERH_CPU_GET_CLASS(ENV_GET_CPU(s->cpu));
         return scc->cvr;
     case 0x1f000044:		/* Processor revision */
-        scc = SUPERH_CPU_GET_CLASS(s->cpu);
+        scc = SUPERH_CPU_GET_CLASS(ENV_GET_CPU(s->cpu));
         return scc->prr;
     default:
 	error_access("long read", addr);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-09 14:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-26 12:20 [Qemu-devel] [PATCH] sh7750: Fix crash when accessing PVR/PRR/CVR Peter Maydell
2013-03-26 14:35 ` Andreas Färber
2013-03-26 14:44   ` Peter Maydell
2013-04-08 12:52   ` Peter Maydell
2013-04-09 14:52     ` Andreas Färber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).