Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/include/arm32 Re-define the L*_PROT_RO for MMUs...



details:   https://anonhg.NetBSD.org/src/rev/acca2c53087c
branches:  trunk
changeset: 354968:acca2c53087c
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Jul 06 15:07:56 2017 +0000

description:
Re-define the L*_PROT_RO for MMUs that don't really support RO mapping
and adjust l2pte_set_{writeable,readony} to the new values.

This allows RO mappings for MMUs that actually support them.

diffstat:

 sys/arch/arm/include/arm32/pmap.h |  24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diffs (73 lines):

diff -r 1d2f3c3a0649 -r acca2c53087c sys/arch/arm/include/arm32/pmap.h
--- a/sys/arch/arm/include/arm32/pmap.h Thu Jul 06 14:26:00 2017 +0000
+++ b/sys/arch/arm/include/arm32/pmap.h Thu Jul 06 15:07:56 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.148 2017/07/06 06:31:24 skrll Exp $ */
+/*     $NetBSD: pmap.h,v 1.149 2017/07/06 15:07:56 skrll Exp $ */
 
 /*
  * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@@ -728,12 +728,12 @@
  */
 #define        L1_S_PROT_U_generic     (L1_S_AP(AP_U))
 #define        L1_S_PROT_W_generic     (L1_S_AP(AP_W))
-#define        L1_S_PROT_RO_generic    (0)
+#define        L1_S_PROT_RO_generic    (L1_S_AP(AP_R)) /* AP_W == AP_R */
 #define        L1_S_PROT_MASK_generic  (L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO)
 
 #define        L1_S_PROT_U_xscale      (L1_S_AP(AP_U))
 #define        L1_S_PROT_W_xscale      (L1_S_AP(AP_W))
-#define        L1_S_PROT_RO_xscale     (0)
+#define        L1_S_PROT_RO_xscale     (L1_S_AP(AP_R)) /* AP_W == AP_R */
 #define        L1_S_PROT_MASK_xscale   (L1_S_PROT_U|L1_S_PROT_W|L1_S_PROT_RO)
 
 #define        L1_S_PROT_U_armv6       (L1_S_AP(AP_R) | L1_S_AP(AP_U))
@@ -754,12 +754,12 @@
 
 #define        L2_L_PROT_U_generic     (L2_AP(AP_U))
 #define        L2_L_PROT_W_generic     (L2_AP(AP_W))
-#define        L2_L_PROT_RO_generic    (0)
+#define        L2_L_PROT_RO_generic    (L2_AP(AP_R))
 #define        L2_L_PROT_MASK_generic  (L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO)
 
 #define        L2_L_PROT_U_xscale      (L2_AP(AP_U))
 #define        L2_L_PROT_W_xscale      (L2_AP(AP_W))
-#define        L2_L_PROT_RO_xscale     (0)
+#define        L2_L_PROT_RO_xscale     (L2_AP(AP_R))
 #define        L2_L_PROT_MASK_xscale   (L2_L_PROT_U|L2_L_PROT_W|L2_L_PROT_RO)
 
 #define        L2_L_PROT_U_armv6n      (L2_AP0(AP_R) | L2_AP0(AP_U))
@@ -780,12 +780,12 @@
 
 #define        L2_S_PROT_U_generic     (L2_AP(AP_U))
 #define        L2_S_PROT_W_generic     (L2_AP(AP_W))
-#define        L2_S_PROT_RO_generic    (0)
+#define        L2_S_PROT_RO_generic    (L2_AP(AP_R))
 #define        L2_S_PROT_MASK_generic  (L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO)
 
 #define        L2_S_PROT_U_xscale      (L2_AP0(AP_U))
 #define        L2_S_PROT_W_xscale      (L2_AP0(AP_W))
-#define        L2_S_PROT_RO_xscale     (0)
+#define        L2_S_PROT_RO_xscale     (L2_AP(AP_R))
 #define        L2_S_PROT_MASK_xscale   (L2_S_PROT_U|L2_S_PROT_W|L2_S_PROT_RO)
 
 #define        L2_S_PROT_U_armv6n      (L2_AP0(AP_R) | L2_AP0(AP_U))
@@ -1023,11 +1023,15 @@
  */
 #define l1pte_set_writable(pte)        (((pte) & ~L1_S_PROT_RO) | L1_S_PROT_W)
 #define l1pte_set_readonly(pte)        (((pte) & ~L1_S_PROT_W) | L1_S_PROT_RO)
-#define l2pte_set_writable(pte)        (((pte) & ~L2_S_PROT_RO) | L2_S_PROT_W)
-#define l2pte_set_readonly(pte)        (((pte) & ~L2_S_PROT_W) | L2_S_PROT_RO)
+
+#define l2pte_set_writable(pte)        (L2_S_PROT_W == L2_S_PROT_RO ? \
+    ((pte) | L2_S_PROT_W) : (((pte) & ~L2_S_PROT_RO) | L2_S_PROT_W))
+
+#define l2pte_set_readonly(pte)        (L2_S_PROT_W == L2_S_PROT_RO ? \
+    ((pte) & ~L2_S_PROT_RO) : (((pte) & ~L2_S_PROT_W) | L2_S_PROT_RO))
 
 #define l2pte_writable_p(pte)  (((pte) & L2_S_PROT_W) == L2_S_PROT_W && \
-                                (L2_S_PROT_RO == 0 || \
+                                (L2_S_PROT_W == L2_S_PROT_RO || \
                                  ((pte) & L2_S_PROT_RO) != L2_S_PROT_RO))
 
 /*



Home | Main Index | Thread Index | Old Index