Index: sys/arch/arm/include/arm32/pmap.h =================================================================== RCS file: /cvsroot/src/sys/arch/arm/include/arm32/pmap.h,v retrieving revision 1.151 diff -u -p -r1.151 pmap.h --- sys/arch/arm/include/arm32/pmap.h 11 Jul 2017 20:42:17 -0000 1.151 +++ sys/arch/arm/include/arm32/pmap.h 28 Aug 2017 12:15:42 -0000 @@ -728,12 +728,12 @@ extern void (*pmap_zero_page_func)(paddr */ #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 (L1_S_AP(AP_R)) /* AP_W == AP_R */ +#define L1_S_PROT_RO_generic (0) #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 (L1_S_AP(AP_R)) /* AP_W == AP_R */ +#define L1_S_PROT_RO_xscale (0) #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 @@ extern void (*pmap_zero_page_func)(paddr #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 (L2_AP(AP_R)) +#define L2_L_PROT_RO_generic (0) #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 (L2_AP(AP_R)) +#define L2_L_PROT_RO_xscale (0) #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 @@ extern void (*pmap_zero_page_func)(paddr #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 (L2_AP(AP_R)) +#define L2_S_PROT_RO_generic (0) #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 (L2_AP(AP_R)) +#define L2_S_PROT_RO_xscale (0) #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)) @@ -1028,31 +1028,44 @@ extern void (*pmap_zero_page_func)(paddr #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) (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_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_writable_p(pte) (((pte) & L2_S_PROT_W) == L2_S_PROT_W && \ - (L2_S_PROT_W == L2_S_PROT_RO || \ + (L2_S_PROT_RO == 0 || \ ((pte) & L2_S_PROT_RO) != L2_S_PROT_RO)) /* * These macros return various bits based on kernel/user and protection. * Note that the compiler will usually fold these at compile time. */ -#define L1_S_PROT(ku, pr) ((((ku) == PTE_USER) ? L1_S_PROT_U : 0) | \ - (((pr) & VM_PROT_WRITE) ? L1_S_PROT_W : \ - (L1_S_PROT_W == L1_S_PROT_RO ? 0 : L1_S_PROT_RO))) - -#define L2_L_PROT(ku, pr) ((((ku) == PTE_USER) ? L2_L_PROT_U : 0) | \ - (((pr) & VM_PROT_WRITE) ? L2_L_PROT_W : \ - (L2_L_PROT_W == L2_L_PROT_RO ? 0 : L2_L_PROT_RO))) - -#define L2_S_PROT(ku, pr) ((((ku) == PTE_USER) ? L2_S_PROT_U : 0) | \ - (((pr) & VM_PROT_WRITE) ? L2_S_PROT_W : \ - (L2_S_PROT_W == L2_S_PROT_RO ? 0 : L2_S_PROT_RO))) + +#define L1_S_PROT(ku, pr) ( \ + (((ku) == PTE_USER) ? \ + L1_S_PROT_U | (((pr) & VM_PROT_WRITE) ? L1_S_PROT_W : 0) \ + : \ + (((L1_S_PROT_RO && \ + ((pr) & (VM_PROT_READ | VM_PROT_WRITE)) == VM_PROT_READ) ? \ + L1_S_PROT_RO : L1_S_PROT_W))) \ + ) + +#define L2_L_PROT(ku, pr) ( \ + (((ku) == PTE_USER) ? \ + L2_L_PROT_U | (((pr) & VM_PROT_WRITE) ? L2_L_PROT_W : 0) \ + : \ + (((L2_L_PROT_RO && \ + ((pr) & (VM_PROT_READ | VM_PROT_WRITE)) == VM_PROT_READ) ? \ + L2_L_PROT_RO : L2_L_PROT_W))) \ + ) + +#define L2_S_PROT(ku, pr) ( \ + (((ku) == PTE_USER) ? \ + L2_S_PROT_U | (((pr) & VM_PROT_WRITE) ? L2_S_PROT_W : 0) \ + : \ + (((L2_S_PROT_RO && \ + ((pr) & (VM_PROT_READ | VM_PROT_WRITE)) == VM_PROT_READ) ? \ + L2_S_PROT_RO : L2_S_PROT_W))) \ + ) /* * Macros to test if a mapping is mappable with an L1 SuperSection,