From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKSrH-0002um-9A for qemu-devel@nongnu.org; Tue, 26 Mar 2013 08:20:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKSrE-0004oO-Db for qemu-devel@nongnu.org; Tue, 26 Mar 2013 08:20:07 -0400 Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1d0::1]:33293 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKSrE-0004mS-7m for qemu-devel@nongnu.org; Tue, 26 Mar 2013 08:20:04 -0400 From: Peter Maydell Date: Tue, 26 Mar 2013 12:20:01 +0000 Message-Id: <1364300401-9340-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH] sh7750: Fix crash when accessing PVR/PRR/CVR List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , patches@linaro.org 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 --- 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