Skip to content

Instantly share code, notes, and snippets.

@jusefn
Created September 7, 2024 17:36
Show Gist options
  • Save jusefn/0157a91c95a12e017ee8b7e79514eb5f to your computer and use it in GitHub Desktop.
Save jusefn/0157a91c95a12e017ee8b7e79514eb5f to your computer and use it in GitHub Desktop.
VMware Workstation 17.6.0 on 6.9+ Kernel
--- a/vmmon-only/include/pgtbl.h 2024-08-25 14:01:21.000000000 +0200
+++ b/vmmon-only/include/pgtbl.h 2024-09-07 19:23:03.639514435 +0200
@@ -26,6 +26,7 @@
#include "compat_pgtable.h"
#include "compat_spinlock.h"
#include "compat_page.h"
+#include "compat_version.h"
/*
@@ -45,7 +46,7 @@
*
*-----------------------------------------------------------------------------
*/
-
+#if COMPAT_LINUX_VERSION_CHECK_LT(6, 5, 0) // only used by PgtblVa2MPN() below
static INLINE MPN
PgtblVa2MPNLocked(struct mm_struct *mm, // IN: Mm structure of a process
VA addr) // IN: Address in the virtual address
@@ -87,7 +88,7 @@
if (pmd_large(*pmd)) {
mpn = pmd_pfn(*pmd) + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
} else {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,5,0) || defined(RHEL94_BACKPORTS)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,5,0)
pte_t *pte = pte_offset_kernel(pmd, addr);
#else
pte_t *pte = pte_offset_map(pmd, addr);
@@ -107,7 +108,7 @@
}
return mpn;
}
-
+#endif
/*
*-----------------------------------------------------------------------------
@@ -125,6 +126,7 @@
*
*-----------------------------------------------------------------------------
*/
+#if COMPAT_LINUX_VERSION_CHECK_LT(6, 5, 0)
static INLINE MPN
PgtblVa2MPN(VA addr) // IN
@@ -139,5 +141,24 @@
spin_unlock(&mm->page_table_lock);
return mpn;
}
+#else /* COMPAT_LINUX_VERSION_CHECK_LT(6, 5, 0) */
+
+static INLINE MPN
+PgtblVa2MPN(VA addr) // IN
+{
+ struct page *page;
+ int npages;
+ MPN mpn;
+
+ npages = get_user_pages_unlocked(addr, 1, &page, FOLL_HWPOISON);
+ if (npages != 1)
+ return INVALID_MPN;
+ mpn = page_to_pfn(page);
+ put_page(page);
+
+ return mpn;
+}
+
+#endif /* COMPAT_LINUX_VERSION_CHECK_LT(6, 5, 0) */
#endif /* __PGTBL_H__ */
--- a/vmnet-only/vmnetInt.h 2024-08-25 14:01:22.000000000 +0200
+++ b/vmnet-only/vmnetInt.h 2024-09-07 19:16:54.169092819 +0200
@@ -41,8 +41,13 @@
compat_skb_set_network_header(skb, sizeof (struct ethhdr)), \
dev_queue_xmit(skb) \
)
-#define dev_lock_list() read_lock(&dev_base_lock)
-#define dev_unlock_list() read_unlock(&dev_base_lock)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 9, 0)
+# define dev_lock_list() rcu_read_lock()
+# define dev_unlock_list() rcu_read_unlock()
+#else
+# define dev_lock_list() read_lock(&dev_base_lock)
+# define dev_unlock_list() read_unlock(&dev_base_lock)
+#endif
extern struct proto vmnet_proto;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment