Subject: vmware2 module doesn't build on 2.0, patch enclosed
To: None <current-users@netbsd.org>
From: Greg Troxel <gdt@ir.bbn.com>
List: current-users
Date: 10/19/2004 08:54:05
I tried to build vmware2 on 2.0, and found that it didn't build.
With the following patch, I was able to build, but I haven't tested it
yet.

This is mostly p->p_dupfd to curlwp->l_dupfd.

I realize wmware2 is ancient, but upgrading isn't free...


Index: distinfo
===================================================================
RCS file: /NETBSD-CVS/pkgsrc/emulators/vmware-module/distinfo,v
retrieving revision 1.6
diff -u -r1.6 distinfo
--- distinfo	16 Feb 2003 19:37:28 -0000	1.6
+++ distinfo	19 Oct 2004 12:27:09 -0000
@@ -3,3 +3,7 @@
 SHA1 (vmware-netbsd-1.2.tgz) = 383512f5a9f6cbc50ad5d25ea7e2ae921b00bb1a
 Size (vmware-netbsd-1.2.tgz) = 97596 bytes
 SHA1 (patch-ab) = 19ff0b151b62870835a2b87e69a52b1cb3d95045
+SHA1 (patch-ad) = 030434776e7b80bbd59c5121ebee04c273eaea52
+SHA1 (patch-ae) = a92a3c18f0b26d8fbe23936b749af89725a9c459
+SHA1 (patch-af) = 3b086b4f85b19b0040e173b1195f2c37a503d43d
+SHA1 (patch-ag) = f37832a6409c39af98c1cd48e173e31e624a810d
Index: patches/patch-ad
===================================================================
RCS file: patches/patch-ad
diff -N patches/patch-ad
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-ad	19 Oct 2004 12:27:09 -0000
@@ -0,0 +1,16 @@
+$NetBSD$
+
+--- source/vmmon/include/x86.h.orig	2003-02-16 05:09:57.000000000 -0500
++++ source/vmmon/include/x86.h
+@@ -180,9 +180,11 @@
+ #define MSR_TSC              0x00000010
+ #endif /* MSR_TSC */
+ #define MSR_MTRR_CAP         0x000000fe
++#ifndef MSR_SYSENTER_CS
+ #define MSR_SYSENTER_CS      0x00000174
+ #define MSR_SYSENTER_ESP     0x00000175
+ #define MSR_SYSENTER_EIP     0x00000176
++#endif /* MSR_SYSENTER_CS */
+ 
+ 
+ typedef uint32 CReg;
Index: patches/patch-ae
===================================================================
RCS file: patches/patch-ae
diff -N patches/patch-ae
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-ae	19 Oct 2004 12:27:09 -0000
@@ -0,0 +1,47 @@
+$NetBSD$
+
+--- source/vmmon/netbsd/drv.c.orig	2003-02-16 07:28:36.000000000 -0500
++++ source/vmmon/netbsd/drv.c
+@@ -43,6 +43,7 @@
+ #include <sys/malloc.h>
+ #include <sys/poll.h>
+ #include <sys/proc.h>
++#include <sys/lwp.h>
+ #include <sys/signalvar.h>
+ #include <sys/ioctl.h>
+ #include <sys/sysctl.h>
+@@ -170,7 +171,7 @@ vmmon_open(dev_t dev, int flag, int mode
+ 	int error;
+ 	VMDriver *vm;
+ 
+-	if (p->p_dupfd >= 0)
++	if (curlwp->l_dupfd >= 0)
+ 		return ENODEV;
+ 
+ 	VMDEBUG("vmmon: %d opened device\n", p->p_pid);
+@@ -192,7 +193,7 @@ vmmon_open(dev_t dev, int flag, int mode
+ 	    p->p_pid, VMNUM(vmxsc->vm_dev), major(vmxsc->vm_dev));
+ 
+ 	error = vmmon_fake_clonedev(vmxsc->vm_dev, flag, p);
+-	if (error != 0 && p->p_dupfd < 0) {
++	if (error != 0 && curlwp->l_dupfd < 0) {
+ 		vm_destroy(vmmonsc, VMNUM(vmxsc->vm_dev));
+ 		return error;
+ 	}
+@@ -281,7 +282,7 @@ vmmon_fake_clonedev(dev_t dev, int flag,
+ #endif
+ 	FILE_UNUSE(fp, p);
+ 
+-	p->p_dupfd = fd;
++	curlwp->l_dupfd = fd;
+ 
+ 	return ENXIO;
+ }
+@@ -673,6 +674,6 @@ Panic(char *fmt, ...)
+ 		vWarning(vm);
+ 	}
+   
+-	exit1(curproc, 0);
++	exit1(curlwp, 0);
+ 	/* NOTREACHED */
+ }
Index: patches/patch-af
===================================================================
RCS file: patches/patch-af
diff -N patches/patch-af
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-af	19 Oct 2004 12:27:09 -0000
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- source/vmmon/netbsd/host.c.orig	2003-02-16 07:28:36.000000000 -0500
++++ source/vmmon/netbsd/host.c
+@@ -266,7 +266,7 @@ HostIF_InitFP(VMDriver *vm)
+ 	 * Since a working int16 means that IRQ 13 will not be used
+ 	 * on NetBSD, this should not be needed.
+ 	 */
+-#if 1
++#if 0
+ 	int mask = (1<<(0xd-0x8));
+ 	uint8 val = inb(0xA1);
+ 
+@@ -635,7 +635,7 @@ HostIF_UserToDriverPtr(VMDriver *vm, voi
+ 	if (vm->crossvaddr != NULL)
+ 		Warning("KernelAddr already allocated\n");
+ 
+-	PHOLD(curproc);
++	PHOLD(curlwp);
+ 	uvm_vslock(curproc, addr, PAGE_SIZE,
+ 	    VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ 
+@@ -644,7 +644,7 @@ HostIF_UserToDriverPtr(VMDriver *vm, voi
+ 	pmap_extract(vm_map_pmap(&curproc->p_vmspace->vm_map), uaddr, &paddr);
+ 	pmap_kenter_pa(kvaddr, paddr,
+ 	    VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
+-	PRELE(curproc);
++	PRELE(curlwp);
+ 	vm->crossvaddr = (void *)kvaddr;
+ 	vm->crossuaddr = addr;
+ #ifdef DEBUG
Index: patches/patch-ag
===================================================================
RCS file: patches/patch-ag
diff -N patches/patch-ag
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-ag	19 Oct 2004 12:27:09 -0000
@@ -0,0 +1,39 @@
+$NetBSD$
+
+--- source/vmnet/if_hubmod.c.orig	2003-02-15 21:09:13.000000000 -0500
++++ source/vmnet/if_hubmod.c
+@@ -44,6 +44,7 @@
+ #include <sys/mbuf.h>
+ #include <sys/poll.h>
+ #include <sys/proc.h>
++#include <sys/lwp.h>
+ #include <sys/signalvar.h>
+ #include <sys/socket.h>
+ #include <sys/ioctl.h>
+@@ -362,7 +363,7 @@ hub_open(dev_t dev, int flag, int mode, 
+ 	struct hubport_softc *portsc;
+ 	int error, unit;
+ 
+-	if (p->p_dupfd >= 0)
++	if (curlwp->l_dupfd >= 0)
+ 		return ENODEV;
+ 
+ 	unit = HUBUNIT(dev);
+@@ -397,7 +398,7 @@ hub_open(dev_t dev, int flag, int mode, 
+ 	    HUBPORT(portsc->port_dev));
+ 
+ 	error = hub_fake_clonedev(portsc->port_dev, flag, p);
+-	if (error != 0 && p->p_dupfd < 0)
++	if (error != 0 && curlwp->l_dupfd < 0)
+ 		port_destroy(hubsc, HUBPORT(portsc->port_dev));
+ 
+ 	return error;
+@@ -516,7 +517,7 @@ hub_fake_clonedev(dev_t dev, int flag, s
+ #endif
+ 	FILE_UNUSE(fp, p);
+ 
+-	p->p_dupfd = fd;
++	curlwp->l_dupfd = fd;
+ 
+ 	return ENXIO;
+ }