From patchwork Tue Jan 13 15:48:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 428480 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 59C5914012F for ; Wed, 14 Jan 2015 02:48:56 +1100 (AEDT) Received: from localhost ([::1]:39916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB3iA-0004st-LM for incoming@patchwork.ozlabs.org; Tue, 13 Jan 2015 10:48:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB3hh-00044o-UX for qemu-devel@nongnu.org; Tue, 13 Jan 2015 10:48:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YB3hd-0003gK-4Y for qemu-devel@nongnu.org; Tue, 13 Jan 2015 10:48:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB3hc-0003fS-Sv for qemu-devel@nongnu.org; Tue, 13 Jan 2015 10:48:21 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0DFmItK025162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 Jan 2015 10:48:18 -0500 Received: from hawk.usersys.redhat.com ([10.34.1.145]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0DFmF4v007600; Tue, 13 Jan 2015 10:48:17 -0500 From: Andrew Jones To: qemu-devel@nongnu.org Date: Tue, 13 Jan 2015 16:48:10 +0100 Message-Id: <1421164091-19989-2-git-send-email-drjones@redhat.com> In-Reply-To: <1421164091-19989-1-git-send-email-drjones@redhat.com> References: <1421164091-19989-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 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 1/2] tcg-aarch64: user doesn't need R/W access to exec 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 Table D4-32 shows that execute access from EL0 doesn't depend on AP[1]. Signed-off-by: Andrew Jones --- target-arm/helper.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index 3ef0f1f38eda5..7c30a2669a0f2 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -4787,7 +4787,7 @@ static int get_phys_addr_lpae(CPUARMState *env, target_ulong address, hwaddr descaddr, descmask; uint32_t tableattrs; target_ulong page_size; - uint32_t attrs; + uint32_t attrs, ap; int32_t granule_sz = 9; int32_t va_size = 32; int32_t tbi = 0; @@ -4952,14 +4952,20 @@ static int get_phys_addr_lpae(CPUARMState *env, target_ulong address, /* Access flag */ goto do_fault; } + fault_type = permission_fault; - if (is_user && !(attrs & (1 << 4))) { - /* Unprivileged access not enabled */ - goto do_fault; + ap = extract32(attrs, 4, 2); /* AP[2:1] */ + + *prot = 0; + if (!is_user || (ap & 1)) { + *prot |= PAGE_READ; + *prot |= !(ap & 2) ? PAGE_WRITE : 0; } - *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; + + *prot |= PAGE_EXEC; if ((arm_feature(env, ARM_FEATURE_V8) && is_user && (attrs & (1 << 12))) || (!arm_feature(env, ARM_FEATURE_V8) && (attrs & (1 << 12))) || + (!arm_el_is_aa64(env, 1) && is_user && !(ap & 1)) || (!is_user && (attrs & (1 << 11)))) { /* XN/UXN or PXN. Since we only implement EL0/EL1 we unconditionally * treat XN/UXN as UXN for v8. @@ -4969,12 +4975,11 @@ static int get_phys_addr_lpae(CPUARMState *env, target_ulong address, } *prot &= ~PAGE_EXEC; } - if (attrs & (1 << 5)) { - /* Write access forbidden */ - if (access_type == 1) { - goto do_fault; - } - *prot &= ~PAGE_WRITE; + + if ((*prot == 0) + || (!(*prot & PAGE_WRITE) && access_type == 1) + || (!(*prot & PAGE_EXEC) && access_type == 2)) { + goto do_fault; } *phys_ptr = descaddr;