diff --git a/vmmon-only/linux/hostif.c b/vmmon-only/linux/hostif.c index 66979fb..3d6d3e0 100644 --- a/vmmon-only/linux/hostif.c +++ b/vmmon-only/linux/hostif.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -624,7 +625,24 @@ HostIF_FastClockUnlock(int callerID) // IN static void * MapCrossPage(struct page *p) // IN: { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0) return vmap(&p, 1, VM_MAP, VM_PAGE_KERNEL_EXEC); +#else + /* Starting with 5.8, vmap() always sets the NX bit, but the cross + * page needs to be executable. */ + pte_t *ptes[1]; + struct vm_struct *area = alloc_vm_area(1UL << PAGE_SHIFT, ptes); + if (area == NULL) + return NULL; + + set_pte(ptes[0], mk_pte(p, VM_PAGE_KERNEL_EXEC)); + + preempt_disable(); + __flush_tlb_all(); + preempt_enable(); + + return area->addr; +#endif }