summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-08-28 11:00:41 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-08-28 11:00:41 -0600
commit60830c4ae18f882834b39b7fc0d0eeeaf15ba90a (patch)
treecec816082723cb436377a94c2085be0ac1afb059
parent45a3faa0bb81ff7ae6eacf9ef9acbec6d9c764a5 (diff)
downloadnuttx-60830c4ae18f882834b39b7fc0d0eeeaf15ba90a.tar.gz
nuttx-60830c4ae18f882834b39b7fc0d0eeeaf15ba90a.tar.bz2
nuttx-60830c4ae18f882834b39b7fc0d0eeeaf15ba90a.zip
Cortex-A address environments: Fix issue with page privileges
-rw-r--r--nuttx/arch/arm/src/armv7-a/arm_addrenv.c4
-rw-r--r--nuttx/arch/arm/src/armv7-a/mmu.h62
2 files changed, 57 insertions, 9 deletions
diff --git a/nuttx/arch/arm/src/armv7-a/arm_addrenv.c b/nuttx/arch/arm/src/armv7-a/arm_addrenv.c
index 8f7fb8fb8..45cf60882 100644
--- a/nuttx/arch/arm/src/armv7-a/arm_addrenv.c
+++ b/nuttx/arch/arm/src/armv7-a/arm_addrenv.c
@@ -361,7 +361,7 @@ int up_addrenv_create(size_t textsize, size_t datasize,
ret = up_addrenv_create_region(addrenv->text, ARCH_TEXT_NSECTS,
CONFIG_ARCH_TEXT_VBASE, textsize,
- MMU_L2_TEXTFLAGS);
+ MMU_L2_UTEXTFLAGS);
if (ret < 0)
{
bdbg("ERROR: Failed to create .text region: %d\n", ret);
@@ -372,7 +372,7 @@ int up_addrenv_create(size_t textsize, size_t datasize,
ret = up_addrenv_create_region(addrenv->data, ARCH_DATA_NSECTS,
CONFIG_ARCH_DATA_VBASE, datasize,
- MMU_L2_DATAFLAGS);
+ MMU_L2_UDATAFLAGS);
if (ret < 0)
{
bdbg("ERROR: Failed to create .bss/.data region: %d\n", ret);
diff --git a/nuttx/arch/arm/src/armv7-a/mmu.h b/nuttx/arch/arm/src/armv7-a/mmu.h
index 84fa18a50..258a9d206 100644
--- a/nuttx/arch/arm/src/armv7-a/mmu.h
+++ b/nuttx/arch/arm/src/armv7-a/mmu.h
@@ -343,7 +343,15 @@
*/
#ifdef CONFIG_AFE_ENABLE
-/* AP[2:1] access permissions model. AP[0] is used as an access flag: */
+/* AP[2:1] access permissions model. AP[0] is used as an access flag:
+ *
+ * AP[2] AP[1] PL1 PL0 Description
+ * ----- ----- ----------- ---------- --------------------------------
+ * 0 0 Read/write No access Access only at PL1
+ * 0 1 Read/write Read/write Full access
+ * 1 0 Read-only No access Read-only for PL1
+ * 1 1 Read-only Read-only Read-only at any privilege level
+ */
# define PMD_SECT_AP_RW1 (0)
# define PMD_SECT_AP_RW01 (PMD_SECT_AP1)
@@ -351,7 +359,19 @@
# define PMD_SECT_AP_R01 (PMD_SECT_AP1 | PMD_SECT_AP2)
#else
-/* AP[2:0] access permissions control, Short-descriptor format only */
+/* AP[2:0] access permissions control, Short-descriptor format only:
+ *
+ * AP[2] AP[1] AP[0] PL1/2 PL0 Description
+ * ----- ----- ----- ----------- ---------- --------------------------------
+ * 0 0 0 No access No access All accesses generate faults
+ * 0 0 1 Read/write No access Access only at PL1 and higher
+ * 0 1 0 Read/write Read-only Writes at PL0 generate faults
+ * 0 1 1 Read/write Read/write Full access
+ * 1 0 0 ---- --- Reserved
+ * 1 0 1 Read-only No access Read-only for PL1 and higher
+ * 1 1 0 Read-only Read-only (deprecated)
+ * 1 1 1 Read-only Read-only Read-only at any privilege level
+ */
# define PMD_SECT_AP_NONE (0)
# define PMD_SECT_AP_RW12 (PMD_SECT_AP0)
@@ -429,7 +449,15 @@
*/
#ifdef CONFIG_AFE_ENABLE
-/* AP[2:1] access permissions model. AP[0] is used as an access flag: */
+/* AP[2:1] access permissions model. AP[0] is used as an access flag:
+ *
+ * AP[2] AP[1] PL1 PL0 Description
+ * ----- ----- ----------- ---------- --------------------------------
+ * 0 0 Read/write No access Access only at PL1
+ * 0 1 Read/write Read/write Full access
+ * 1 0 Read-only No access Read-only for PL1
+ * 1 1 Read-only Read-only Read-only at any privilege level
+ */
# define PTE_AP_RW1 (0)
# define PTE_AP_RW01 (PTE_AP1)
@@ -437,7 +465,19 @@
# define PTE_AP_R01 (PTE_AP1 | PTE_AP2)
#else
-/* AP[2:0] access permissions control, Short-descriptor format only */
+/* AP[2:0] access permissions control, Short-descriptor format only:
+ *
+ * AP[2] AP[1] AP[0] PL1/2 PL0 Description
+ * ----- ----- ----- ----------- ---------- --------------------------------
+ * 0 0 0 No access No access All accesses generate faults
+ * 0 0 1 Read/write No access Access only at PL1 and higher
+ * 0 1 0 Read/write Read-only Writes at PL0 generate faults
+ * 0 1 1 Read/write Read/write Full access
+ * 1 0 0 ---- --- Reserved
+ * 1 0 1 Read-only No access Read-only for PL1 and higher
+ * 1 1 0 Read-only Read-only (deprecated)
+ * 1 1 1 Read-only Read-only Read-only at any privilege level
+ */
# define PTE_AP_NONE (0)
# define PTE_AP_RW12 (PTE_AP0)
@@ -543,11 +583,19 @@
/* MMU Flags for each type memory region (level 1 and 2) */
#define MMU_L1_TEXTFLAGS (PMD_TYPE_PTE | PMD_PTE_DOM(0))
-#define MMU_L2_TEXTFLAGS (PTE_TYPE_SMALL | PTE_WRITE_BACK | PTE_AP_R1)
+
+#define MMU_L2_KTEXTFLAGS (PTE_TYPE_SMALL | PTE_WRITE_BACK | PTE_AP_R1)
+#ifdef CONFIG_AFE_ENABLE
+# define MMU_L2_UTEXTFLAGS (PTE_TYPE_SMALL | PTE_WRITE_BACK | PTE_AP_RW01)
+#else
+# define MMU_L2_UTEXTFLAGS (PTE_TYPE_SMALL | PTE_WRITE_BACK | PTE_AP_RW12_R0)
+#endif
#define MMU_L1_DATAFLAGS (PMD_TYPE_PTE | PMD_PTE_PXN | PMD_PTE_DOM(0))
-#define MMU_L2_DATAFLAGS (PTE_TYPE_SMALL | PTE_WRITE_BACK | PTE_AP_RW1)
-#define MMU_L2_ALLOCFLAGS (PTE_TYPE_SMALL | PTE_WRITE_BACK | PTE_AP_RW1)
+#define MMU_L2_UDATAFLAGS (PTE_TYPE_SMALL | PTE_WRITE_BACK | PTE_AP_RW01)
+#define MMU_L2_KDATAFLAGS (PTE_TYPE_SMALL | PTE_WRITE_BACK | PTE_AP_RW1)
+#define MMU_L2_UALLOCFLAGS (PTE_TYPE_SMALL | PTE_WRITE_BACK | PTE_AP_RW01)
+#define MMU_L2_KALLOCFLAGS (PTE_TYPE_SMALL | PTE_WRITE_BACK | PTE_AP_RW1)
#define MMU_L1_PGTABFLAGS (PMD_TYPE_PTE | PMD_PTE_PXN | PTE_WRITE_THROUGH | \
PMD_PTE_DOM(0))