From patchwork Fri Mar 27 19:10:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 46442 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5162621597 for ; Fri, 27 Mar 2015 19:15:06 +0000 (UTC) Received: by lbbzl9 with SMTP id zl9sf12620143lbb.2 for ; Fri, 27 Mar 2015 12:15:05 -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=MkatXw9T62DmMvbVRT3qOlaBzxfG7uRVDADObC0QCM0=; b=VtMnpUZ4yiEmR7evorpX1MJaFTMSlF/ItFDS9WkUBaaEm/mJOn3cOsy9jgR8h9Abqj pcbdvA2onNhtA6F62Xexsl9Lv8MlH/U/+WA75C3nXAcC+DRkNechdutxS6ro0nJLtZd8 c12yySe4ahKaWWX3SrS+xsq8FECd12nxjLNE3wQO98O/hl8QqQdI8VblfnKz5SjDA8VY KEXTBdhURx9Ekdcniel89yk9GG53S1G18yj7mXbdDtOahHp+OtJnEyxGYs//XuC/fNnJ 7RMydQTs3yqWXevtvzI6KAozh1Jax7oml3MVIQRehSYU+2vCmIW/7k9e6nkZyhcz+G0h R2hQ== X-Gm-Message-State: ALoCoQmDchW3eydDMI15OhlCQUsb6lZED3LWotJGp4tZjQSQ1KY10t4nApq7s2z0xrn+B+joeomB X-Received: by 10.112.170.38 with SMTP id aj6mr4828483lbc.4.1427483705271; Fri, 27 Mar 2015 12:15:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.7 with SMTP id w7ls389386law.96.gmail; Fri, 27 Mar 2015 12:15:05 -0700 (PDT) X-Received: by 10.112.26.43 with SMTP id i11mr18821815lbg.83.1427483705127; Fri, 27 Mar 2015 12:15:05 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id q11si1958198lbl.110.2015.03.27.12.15.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2015 12:15:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbug6 with SMTP id ug6so70520529lbb.3 for ; Fri, 27 Mar 2015 12:15:05 -0700 (PDT) X-Received: by 10.112.235.227 with SMTP id up3mr9508446lbc.86.1427483705035; Fri, 27 Mar 2015 12:15:05 -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.57.201 with SMTP id k9csp66936lbq; Fri, 27 Mar 2015 12:15:04 -0700 (PDT) X-Received: by 10.141.28.197 with SMTP id f188mr26752355qhe.103.1427483703715; Fri, 27 Mar 2015 12:15:03 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u194si2774140qhd.72.2015.03.27.12.15.03 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 27 Mar 2015 12:15:03 -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]:51446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbZig-0006bJ-DH for patch@linaro.org; Fri, 27 Mar 2015 15:15:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbZfH-0001i1-Kh for qemu-devel@nongnu.org; Fri, 27 Mar 2015 15:12:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YbZex-0005Cq-9B for qemu-devel@nongnu.org; Fri, 27 Mar 2015 15:11:31 -0400 Received: from mail-ob0-f175.google.com ([209.85.214.175]:34953) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbZex-0005CK-3w for qemu-devel@nongnu.org; Fri, 27 Mar 2015 15:11:11 -0400 Received: by obcjt1 with SMTP id jt1so78763306obc.2 for ; Fri, 27 Mar 2015 12:11:10 -0700 (PDT) X-Received: by 10.202.57.195 with SMTP id g186mr16624404oia.86.1427483470796; Fri, 27 Mar 2015 12:11:10 -0700 (PDT) Received: from gbellows-linaro.bellowshome.netattlocal.net (99-179-1-128.lightspeed.austtx.sbcglobal.net. [99.179.1.128]) by mx.google.com with ESMTPSA id hc7sm1490859obb.16.2015.03.27.12.11.08 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Mar 2015 12:11:09 -0700 (PDT) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, alex.bennee@linaro.org Date: Fri, 27 Mar 2015 14:10:44 -0500 Message-Id: <1427483446-31900-6-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1427483446-31900-1-git-send-email-greg.bellows@linaro.org> References: <1427483446-31900-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.214.175 Cc: Greg Bellows Subject: [Qemu-devel] [[PATCH] 5/7] 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.217.177 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 | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index 00b457a..13fdf02 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -4892,6 +4892,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) @@ -5090,7 +5105,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) { @@ -5098,13 +5112,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; @@ -5376,20 +5390,26 @@ static int get_phys_addr_lpae(CPUARMState *env, target_ulong address, int32_t tbi = 0; TCR *tcr = regime_tcr(env, mmu_idx); int ap, ns, xn, pxn; + uint32_t el = regime_el(env, mmu_idx); /* TODO: * This code assumes we're either a 64-bit EL1 or a 32-bit PL1; - * it doesn't handle the different format TCR for TCR_EL2, TCR_EL3, - * and VTCR_EL2, or the fact that those regimes don't have a split + * it doesn't handle the different format TCR for and VTCR_EL2, + * or the fact that those regimes don't have a split * TTBR0/TTBR1. Attribute and permission bit handling should also * be checked when adding support for those page table walks. */ - if (arm_el_is_aa64(env, regime_el(env, mmu_idx))) { + if (arm_el_is_aa64(env, el)) { va_size = 64; - if (extract64(address, 55, 1)) - tbi = extract64(tcr->raw_tcr, 38, 1); - else - tbi = extract64(tcr->raw_tcr, 37, 1); + if (el == 3 || el == 2) { + tbi = extract64(tcr->raw_tcr, 20, 1); + } else { + if (extract64(address, 55, 1)) { + tbi = extract64(tcr->raw_tcr, 38, 1); + } else { + tbi = extract64(tcr->raw_tcr, 37, 1); + } + } tbi *= 8; } @@ -5434,7 +5454,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; @@ -5446,7 +5466,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;