summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzbb <zbb@FreeBSD.org>2017-07-27 23:14:17 +0000
committerLuiz Souza <luiz@netgate.com>2017-09-06 13:46:13 -0500
commit77f1108155169e7acbeb65d3ea697ab7fda3cc0a (patch)
tree7e63f855603d952009d2ed2343449f3e3f0997eb
parent8e7d820ef2e38b52367d97799b9785e6cf5a0625 (diff)
downloadFreeBSD-src-77f1108155169e7acbeb65d3ea697ab7fda3cc0a.zip
FreeBSD-src-77f1108155169e7acbeb65d3ea697ab7fda3cc0a.tar.gz
Fix TEX index acquisition using L2 attributes
The TEX index is selected using (TEX0 C B) bits from the L2 descriptor. Use correct index by masking and shifting those bits accordingly. Differential Revision: https://reviews.freebsd.org/D11703 (cherry picked from commit 90fde46fef4df1269c1855372f80834ea8e50143)
-rw-r--r--sys/arm/arm/pmap-v6.c4
-rw-r--r--sys/arm/include/pte-v6.h8
2 files changed, 9 insertions, 3 deletions
diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c
index 5f90af3..494541c 100644
--- a/sys/arm/arm/pmap-v6.c
+++ b/sys/arm/arm/pmap-v6.c
@@ -524,8 +524,8 @@ pmap_remap_vm_attr(vm_memattr_t old_attr, vm_memattr_t new_attr)
int old_idx, new_idx;
/* Map VM memattrs to indexes to tex_class table. */
- old_idx = pte2_attr_tab[(int)old_attr];
- new_idx = pte2_attr_tab[(int)new_attr];
+ old_idx = PTE2_ATTR2IDX(pte2_attr_tab[(int)old_attr]);
+ new_idx = PTE2_ATTR2IDX(pte2_attr_tab[(int)new_attr]);
/* Replace TEX attribute and apply it. */
tex_class[old_idx] = tex_class[new_idx];
diff --git a/sys/arm/include/pte-v6.h b/sys/arm/include/pte-v6.h
index cc92b28..d9aaaea 100644
--- a/sys/arm/include/pte-v6.h
+++ b/sys/arm/include/pte-v6.h
@@ -149,10 +149,12 @@
#define L2_NX 0x00000001 /* Not executable */
#define L2_B 0x00000004 /* Bufferable page */
#define L2_C 0x00000008 /* Cacheable page */
+#define L2_CB_SHIFT 2 /* C,B bit field shift */
#define L2_AP(x) ((x) << 4)
#define L2_AP0 0x00000010 /* access permissions bit 0*/
#define L2_AP1 0x00000020 /* access permissions bit 1*/
-#define L2_TEX(x) ((x) << 6) /* type extension */
+#define L2_TEX_SHIFT 6 /* type extension field shift */
+#define L2_TEX(x) ((x) << L2_TEX_SHIFT) /* type extension */
#define L2_TEX0 0x00000040 /* type extension bit 0 */
#define L2_TEX1 0x00000080 /* type extension bit 1 */
#define L2_TEX2 0x00000100 /* type extension bit 2 */
@@ -271,6 +273,10 @@
#define PTE2_FRAME L2_S_FRAME
#define PTE2_ATTR_MASK (L2_TEX0 | L2_C | L2_B)
+/* PTE2 attributes to TEX class index: (TEX0 C B) */
+#define PTE2_ATTR2IDX(attr) \
+ ((((attr) & (L2_C | L2_B)) >> L2_CB_SHIFT) | \
+ (((attr) & L2_TEX0) >> (L2_TEX_SHIFT - L2_CB_SHIFT)))
#define PTE2_AP_KR (PTE2_RO | PTE2_NM)
#define PTE2_AP_KRW 0
OpenPOWER on IntegriCloud