Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143205937
D20348.id57749.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D20348.id57749.diff
View Options
Index: sys/arm64/arm64/pmap.c
===================================================================
--- sys/arm64/arm64/pmap.c
+++ sys/arm64/arm64/pmap.c
@@ -127,6 +127,7 @@
#include <sys/sysctl.h>
#include <sys/_unrhdr.h>
#include <sys/smp.h>
+#include <sys/efi.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -174,7 +175,6 @@
#define UNCACHED_MEMORY 1
#define CACHED_MEMORY 2
-
#ifdef PV_STATS
#define PV_STAT(x) do { x ; } while (0)
#else
@@ -1152,6 +1152,27 @@
* Low level mapping routines.....
***************************************************/
+static inline int
+pmap_correct_attr(vm_paddr_t pa, int mode_req)
+{
+ uint64_t attr;
+ int mode;
+
+ /* From UEFI spec 2.8 table 7 in 2.3.6.1 */
+ attr = efi_memory_attribute(pa);
+ if ((attr & EFI_MD_ATTR_WB) != 0)
+ mode = VM_MEMATTR_WRITE_BACK;
+ else if ((attr & EFI_MD_ATTR_WT) != 0)
+ mode = VM_MEMATTR_WRITE_THROUGH;
+ else if ((attr & EFI_MD_ATTR_WC) != 0)
+ mode = VM_MEMATTR_WRITE_COMBINING;
+ else
+ mode = VM_MEMATTR_DEVICE;
+ if (mode_req < mode)
+ mode = mode_req;
+ return (mode);
+}
+
void
pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode)
{
@@ -1167,6 +1188,7 @@
KASSERT((size & PAGE_MASK) == 0,
("pmap_kenter: Mapping is not page-sized"));
+ mode = pmap_correct_attr(pa, mode);
attr = ATTR_DEFAULT | ATTR_IDX(mode) | L3_PAGE;
if (mode == DEVICE_MEMORY)
attr |= ATTR_XN;
@@ -4723,7 +4745,13 @@
/* L3 table is linked */
va = trunc_page(va);
pa = trunc_page(pa);
- pmap_kenter(va, size, pa, CACHED_MEMORY);
+
+ /*
+ * Call pmap_kenter with the highest mode
+ * it will call pmap_correct_attr to get the
+ * correct one based on the EFI map
+ */
+ pmap_kenter(va, size, pa, VM_MEMATTR_WRITE_BACK);
}
return ((void *)(va + offset));
Index: sys/arm64/include/vm.h
===================================================================
--- sys/arm64/include/vm.h
+++ sys/arm64/include/vm.h
@@ -37,7 +37,7 @@
#ifdef _KERNEL
/* If defined vmstat will try to use both of these in a switch statement */
-#define VM_MEMATTR_WRITE_COMBINING VM_MEMATTR_WRITE_THROUGH
+#define VM_MEMATTR_WRITE_COMBINING VM_MEMATTR_UNCACHEABLE
#endif
#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 28, 10:44 AM (12 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28065332
Default Alt Text
D20348.id57749.diff (2 KB)
Attached To
Mode
D20348: arm64: pmap: Try to find the correct attribute
Attached
Detach File
Event Timeline
Log In to Comment