From patchwork Thu Feb 12 15:05:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 439232 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 492F1140129 for ; Fri, 13 Feb 2015 02:06:27 +1100 (AEDT) Received: from localhost ([::1]:50627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLvLV-0003uB-C1 for incoming@patchwork.ozlabs.org; Thu, 12 Feb 2015 10:06:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLvKc-0002jv-FI for qemu-devel@nongnu.org; Thu, 12 Feb 2015 10:05:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLvKU-0006cL-G2 for qemu-devel@nongnu.org; Thu, 12 Feb 2015 10:05:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLvKU-0006by-7N for qemu-devel@nongnu.org; Thu, 12 Feb 2015 10:05:22 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1CF5ITY029482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 12 Feb 2015 10:05:19 -0500 Received: from hawk.usersys.redhat.com ([10.34.1.145]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1CF5BVQ019602; Thu, 12 Feb 2015 10:05:17 -0500 From: Andrew Jones To: qemu-devel@nongnu.org Date: Thu, 12 Feb 2015 16:05:05 +0100 Message-Id: <1423753507-30542-4-git-send-email-drjones@redhat.com> In-Reply-To: <1423753507-30542-1-git-send-email-drjones@redhat.com> References: <1423753507-30542-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH 3/5] target-arm: add an is_user param to get_rw_prot 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Give callers the ability to get page protection flags for PL0, even if not currently operating in PL0. This puts the burden of determining 'is_user' on the caller (again - it was this way before regime_is_user was introduced), but will be useful in a following patch. Signed-off-by: Andrew Jones --- target-arm/helper.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index b63ec7b7979f9..df78f481e92f4 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -4696,12 +4696,11 @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) * R/W protection flags */ static inline int get_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, - int ap, int domain_prot) + bool is_user, int ap, int domain_prot) { bool simple_ap = regime_using_lpae_format(env, mmu_idx) || (regime_sctlr(env, mmu_idx) & SCTLR_AFE); bool domain_prot_valid = !regime_using_lpae_format(env, mmu_idx); - bool is_user = regime_is_user(env, mmu_idx); if (domain_prot_valid && domain_prot == 3) { return PAGE_READ | PAGE_WRITE; @@ -4881,7 +4880,8 @@ static int get_phys_addr_v5(CPUARMState *env, uint32_t address, int access_type, } code = 15; } - *prot = get_rw_prot(env, mmu_idx, ap, domain_prot); + *prot = get_rw_prot(env, mmu_idx, regime_is_user(env, mmu_idx), + ap, domain_prot); *prot |= *prot ? PAGE_EXEC : 0; if (!(*prot & (1 << access_type))) { /* Access permission fault. */ @@ -4989,7 +4989,9 @@ static int get_phys_addr_v6(CPUARMState *env, uint32_t address, int access_type, if (domain_prot == 3) { *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; } else { - if (pxn && !regime_is_user(env, mmu_idx)) { + bool is_user = regime_is_user(env, mmu_idx); + + if (pxn && !is_user) { xn = 1; } if (xn && access_type == 2) @@ -5002,7 +5004,7 @@ static int get_phys_addr_v6(CPUARMState *env, uint32_t address, int access_type, code = (code == 15) ? 6 : 3; goto do_fault; } - *prot = get_rw_prot(env, mmu_idx, ap, domain_prot); + *prot = get_rw_prot(env, mmu_idx, is_user, ap, domain_prot); *prot |= *prot && !xn ? PAGE_EXEC : 0; if (!(*prot & (1 << access_type))) { /* Access permission fault. */