qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: patches@linaro.org
Subject: [Qemu-devel] [PATCH for-2.10 2/5] target/arm: Don't allow guest to make System space executable for M profile
Date: Thu, 27 Jul 2017 11:59:07 +0100	[thread overview]
Message-ID: <1501153150-19984-3-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1501153150-19984-1-git-send-email-peter.maydell@linaro.org>

For an M profile v7PMSA, the system space (0xe0000000 - 0xffffffff) can
never be executable, even if the guest tries to set the MPU registers
up that way. Enforce this restriction.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target/arm/helper.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/target/arm/helper.c b/target/arm/helper.c
index ceef225..169c361 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -8251,6 +8251,14 @@ static inline bool is_ppb_region(CPUARMState *env, uint32_t address)
         extract32(address, 20, 12) == 0xe00;
 }
 
+static inline bool is_system_region(CPUARMState *env, uint32_t address)
+{
+    /* True if address is in the M profile system region
+     * 0xe0000000 - 0xffffffff
+     */
+    return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) == 0x7;
+}
+
 static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
                                  int access_type, ARMMMUIdx mmu_idx,
                                  hwaddr *phys_ptr, int *prot, uint32_t *fsr)
@@ -8354,6 +8362,12 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
             get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
         } else { /* a MPU hit! */
             uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3);
+            uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1);
+
+            if (is_system_region(env, address)) {
+                /* System space is always execute never */
+                xn = 1;
+            }
 
             if (is_user) { /* User mode AP bit decoding */
                 switch (ap) {
@@ -8394,7 +8408,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
             }
 
             /* execute never */
-            if (env->pmsav7.dracr[n] & (1 << 12)) {
+            if (xn) {
                 *prot &= ~PAGE_EXEC;
             }
         }
-- 
2.7.4

  parent reply	other threads:[~2017-07-27 10:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27 10:59 [Qemu-devel] [PATCH for-2.10 0/5] M profile MPU bugfixes Peter Maydell
2017-07-27 10:59 ` [Qemu-devel] [PATCH for-2.10 1/5] target/arm: Don't do MPU lookups for addresses in M profile PPB region Peter Maydell
2017-07-27 23:32   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-07-27 10:59 ` Peter Maydell [this message]
2017-07-27 23:59   ` [Qemu-devel] [Qemu-arm] [PATCH for-2.10 2/5] target/arm: Don't allow guest to make System space executable for M profile Philippe Mathieu-Daudé
2017-07-28  8:51     ` Peter Maydell
2017-07-28 17:01       ` Philippe Mathieu-Daudé
2017-07-27 10:59 ` [Qemu-devel] [PATCH for-2.10 3/5] target/arm: Rename cp15.c6_rgnr to pmsav7.rnr Peter Maydell
2017-07-27 22:43   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-07-27 22:58     ` Philippe Mathieu-Daudé
2017-07-28  8:42       ` Peter Maydell
2017-07-28 17:03         ` Philippe Mathieu-Daudé
2017-07-27 10:59 ` [Qemu-devel] [PATCH for-2.10 4/5] target/arm: Move PMSAv7 reset into arm_cpu_reset() so M profile MPUs get reset Peter Maydell
2017-07-28  0:02   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-07-27 10:59 ` [Qemu-devel] [PATCH for-2.10 5/5] target/arm: Migrate MPU_RNR register state for M profile cores Peter Maydell
2017-07-27 22:50   ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-07-31 12:11 ` [Qemu-devel] [Qemu-arm] [PATCH for-2.10 0/5] M profile MPU bugfixes Peter Maydell

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=1501153150-19984-3-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=patches@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --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).