sel4utils: properly cache ept pages (#43)
A kernel bug previously always cached EPT page regardless of the
cacheable flag. When the bug was fixed, this function would always map
EPT pages as uncacheable, due to the attributes difference between an
EPT map and a normal page map. This commit checks if the function is
mapping an EPT and provides the proper cache attribute to the kernel.
Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
diff --git a/libsel4utils/src/mapping.c b/libsel4utils/src/mapping.c
index 31db2c5..f315be8 100644
--- a/libsel4utils/src/mapping.c
+++ b/libsel4utils/src/mapping.c
@@ -31,6 +31,19 @@
seL4_ARCH_VMAttributes attr = cacheable ? seL4_ARCH_Default_VMAttributes :
seL4_ARCH_Uncached_VMAttributes;
+ /* EPT attributes are different than a standard page table. Previously, a kernel bug
+ * masked the problem by always setting EPT mappings to WriteBack. Once the bug was
+ * fixed, every page became uncached, killing VM performance.
+ *
+ * This check ensure the pages are properly cached
+ */
+#ifdef CONFIG_VTX
+ if (seL4_X86_Page_MapEPT == map_page_fn) {
+ attr = cacheable ? seL4_X86_EPT_Default_VMAttributes :
+ seL4_X86_EPT_Uncached_VMAttributes;
+ }
+#endif
+
*num_objects = 0;
int error = map_page_fn(frame, root, (seL4_Word) vaddr, rights, attr);
while (error == seL4_FailedLookup) {