qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bahadir Balban <bbalban@b-labs.co.uk>
To: qemu-devel@nongnu.org
Cc: Bahadir Balban <bbalban@b-labs.co.uk>
Subject: [Qemu-devel] [PATCH 2/2] [RFC] ARMv7: Support for simplified access permissions checking
Date: Mon, 25 Jan 2010 09:38:48 +0200	[thread overview]
Message-ID: <1264405128-2332-2-git-send-email-bbalban@b-labs.co.uk> (raw)
In-Reply-To: <1264405128-2332-1-git-send-email-bbalban@b-labs.co.uk>

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 <bbalban@b-labs.co.uk>
---
 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

  reply	other threads:[~2010-01-25  7:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-25  7:38 [Qemu-devel] [PATCH 1/2] [RFC] ARMv7: Enable hardware management of access flags Bahadir Balban
2010-01-25  7:38 ` Bahadir Balban [this message]
2010-03-01 14:40   ` [Qemu-devel] [PATCH 2/2] [RFC] ARMv7: Support for simplified access permissions checking Paul Brook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1264405128-2332-2-git-send-email-bbalban@b-labs.co.uk \
    --to=bbalban@b-labs.co.uk \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).