Page MenuHomeFreeBSD

D57004.id178060.diff
No OneTemporary

D57004.id178060.diff

diff --git a/sys/compat/linuxkpi/common/include/asm/set_memory.h b/sys/compat/linuxkpi/common/include/asm/set_memory.h
--- a/sys/compat/linuxkpi/common/include/asm/set_memory.h
+++ b/sys/compat/linuxkpi/common/include/asm/set_memory.h
@@ -62,35 +62,28 @@
return (-pmap_change_attr((void *)addr, len, VM_MEMATTR_WRITE_BACK));
}
+int lkpi_set_pages_attr(struct page *page, int numpages, vm_memattr_t ma);
+
static inline int
set_pages_uc(struct page *page, int numpages)
{
- KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages));
-
- pmap_page_set_memattr(page, VM_MEMATTR_UNCACHEABLE);
- return (0);
+ return (lkpi_set_pages_attr(page, numpages, VM_MEMATTR_UNCACHEABLE));
}
static inline int
set_pages_wc(struct page *page, int numpages)
{
- KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages));
-
#ifdef VM_MEMATTR_WRITE_COMBINING
- pmap_page_set_memattr(page, VM_MEMATTR_WRITE_COMBINING);
+ return (lkpi_set_pages_attr(page, numpages, VM_MEMATTR_WRITE_COMBINING));
#else
return (set_pages_uc(page, numpages));
#endif
- return (0);
}
static inline int
set_pages_wb(struct page *page, int numpages)
{
- KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages));
-
- pmap_page_set_memattr(page, VM_MEMATTR_WRITE_BACK);
- return (0);
+ return (lkpi_set_pages_attr(page, numpages, VM_MEMATTR_WRITE_BACK));
}
static inline int
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -710,6 +710,27 @@
#endif
}
+int
+lkpi_set_pages_attr(struct page *page, int numpages, vm_memattr_t ma)
+{
+ while (numpages-- > 0) {
+ /*
+ * pmap_page_set_memattr() would only update the DMAP mapping
+ * if it's a normal page, leaving the kernel map untouched.
+ */
+ MPASS(page->object != kernel_object);
+
+ /*
+ * pmap_page_set_memattr() sets page->md.pat_mode, which is
+ * crucial for future userspace mappings.
+ */
+ pmap_page_set_memattr(page, ma);
+ page++;
+ }
+
+ return (0);
+}
+
/*
* This is a highly simplified version of the Linux page_frag_cache.
* We only support up-to 1 single page as fragment size and we will

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 7, 12:08 PM (2 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38432972
Default Alt Text
D57004.id178060.diff (2 KB)

Event Timeline