summaryrefslogtreecommitdiff
path: root/vm
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2023-08-14 10:40:11 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-08-14 10:40:51 +0200
commit28c51f7f60281bf3acbefd47e8233ae40de1e463 (patch)
tree8e5709834780fab0a85e909fedc3dc047902974e /vm
parent952872cb67bd811991dd558dd4e5d28e7d16b21b (diff)
vm: Fix ordering of addresses between DMA32 and DIRECTMAP
Diffstat (limited to 'vm')
-rw-r--r--vm/vm_page.c10
-rw-r--r--vm/vm_page.h16
-rw-r--r--vm/vm_resident.c6
3 files changed, 28 insertions, 4 deletions
diff --git a/vm/vm_page.c b/vm/vm_page.c
index ce37c8aa..8e5cab38 100644
--- a/vm/vm_page.c
+++ b/vm/vm_page.c
@@ -245,10 +245,12 @@ static int vm_page_is_ready __read_mostly;
* - HIGHMEM: must be mapped before it can be accessed
*
* Segments are ordered by priority, 0 being the lowest priority. Their
- * relative priorities are DMA < DMA32 < DIRECTMAP < HIGHMEM. Some segments
- * may actually be aliases for others, e.g. if DMA is always possible from
- * the direct physical mapping, DMA and DMA32 are aliases for DIRECTMAP,
- * in which case the segment table contains DIRECTMAP and HIGHMEM only.
+ * relative priorities are DMA < DMA32 < DIRECTMAP < HIGHMEM or
+ * DMA < DIRECTMAP < DMA32 < HIGHMEM.
+ * Some segments may actually be aliases for others, e.g. if DMA is always
+ * possible from the direct physical mapping, DMA and DMA32 are aliases for
+ * DIRECTMAP, in which case the segment table contains DIRECTMAP and HIGHMEM
+ * only.
*/
static struct vm_page_seg vm_page_segs[VM_PAGE_MAX_SEGS];
diff --git a/vm/vm_page.h b/vm/vm_page.h
index b2581d9e..f4761f3f 100644
--- a/vm/vm_page.h
+++ b/vm/vm_page.h
@@ -162,8 +162,13 @@ void vm_page_check(const struct vm_page *page);
*/
#define VM_PAGE_DMA 0x01
+#if defined(VM_PAGE_DMA32_LIMIT) && VM_PAGE_DMA32_LIMIT > VM_PAGE_DIRECTMAP_LIMIT
+#define VM_PAGE_DIRECTMAP 0x02
+#define VM_PAGE_DMA32 0x04
+#else
#define VM_PAGE_DMA32 0x02
#define VM_PAGE_DIRECTMAP 0x04
+#endif
#define VM_PAGE_HIGHMEM 0x08
extern
@@ -327,13 +332,24 @@ extern unsigned int vm_page_info(
*
* Selector-to-segment-list translation table :
* DMA DMA
+ * if 32bit PAE
+ * DIRECTMAP DMA32 DMA
+ * DMA32 DMA32 DIRECTMAP DMA
+ * HIGHMEM HIGHMEM DMA32 DIRECTMAP DMA
+ * else
* DMA32 DMA32 DMA
* DIRECTMAP DIRECTMAP DMA32 DMA
* HIGHMEM HIGHMEM DIRECTMAP DMA32 DMA
+ * endif
*/
#define VM_PAGE_SEL_DMA 0
+#if defined(VM_PAGE_DMA32_LIMIT) && VM_PAGE_DMA32_LIMIT > VM_PAGE_DIRECTMAP_LIMIT
+#define VM_PAGE_SEL_DIRECTMAP 1
+#define VM_PAGE_SEL_DMA32 2
+#else
#define VM_PAGE_SEL_DMA32 1
#define VM_PAGE_SEL_DIRECTMAP 2
+#endif
#define VM_PAGE_SEL_HIGHMEM 3
/*
diff --git a/vm/vm_resident.c b/vm/vm_resident.c
index d4777e70..8fa7c36b 100644
--- a/vm/vm_resident.c
+++ b/vm/vm_resident.c
@@ -777,10 +777,16 @@ vm_page_t vm_page_grab(unsigned flags)
if (flags & VM_PAGE_HIGHMEM)
selector = VM_PAGE_SEL_HIGHMEM;
+#if defined(VM_PAGE_DMA32_LIMIT) && VM_PAGE_DMA32_LIMIT > VM_PAGE_DIRECTMAP_LIMIT
+ else if (flags & VM_PAGE_DMA32)
+ selector = VM_PAGE_SEL_DMA32;
+#endif
else if (flags & VM_PAGE_DIRECTMAP)
selector = VM_PAGE_SEL_DIRECTMAP;
+#if defined(VM_PAGE_DMA32_LIMIT) && VM_PAGE_DMA32_LIMIT <= VM_PAGE_DIRECTMAP_LIMIT
else if (flags & VM_PAGE_DMA32)
selector = VM_PAGE_SEL_DMA32;
+#endif
else
selector = VM_PAGE_SEL_DMA;