From patchwork Wed Apr 22 17:09:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 47425 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C93B52121F for ; Wed, 22 Apr 2015 17:13:32 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf53445256lbb.0 for ; Wed, 22 Apr 2015 10:13:31 -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=a6UzWetasP3XaQqRt8FHXQc9yGsS5rIoPvnGyqRgQoA=; b=eWeLDKDtPsVdt8ELTx62fLWjdetkxLgP1gZlNTyF5io4XNG9GLe2CFGaQerFp0tJ58 mFRVFiY+4UA1HrzuaDQtDmivchQEjtEdHHweKIyYfP8j/v9zPx95RkbowLm7uA0/Ob0k pBlWxXLbYdPqe2OZ2CmDUyRO1DLgjo02pJZmItiiCaChefFvET7Md7+8539fp0BiQgCa 5Z3JNIrS0INUrBXuO5lRX6xFs1qCPU1NVKbAiXcedTIdSdu3SNxK5MmMp1eFBilN9GOH WN/KwSWuYgOxCo3AQlBHPRCu6KDyTiNzNqu2cfE46yMpAOC5eZ1h8IZyoYglgHbL0acv qffQ== X-Gm-Message-State: ALoCoQlPqlakEFC6JyacF1IEDxmfSpVCa6xvYrgFDmVtDBZb4V2uCgmlekublAAfHEjK/1+r0kM8 X-Received: by 10.194.236.230 with SMTP id ux6mr12071419wjc.5.1429722811682; Wed, 22 Apr 2015 10:13:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.30.37 with SMTP id p5ls228829lah.9.gmail; Wed, 22 Apr 2015 10:13:31 -0700 (PDT) X-Received: by 10.152.115.173 with SMTP id jp13mr25200644lab.119.1429722811527; Wed, 22 Apr 2015 10:13:31 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id dy7si4155150lbc.63.2015.04.22.10.13.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 10:13:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by layy10 with SMTP id y10so180039886lay.0 for ; Wed, 22 Apr 2015 10:13:31 -0700 (PDT) X-Received: by 10.152.5.72 with SMTP id q8mr25247206laq.73.1429722811429; Wed, 22 Apr 2015 10:13:31 -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.112.67.65 with SMTP id l1csp69459lbt; Wed, 22 Apr 2015 10:13:30 -0700 (PDT) X-Received: by 10.140.192.73 with SMTP id n70mr31596972qha.91.1429722809460; Wed, 22 Apr 2015 10:13:29 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 133si5643240qhx.1.2015.04.22.10.13.28 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 22 Apr 2015 10:13:29 -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]:36250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkyDI-0004lW-8P for patch@linaro.org; Wed, 22 Apr 2015 13:13:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yky9k-0007LL-1P for qemu-devel@nongnu.org; Wed, 22 Apr 2015 13:09:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yky9f-0004ro-Uy for qemu-devel@nongnu.org; Wed, 22 Apr 2015 13:09:47 -0400 Received: from mail-oi0-f52.google.com ([209.85.218.52]:36673) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yky9f-0004rY-RT for qemu-devel@nongnu.org; Wed, 22 Apr 2015 13:09:43 -0400 Received: by oift201 with SMTP id t201so186214964oif.3 for ; Wed, 22 Apr 2015 10:09:43 -0700 (PDT) X-Received: by 10.182.87.36 with SMTP id u4mr1070103obz.50.1429722583528; Wed, 22 Apr 2015 10:09:43 -0700 (PDT) Received: from gbellows-linaro.gateway.pace.com (99-179-1-214.lightspeed.austtx.sbcglobal.net. [99.179.1.214]) by mx.google.com with ESMTPSA id w72sm3417636oie.28.2015.04.22.10.09.41 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Apr 2015 10:09:42 -0700 (PDT) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, alex.bennee@linaro.org Date: Wed, 22 Apr 2015 12:09:18 -0500 Message-Id: <1429722561-12651-7-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1429722561-12651-1-git-send-email-greg.bellows@linaro.org> References: <1429722561-12651-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.218.52 Cc: serge.fdrv@gmail.com, Greg Bellows Subject: [Qemu-devel] [PATCH v2 6/9] target-arm: Add TTBR regime function and use 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.215.45 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 Add a utility function for choosing the correct TTBR system register based on the specified MMU index. Add use of function on physical address lookup. Signed-off-by: Greg Bellows --- target-arm/helper.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index e36c3d4..69a5891 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -4899,6 +4899,21 @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx) return &env->cp15.tcr_el[regime_el(env, mmu_idx)]; } +/* Return the TTBR associated with this translation regime */ +static inline uint32_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, + int ttbrn) +{ + if (mmu_idx == ARMMMUIdx_S2NS) { + /* TODO: return VTTBR_EL2 */ + g_assert_not_reached(); + } + if (ttbrn == 0) { + return env->cp15.ttbr0_el[regime_el(env, mmu_idx)]; + } else { + return env->cp15.ttbr1_el[regime_el(env, mmu_idx)]; + } +} + /* Return true if the translation regime is using LPAE format page tables */ static inline bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) @@ -5097,7 +5112,6 @@ static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, uint32_t *table, uint32_t address) { /* Note that we can only get here for an AArch32 PL0/PL1 lookup */ - int el = regime_el(env, mmu_idx); TCR *tcr = regime_tcr(env, mmu_idx); if (address & tcr->mask) { @@ -5105,13 +5119,13 @@ static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, /* Translation table walk disabled for TTBR1 */ return false; } - *table = env->cp15.ttbr1_el[el] & 0xffffc000; + *table = regime_ttbr(env, mmu_idx, 1) & 0xffffc000; } else { if (tcr->raw_tcr & TTBCR_PD0) { /* Translation table walk disabled for TTBR0 */ return false; } - *table = env->cp15.ttbr0_el[el] & tcr->base_mask; + *table = regime_ttbr(env, mmu_idx, 0) & tcr->base_mask; } *table |= (address >> 18) & 0x3ffc; return true; @@ -5441,7 +5455,7 @@ static int get_phys_addr_lpae(CPUARMState *env, target_ulong address, * we will always flush the TLB any time the ASID is changed). */ if (ttbr_select == 0) { - ttbr = A32_BANKED_CURRENT_REG_GET(env, ttbr0); + ttbr = regime_ttbr(env, mmu_idx, 0); epd = extract32(tcr->raw_tcr, 7, 1); tsz = t0sz; @@ -5453,7 +5467,7 @@ static int get_phys_addr_lpae(CPUARMState *env, target_ulong address, granule_sz = 11; } } else { - ttbr = A32_BANKED_CURRENT_REG_GET(env, ttbr1); + ttbr = regime_ttbr(env, mmu_idx, 1); epd = extract32(tcr->raw_tcr, 23, 1); tsz = t1sz;