From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZJXP-0006Ll-61 for qemu-devel@nongnu.org; Mon, 25 Jan 2010 02:39:07 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZJXJ-0006L3-0k for qemu-devel@nongnu.org; Mon, 25 Jan 2010 02:39:05 -0500 Received: from [199.232.76.173] (port=35168 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZJXI-0006Kt-OQ for qemu-devel@nongnu.org; Mon, 25 Jan 2010 02:39:00 -0500 Received: from 17.254.223.67.in-addr.arpa ([67.223.254.17]:50875 helo=l4dev.org) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZJXI-00039h-8f for qemu-devel@nongnu.org; Mon, 25 Jan 2010 02:39:00 -0500 From: Bahadir Balban Date: Mon, 25 Jan 2010 09:38:48 +0200 Message-Id: <1264405128-2332-2-git-send-email-bbalban@b-labs.co.uk> In-Reply-To: <1264405128-2332-1-git-send-email-bbalban@b-labs.co.uk> References: <1264405128-2332-1-git-send-email-bbalban@b-labs.co.uk> Subject: [Qemu-devel] [PATCH 2/2] [RFC] ARMv7: Support for simplified access permissions checking List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Bahadir Balban ARMv7 has a simplified access permissions model that is enabled by setting the AFE bit of the SCTLR. This patch adds checking for permission values for when this mode is selected. Signed-off-by: Bahadir Balban --- target-arm/helper.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 48 insertions(+), 2 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index 334832d..732d142 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -837,11 +837,48 @@ void do_interrupt(CPUARMState *env) env->interrupt_request |= CPU_INTERRUPT_EXITTB; } + +/* + * Simplified access permissions: + * AP[2:1] has below meanings: + * User/None Kern/RW 0 + * User/RW Kern/RW 1 + * User/None Kern/RO 2 + * User/RO Kern/RO 3 + */ +#define AP_SIMPLE_USER_NONE_KERN_RW 0 +#define AP_SIMPLE_USER_RW_KERN_RW 1 +#define AP_SIMPLE_USER_NONE_KERN_RO 2 +#define AP_SIMPLE_USER_RO_KERN_RO 3 + +static int check_ap_simplified(CPUState *env, int ap, int domain, + int access_type, int is_user) +{ + switch(ap) { + case AP_SIMPLE_USER_NONE_KERN_RW: + if (is_user) + return 0; + else + return PAGE_READ | PAGE_WRITE; + case AP_SIMPLE_USER_RW_KERN_RW: + return PAGE_READ | PAGE_WRITE; + case AP_SIMPLE_USER_NONE_KERN_RO: + if (is_user) + return 0; + else + return PAGE_READ; + case AP_SIMPLE_USER_RO_KERN_RO: + return PAGE_READ; + default: + return 0; + } +} + /* Check section/page access permissions. Returns the page protection flags, or zero if the access is not permitted. */ -static inline int check_ap(CPUState *env, int ap, int domain, int access_type, - int is_user) +static inline int check_ap_normal(CPUState *env, int ap, int domain, + int access_type, int is_user) { int prot_ro; @@ -889,6 +926,15 @@ static inline int check_ap(CPUState *env, int ap, int domain, int access_type, } } +static inline int check_ap(CPUState *env, int ap, int domain, + int access_type, int is_user) +{ + if (env->cp15.c1_sys & (1 << 29)) + return check_ap_simplified(env, ap, domain, access_type, is_user); + else + return check_ap_normal(env, ap, domain, access_type, is_user); +} + static uint32_t get_level1_table_address(CPUState *env, uint32_t address) { uint32_t table; -- 1.6.3.3