From patchwork Tue Mar 26 12:20:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 15666 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5463623DEE for ; Tue, 26 Mar 2013 12:20:06 +0000 (UTC) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by fiordland.canonical.com (Postfix) with ESMTP id 0E7DBA19939 for ; Tue, 26 Mar 2013 12:20:05 +0000 (UTC) Received: by mail-vc0-f174.google.com with SMTP id hx10so5373814vcb.19 for ; Tue, 26 Mar 2013 05:20:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=g7Lj6lNqX+5RhDaNQuBX26D/wjGn5vpmjpjVw3GO6gc=; b=bgPHFFDIhB2mitJm9O3xrHzk8YrDSQZoGlWdROrqoE4lu5KRDrtxMH0KA50B2WORGP XHwB1WX4Ovbdm1u1mEUgkwwN6sJHH0T5red2h1GCrGTvuIt/jFXCvc6mlE2nZIJ00RBi gIghuMFhyhB4Ho/NguSTqZyT4xcqlzZArMYUq87STAJzUT3SVxl9BXHIFliSvHikOj1q g390AKS1SrYeLDBRcgA2yvjxCo4ey/XrnIK47hLsb1RyOrwE98Yu6DyDvVB4ajwLGHTa wnjhuapaGj4/x0oLDhVvXyVJsuXHsIcvC9w30sOVNLk91REVZ+TgRm5PUkNloTPFRNPl RYZQ== X-Received: by 10.220.150.74 with SMTP id x10mr19306827vcv.68.1364300405583; Tue, 26 Mar 2013 05:20:05 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp68564ved; Tue, 26 Mar 2013 05:20:04 -0700 (PDT) X-Received: by 10.180.72.165 with SMTP id e5mr2826105wiv.7.1364300404338; Tue, 26 Mar 2013 05:20:04 -0700 (PDT) Received: from mnementh.archaic.org.uk (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]) by mx.google.com with ESMTPS id jc12si681267wic.126.2013.03.26.05.20.03 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 26 Mar 2013 05:20:04 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UKSrB-0002R5-WD; Tue, 26 Mar 2013 12:20:02 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , Magnus Damm Subject: [PATCH] sh7750: Fix crash when accessing PVR/PRR/CVR Date: Tue, 26 Mar 2013 12:20:01 +0000 Message-Id: <1364300401-9340-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-Gm-Message-State: ALoCoQncUOO1AE1827cfGqlkR95XAUwzUcIPhJxInAx+atzwbGEiibEDuNJPtBmyOojSFPiPwB3z 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);