From dd02025f89e9813fd39ff875d3c81056ccfc0bbc Mon Sep 17 00:00:00 2001 From: Christopher Guikema Date: Mon, 6 Sep 2021 02:19:41 -0400 Subject: [PATCH] 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 --- libsel4utils/src/mapping.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libsel4utils/src/mapping.c b/libsel4utils/src/mapping.c index 31db2c515..f315be820 100644 --- a/libsel4utils/src/mapping.c +++ b/libsel4utils/src/mapping.c @@ -31,6 +31,19 @@ static int map_page(vka_t *vka, vspace_map_page_fn_t map_page_fn, vspace_get_map 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) {