From patchwork Mon Jun 30 23:09:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 32812 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0E93F203F4 for ; Mon, 30 Jun 2014 23:23:55 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id id10sf18868039vcb.11 for ; Mon, 30 Jun 2014 16:23:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=TZsPZ1uOILUZDMwLQFbbTEUhjZB59SzGif0EemvnA/k=; b=VJrvmnOLPL6Zvz/ULevpi5yM+nVyOaF2Yi5IWLNJQfjaEgjcgHNlKKzxMA3tDpar9T fp3wi0LiNW6+CgMz9lL/DLhBc1pro5CqoY9JI5IsKlKp7PUwTRGLk4fvtfLSIQm81uOI vlvrdRLwAaXMKyGzwTxiDSzOr1u9tenbKGD1vxhUpECEmHQCDkgKdgX66MWoGAXEhvyK ors8NdOxUHd7IdAIJCzhlChKInxRWKDBgykFi5E4HaxfxQwcMUtyC2whqRdEo/Rbi7Nh DLbdxf+GXmVBfWMMlAti+NUWzE71LCzaPrCo/4XtyKZm00xAiT0vazLx1OHtxv3xC5Is UskA== X-Gm-Message-State: ALoCoQmkcHGvaFihjLSxtuBUAuySscBiT8MbyUouMyJdKcd308lzLZJJhNKqYQfeZPNBdm18nE7Q X-Received: by 10.236.189.68 with SMTP id b44mr1963985yhn.4.1404170635561; Mon, 30 Jun 2014 16:23:55 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.201 with SMTP id z67ls1824423qgd.94.gmail; Mon, 30 Jun 2014 16:23:55 -0700 (PDT) X-Received: by 10.52.252.193 with SMTP id zu1mr34183099vdc.7.1404170635358; Mon, 30 Jun 2014 16:23:55 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id ab3si10723340vec.46.2014.06.30.16.23.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 16:23:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jx11so8825022veb.20 for ; Mon, 30 Jun 2014 16:23:55 -0700 (PDT) X-Received: by 10.52.23.71 with SMTP id k7mr34304791vdf.27.1404170635267; Mon, 30 Jun 2014 16:23:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp175347vcb; Mon, 30 Jun 2014 16:23:54 -0700 (PDT) X-Received: by 10.140.36.43 with SMTP id o40mr35479415qgo.25.1404170634756; Mon, 30 Jun 2014 16:23:54 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id hx1si27015383qcb.25.2014.06.30.16.23.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 30 Jun 2014 16:23:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:37188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1kvS-0001ey-B6 for patch@linaro.org; Mon, 30 Jun 2014 19:23:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1kjA-0006Fi-6i for qemu-devel@nongnu.org; Mon, 30 Jun 2014 19:11:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1kj4-0003XP-Jp for qemu-devel@nongnu.org; Mon, 30 Jun 2014 19:11:12 -0400 Received: from mail-oa0-f50.google.com ([209.85.219.50]:51948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1kj4-0003Wn-EV for qemu-devel@nongnu.org; Mon, 30 Jun 2014 19:11:06 -0400 Received: by mail-oa0-f50.google.com with SMTP id n16so9627915oag.23 for ; Mon, 30 Jun 2014 16:11:06 -0700 (PDT) X-Received: by 10.60.117.39 with SMTP id kb7mr45647829oeb.5.1404169865827; Mon, 30 Jun 2014 16:11:05 -0700 (PDT) Received: from gbellows-linaro.bellowshome.net (99-179-1-128.lightspeed.austtx.sbcglobal.net. [99.179.1.128]) by mx.google.com with ESMTPSA id cu7sm76370192oec.12.2014.06.30.16.11.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 16:11:04 -0700 (PDT) From: greg.bellows@linaro.org To: qemu-devel@nongnu.org Date: Mon, 30 Jun 2014 18:09:20 -0500 Message-Id: <1404169773-20264-21-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1404169773-20264-1-git-send-email-greg.bellows@linaro.org> References: <1404169773-20264-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.219.50 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, Fabian Aggeler , Greg Bellows , serge.fdrv@gmail.com, edgar.iglesias@gmail.com, christoffer.dall@linaro.org Subject: [Qemu-devel] [PATCH v4 20/33] target-arm: arrayfying fieldoffset for banking X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: greg.bellows@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Fabian Aggeler Prepare ARMCPRegInfo to support specifying two fieldoffsets per register definition. This will allow us to keep one register definition for banked registers (different offsets for secure/ non-secure world). Signed-off-by: Fabian Aggeler Signed-off-by: Greg Bellows --- target-arm/cpu.h | 16 +++++++++++++--- target-arm/helper.c | 35 +++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 76fd7f3..7f715d9 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -1102,12 +1102,22 @@ struct ARMCPRegInfo { * fieldoffset is non-zero, the reset value of the register. */ uint64_t resetvalue; - /* Offset of the field in CPUARMState for this register. This is not - * needed if either: + /* Offsets of the fields (secure/non-secure) in CPUARMState for this + * register. The array will be accessed by the ns bit which means the + * secure instance has to be at [0] while the non-secure instance must be + * at [1]. If a register is not banked .fieldoffset can be used, which maps + * to the non-secure bank. + * This is not needed if either: * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs * 2. both readfn and writefn are specified */ - ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */ + union { /* offsetof(CPUARMState, field) */ + struct { + ptrdiff_t fieldoffset_padding; + ptrdiff_t fieldoffset; + }; + ptrdiff_t bank_fieldoffsets[2]; + }; /* Function for making any access checks for this register in addition to * those specified by the 'access' permissions bits. If NULL, no extra * checks required. The access check is performed at runtime, not at diff --git a/target-arm/helper.c b/target-arm/helper.c index 5d011fd..f620dce 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2906,20 +2906,31 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, uint32_t *key = g_new(uint32_t, 1); ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo)); int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0; - if (r->state == ARM_CP_STATE_BOTH && state == ARM_CP_STATE_AA32) { - /* The AArch32 view of a shared register sees the lower 32 bits - * of a 64 bit backing field. It is not migratable as the AArch64 - * view handles that. AArch64 also handles reset. - * We assume it is a cp15 register. - */ - r2->cp = 15; - r2->type |= ARM_CP_NO_MIGRATE; - r2->resetfn = arm_cp_reset_ignore; -#ifdef HOST_WORDS_BIGENDIAN - if (r2->fieldoffset) { - r2->fieldoffset += sizeof(uint32_t); + + if (state == ARM_CP_STATE_AA32) { + if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) { + /* Register is banked (using both entries in array). + * Overwriting fieldoffset as the array was only used to define + * banked registers but later only fieldoffset is used. + */ + r2->fieldoffset = r->bank_fieldoffsets[nsbit]; } + + if (r->state == ARM_CP_STATE_BOTH) { + /* The AArch32 view of a shared register sees the lower 32 bits + * of a 64 bit backing field. It is not migratable as the AArch64 + * view handles that. AArch64 also handles reset. + * We assume it is a cp15 register. + */ + r2->cp = 15; + r2->type |= ARM_CP_NO_MIGRATE; + r2->resetfn = arm_cp_reset_ignore; +#ifdef HOST_WORDS_BIGENDIAN + if (r2->fieldoffset) { + r2->fieldoffset += sizeof(uint32_t); + } #endif + } } if (state == ARM_CP_STATE_AA64) { /* To allow abbreviation of ARMCPRegInfo