Skip to content

Instantly share code, notes, and snippets.

@addohm
Last active July 25, 2025 22:16
Show Gist options
  • Save addohm/20776649463a831174a313e67fe25083 to your computer and use it in GitHub Desktop.
Save addohm/20776649463a831174a313e67fe25083 to your computer and use it in GitHub Desktop.
6.15.2-200.nobara.fc42.x86_64 patch for vmware workstation vm drivers

cd /usr/lib/vmware/modules/source/

create backup of modules and unpack

sudo mv vmmon.tar vmmon.tar.bak

sudo tar xf vmmon.tar.bak

sudo mv vmnet.tar vmnet.tar.bak

sudo tar xf vmnet.tar.bak

Download the patch from

https://paste.gloriouseggroll.tv/?38be3fa82f505e8c#GGzhGWuJTwTFmBk7wJon2aAgHUCPiej6ENMj87Wrg47c

#Apply the patch

git apply patch_you_downloaded.patch

repack the modules and remove folders

sudo tar cf vmmon.tar vmmon-only

sudo rm -rf vmmon-only

sudo tar cf vmnet.tar vmnet-only

sudo rm -rf vmnet-only

Re-install the drivers

sudo vmware-modconfig --console --install-all

From 926cfc50c017a099c796662c8e2820d12f94d0bb Mon Sep 17 00:00:00 2001
From: Amadej Kastelic <[email protected]>
Date: Wed, 28 May 2025 22:17:29 +0200
Subject: [PATCH] Fix build for 6.15 kernel
---
vmmon-only/Makefile | 2 +-
vmmon-only/Makefile.kernel | 2 +-
vmmon-only/include/pgtbl.h | 56 ++++++++++++++++++++++----------------
vmmon-only/linux/driver.c | 2 +-
vmmon-only/linux/hostif.c | 10 +++----
vmnet-only/driver.c | 10 +++----
6 files changed, 45 insertions(+), 37 deletions(-)
diff --git a/vmmon-only/Makefile b/vmmon-only/Makefile
index f4a60e6d..f333ac1a 100644
--- a/vmmon-only/Makefile
+++ b/vmmon-only/Makefile
@@ -122,7 +122,7 @@ endif
vm_check_build = $(shell if $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
$(CPPFLAGS) $(CFLAGS) $(CFLAGS_KERNEL) $(LINUXINCLUDE) \
- $(EXTRA_CFLAGS) -Iinclude2/asm/mach-default \
+ $(ccflags-y) -Iinclude2/asm/mach-default \
-DKBUILD_BASENAME=\"$(DRIVER)\" \
-Werror -S -o /dev/null -xc $(1) \
> /dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi)
diff --git a/vmmon-only/Makefile.kernel b/vmmon-only/Makefile.kernel
index ded2dfc3..aaa3558a 100644
--- a/vmmon-only/Makefile.kernel
+++ b/vmmon-only/Makefile.kernel
@@ -21,7 +21,7 @@
CC_OPTS += -DVMMON -DVMCORE
INCLUDE := -I$(SRCROOT)/include -I$(SRCROOT)/include/x86 -I$(SRCROOT)/common -I$(SRCROOT)/linux
-EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE)
+ccflags-y := $(CC_OPTS) $(INCLUDE)
obj-m += $(DRIVER).o
diff --git a/vmmon-only/include/pgtbl.h b/vmmon-only/include/pgtbl.h
index d19326d7..da90ec82 100644
--- a/vmmon-only/include/pgtbl.h
+++ b/vmmon-only/include/pgtbl.h
@@ -28,7 +28,6 @@
#include "compat_page.h"
#include "compat_version.h"
-#if COMPAT_LINUX_VERSION_CHECK_LT(4, 10, 0)
/*
*-----------------------------------------------------------------------------
@@ -48,6 +47,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
@@ -89,7 +89,11 @@ PgtblVa2MPNLocked(struct mm_struct *mm, // IN: Mm structure of a process
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)
+ pte_t *pte = pte_offset_kernel(pmd, addr);
+#else
pte_t *pte = pte_offset_map(pmd, addr);
+#endif
if (pte_present(*pte) == 0) {
pte_unmap(pte);
@@ -105,32 +109,19 @@ PgtblVa2MPNLocked(struct mm_struct *mm, // IN: Mm structure of a process
}
return mpn;
}
+#endif
-static INLINE MPN
-UserVa2MPN(VA addr) // IN
-{
- struct mm_struct *mm;
- MPN mpn;
- /* current->mm is NULL for kernel threads, so use active_mm. */
- mm = current->active_mm;
- spin_lock(&mm->page_table_lock);
- mpn = PgtblVa2MPNLocked(mm, addr);
- spin_unlock(&mm->page_table_lock);
- return mpn;
-}
-
-#else
/*
*-----------------------------------------------------------------------------
*
- * UserVa2MPN --
+ * PgtblVa2MPN --
*
* Walks through the hardware page tables of the current process to try to
* find the page structure associated to a virtual address.
*
* Results:
- * MPN associated with the given virtual address
+ * Same as PgtblVa2MPNLocked()
*
* Side effects:
* None
@@ -138,23 +129,40 @@ UserVa2MPN(VA addr) // IN
*-----------------------------------------------------------------------------
*/
+#if COMPAT_LINUX_VERSION_CHECK_LT(6, 5, 0)
+
static INLINE MPN
-UserVa2MPN(VA addr) // IN
+PgtblVa2MPN(VA addr) // IN
+{
+ struct mm_struct *mm;
+ MPN mpn;
+
+ /* current->mm is NULL for kernel threads, so use active_mm. */
+ mm = current->active_mm;
+ spin_lock(&mm->page_table_lock);
+ mpn = PgtblVa2MPNLocked(mm, addr);
+ 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, 0);
- if (npages != 1) {
- return INVALID_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(4, 10, 0) */
+
+#endif /* COMPAT_LINUX_VERSION_CHECK_LT(6, 5, 0) */
#endif /* __PGTBL_H__ */
diff --git a/vmmon-only/linux/driver.c b/vmmon-only/linux/driver.c
index 2fb42654..2634ebf7 100644
--- a/vmmon-only/linux/driver.c
+++ b/vmmon-only/linux/driver.c
@@ -346,7 +346,7 @@ LinuxDriverExit(void)
Log("Module %s: unloaded\n", vmmon_miscdev.name);
- del_timer_sync(&tscTimer);
+ timer_delete_sync(&tscTimer);
Vmx86_CleanupHVIOBitmap();
Task_Terminate();
diff --git a/vmmon-only/linux/hostif.c b/vmmon-only/linux/hostif.c
index 1c499d79..6a93b0fa 100644
--- a/vmmon-only/linux/hostif.c
+++ b/vmmon-only/linux/hostif.c
@@ -1177,7 +1177,7 @@ HostIF_LookupUserMPN(VMDriver *vm, // IN: VMDriver
void *uvAddr = VA64ToPtr(uAddr);
int retval = PAGE_LOCK_SUCCESS;
- *mpn = UserVa2MPN((VA)uvAddr);
+ *mpn = PgtblVa2MPN((VA)uvAddr);
/*
* On failure, check whether the page is locked.
@@ -1205,7 +1205,7 @@ HostIF_LookupUserMPN(VMDriver *vm, // IN: VMDriver
volatile int c;
get_user(c, (char *)uvAddr);
- *mpn = UserVa2MPN((VA)uvAddr);
+ *mpn = PgtblVa2MPN((VA)uvAddr);
if (*mpn == entryPtr->mpn) {
#ifdef VMX86_DEBUG
printk(KERN_DEBUG "Page %p disappeared from %s(%u)... "
@@ -1410,11 +1410,11 @@ HostIF_UnlockPageByMPN(VMDriver *vm, // IN: VMDriver
/*
* Verify for debugging that VA and MPN make sense.
- * UserVa2MPN() can fail under high memory pressure.
+ * PgtblVa2MPN() can fail under high memory pressure.
*/
if (va != NULL) {
- MPN lookupMpn = UserVa2MPN((VA)va);
+ MPN lookupMpn = PgtblVa2MPN((VA)va);
if (lookupMpn != INVALID_MPN && mpn != lookupMpn) {
Warning("Page lookup fail %#"FMT64"x %016" FMT64 "x %p\n",
@@ -1996,7 +1996,7 @@ HostIF_InitUptime(void)
void
HostIF_CleanupUptime(void)
{
- del_timer_sync(&uptimeState.timer);
+ timer_delete_sync(&uptimeState.timer);
}
diff --git a/vmnet-only/driver.c b/vmnet-only/driver.c
index 0e4e11d2..a607851e 100644
--- a/vmnet-only/driver.c
+++ b/vmnet-only/driver.c
@@ -285,7 +285,7 @@ VNetRemovePortFromList(const VNetPort *port) // IN: port to remove from list
*/
int
-init_module(void)
+LinuxDriverInit(void)
{
int retval;
@@ -347,7 +347,7 @@ vmnet_init_module(void)
/*
*----------------------------------------------------------------------
*
- * cleanup_module --
+ * LinuxDriverExit --
*
* Called by /sbin/rmmod. Unregisters this driver for a
* vnet major #, and deinitializes the modules. The 64-bit
@@ -364,7 +364,7 @@ vmnet_init_module(void)
*/
void
-cleanup_module(void)
+LinuxDriverExit(void)
{
unregister_chrdev(VNET_MAJOR_NUMBER, "vmnet");
VNetProtoUnregister();
@@ -1659,3 +1659,5 @@ MODULE_LICENSE("GPL v2");
* by default (i.e., neither mkinitrd nor modprobe will accept it).
*/
MODULE_INFO(supported, "external");
+module_init(LinuxDriverInit);
+module_exit(LinuxDriverExit);
@CobrianTinander
Copy link

The pastebin link has expired, tried downloading the patch file from here but upon applying I got the error
··• git apply ~/Downloads/vmware-6.15.2.patch.txt error: corrupt patch at line 251

As a result installing the drivers fails like usual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment