From allbery@pyanfar.ece.cmu.edu  Sun Aug 24 10:32:55 2003
Return-Path: <allbery@pyanfar.ece.cmu.edu>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3378116A4BF
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 24 Aug 2003 10:32:55 -0700 (PDT)
Received: from pyanfar.ece.cmu.edu (allbery.dsl.telerama.com [205.201.8.182])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E475F43FBF
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 24 Aug 2003 10:32:53 -0700 (PDT)
	(envelope-from allbery@pyanfar.ece.cmu.edu)
Received: from pyanfar.ece.cmu.edu (jvo6rkodyysjd74c@localhost [127.0.0.1])
	by pyanfar.ece.cmu.edu (8.12.9/8.12.9) with ESMTP id h7OBETeN004361
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 24 Aug 2003 07:14:29 -0400 (EDT)
	(envelope-from allbery@pyanfar.ece.cmu.edu)
Received: (from root@localhost)
	by pyanfar.ece.cmu.edu (8.12.9/8.12.9/Submit) id h7OBETsI004360;
	Sun, 24 Aug 2003 07:14:29 -0400 (EDT)
Message-Id: <200308241114.h7OBETsI004360@pyanfar.ece.cmu.edu>
Date: Sun, 24 Aug 2003 07:14:29 -0400 (EDT)
From: "Brandon S. Allbery KF8NH" <allbery@ece.cmu.edu>
Reply-To: "Brandon S. Allbery KF8NH" <allbery@ece.cmu.edu>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: vmware2 broken on -STABLE, presumably by PAE import
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         55928
>Category:       ports
>Synopsis:       vmware2 broken on -STABLE, presumably by PAE import
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 24 10:40:00 PDT 2003
>Closed-Date:    Mon Oct 06 03:10:04 PDT 2003
>Last-Modified:  Mon Oct 06 03:10:04 PDT 2003
>Originator:     Brandon S. Allbery KF8NH
>Release:        FreeBSD 4.8-STABLE i386
>Organization:
Carnegie Mellon University
		Dept. of Electrical & Computer Engineering
		Computing Facilities
>Environment:
System: FreeBSD pyanfar.ece.cmu.edu 4.8-STABLE FreeBSD 4.8-STABLE #4: Sun Aug 17 17:28:05 EDT 2003 allbery@pyanfar.ece.cmu.edu:/usr/src/sys/compile/TIRUN i386


>Description:
	The emulators/vmware2 port does not work on recent -STABLE, failing
	with "VMware Workstation PANIC: BUG F(571):1607 bugNr=2302".  The
	usual fix for this is to rebuild the kernel modules, but (a) they
	do not build without patching and (b) the new kernel modules fail with
	the same error.

	No kernel messages were logged.

	Update:  retrying it with syslogd recording debug messages, the vmware
	bugcheck no longer occurs, but vmware reports an inability to reserve
	memory and the following is syslogged:

	Aug 24 07:10:10 pyanfar /kernel: /dev/vmmon: HostIF_LockPage vpn=0x0287bc mpn=000000 already tracked
	Aug 24 07:10:22 pyanfar last message repeated 11 times
	Aug 24 07:10:30 pyanfar /kernel: /dev/vmmon: Vmx86_DestroyVM: unlocked pages: 0, unlocked dirty pages: 0
	Aug 24 07:10:30 pyanfar /kernel: /dev/vmmon: PhysTrack_Cleanup: pfns still locked

>How-To-Repeat:
	Attempt to boot a VMware virtual machine.

>Fix:

	I used the following patch to get the modules to build; not being a
	kernel hacker, I don't know if it's correct (and would guess it's not,
	but have no idea what the correct fix is).

--- vmmon-only/freebsd/hostif.c~	Fri Aug 22 02:14:28 2003
+++ vmmon-only/freebsd/hostif.c	Fri Aug 22 02:13:19 2003
@@ -181,11 +181,11 @@
 {
 #define DEB(x) 
    caddr_t addr = (caddr_t)VPN_2_VA(ppn);
-   pt_entry_t pteptr = (pt_entry_t)vtopte(addr);
+   pt_entry_t pteptr = (pt_entry_t)vtopte((unsigned long) addr);
    PTE pte;
 
    DEB(printf("FindMPN: for page %d address %p(phys %p) pteptr %p", ppn, addr, (caddr_t)vtophys(addr), pteptr));
-   pte=*pteptr;
+   pte=*((caddr_t)pteptr);
    DEB(printf("(0x%08x)\n", pte));
    if (pte & PTE_P) { 
       return PTE_2_PFN(pte);


>Release-Note:
>Audit-Trail:

From: Edwin Groothuis <edwin@freebsd.org>
To: vsilyaev@mindspring.com
Cc: freebsd-gnats-submit@FreeBSD.org, allbery@ece.cmu.edu
Subject: ports/55928: vmware2 broken on -STABLE, presumably by PAE import
Date: Mon, 25 Aug 2003 09:30:13 +1000

 Please have a look at http://www.freebsd.org/cgi/query-pr.cgi?pr=55928
 
 What I can see from it is that it shouldn't fix it, but since I'm
 still running 4.7 on my machine I don't see the full problem yet.
 
 Edwin
 
 -- 
 Edwin Groothuis
 edwin@freebsd.org
 http://www.mavetju.org

From: Anders Nordby <anders@FreeBSD.org>
To: "Brandon S. Allbery KF8NH" <allbery@ece.cmu.edu>
Cc: FreeBSD-gnats-submit@FreeBSD.org, vsilyaev@mindspring.com,
	stable@FreeBSD.org, luoqi@FreeBSD.org, jake@FreeBSD.org
Subject: Re: ports/55928: vmware2 broken on -STABLE, presumably by PAE import
Date: Mon, 8 Sep 2003 11:21:55 +0200

 --AhhlLboLdkugWU4S
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Hi,
 
 On Sun, Aug 24, 2003 at 07:14:29AM -0400, Brandon S. Allbery KF8NH wrote:
 > >Synopsis:       vmware2 broken on -STABLE, presumably by PAE import
 >> (..)
 
 Your patch makes VmWare2 build, but it doesn't make it work:
 
 - VmWare fails to allocate memory (see
 http://anders.fix.no/test/vmware/1.png and
 http://anders.fix.no/test/vmware/2.png).
 - There seems to be something wrong with vmmon, some error messages are
 reported to my console log:
 
 Console log for noname.aftenposten.no
 /dev/vmmon: HostIF_LockPage vpn=0x048a65 mpn=000000 already tracked
 Sep  8 10:07:54 noname /kernel: /dev/vmmon: HostIF_LockPage vpn=0x048a65
 mpn=000000 already tracked
 /dev/vmmon: HostIF_LockPage vpn=0x048a65 mpn=000000 already tracked
 /dev/vmmon: HostIF_LockPage vpn=0x048a65 mpn=000000 already tracked
 /dev/vmmon: HostIF_LockPage vpn=0x048a65 mpn=000000 already tracked
 /dev/vmmon: HostIF_LockPage vpn=0x048a65 mpn=000000 already tracked
 Sep  8 10:07:58 noname last message repeated 4 times
 
 Oh, and FreeBSD gets unstable with these patches of yours. I've seen
 several hard hangs.
 
 I cleaned up the patch to be relative to the current port (patch
 attached). I'm applying your patch (pmap.patch-stable) if OSVERSION is
 less than 500000, and higher or equal to 480101 (which was used at the
 time of the PAE MFC).
 
 For those on the Cc: list, I added you because you committed PAE/pmap
 things, are on the -stable list or maintain the vmware2 port. :)
 
 Any tips or improvements to the patch to make VmWare2 work in FreeBSD
 again is very welcome. If we want VmWare supported in -stable at all
 (4.9 being right around the corner and all), this must be dealt with
 ASAP.
 
 Feel free to use me for testing your suggestions.
 
 Cheers,
 
 -- 
 Anders.
 
 --AhhlLboLdkugWU4S
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="vmware2.diff"
 
 diff -Nur vmware2.old/Makefile vmware2/Makefile
 --- vmware2.old/Makefile	Sun Apr 13 11:55:43 2003
 +++ vmware2/Makefile	Mon Sep  8 09:22:11 2003
 @@ -99,6 +99,8 @@
  .endif
  .if ${OSVERSION} >= 500027
  	${CAT} ${FILESDIR}/pmap.patch | (cd ${WRKSRC} && patch) > /dev/null 2>&1
 +.elseif ${OSVERSION} < 500000 && ${OSVERSION} >= 480101
 +	${CAT} ${FILESDIR}/pmap.patch-stable | (cd ${WRKSRC} && patch) > /dev/null 2>&1
  .endif
  	${CP} ${FILESDIR}/Makefile ${WRKSRC}
  	${CP} ${FILESDIR}/Makefile.vmmon ${WRKSRC}/vmmon-only/Makefile
 diff -Nur vmware2.old/files/pmap.patch-stable vmware2/files/pmap.patch-stable
 --- vmware2.old/files/pmap.patch-stable	Thu Jan  1 01:00:00 1970
 +++ vmware2/files/pmap.patch-stable	Mon Sep  8 09:17:55 2003
 @@ -0,0 +1,16 @@
 +--- vmmon-only/freebsd/hostif.c.orig	Mon Sep  8 09:10:39 2003
 ++++ vmmon-only/freebsd/hostif.c	Mon Sep  8 09:11:28 2003
 +@@ -181,11 +181,11 @@
 + {
 + #define DEB(x) 
 +    caddr_t addr = (caddr_t)VPN_2_VA(ppn);
 +-   pt_entry_t pteptr = (pt_entry_t)vtopte(addr);
 ++   pt_entry_t pteptr = (pt_entry_t)vtopte((unsigned long) addr);
 +    PTE pte;
 + 
 +    DEB(printf("FindMPN: for page %d address %p(phys %p) pteptr %p", ppn, addr, (caddr_t)vtophys(addr), pteptr));
 +-   pte=*pteptr;
 ++   pte=*((caddr_t)pteptr);
 +    DEB(printf("(0x%08x)\n", pte));
 +    if (pte & PTE_P) { 
 +       return PTE_2_PFN(pte);
 
 --AhhlLboLdkugWU4S--

From: "Brandon S. Allbery KF8NH" <allbery@ece.cmu.edu>
To: FreeBSD-gnats-submit@FreeBSD.org, vsilyaev@mindspring.com,
	stable@FreeBSD.org, luoqi@FreeBSD.org, jake@FreeBSD.org
Cc:  
Subject: Re: ports/55928: vmware2 broken on -STABLE, presumably by PAE
	import
Date: Mon, 08 Sep 2003 07:36:51 -0400

 On Mon, 2003-09-08 at 05:21, Anders Nordby wrote:
 > Your patch makes VmWare2 build, but it doesn't make it work:
 
 I mentioned that in the bug report (and also said "almost certainly
 wrong"...).
 
 > Oh, and FreeBSD gets unstable with these patches of yours. I've seen
 > several hard hangs.
 
 I wouldn't have noticed as my FreeBSD was unstable anyway; this was
 before any patches for the PAE code appeared, so my machine was crashing
 every few hours anyway.  :/
 
 In any case, I had already guessed from the type change away from
 pointers that just using the provided values would do the wrong thing. 
 I was hoping that getting the module to compile would at least produce
 some useful diagnostics before the incorrect page manipulations trashed
 too much of kernel memory....  (I am no kernel hacker, and in particular
 know approximately nothing about FreeBSD's memory management or how the
 PAE import changed it.)
 
 -- 
 brandon s. allbery    [linux,solaris,freebsd,perl]     allbery@kf8nh.com
 system administrator      [WAY too many hats]        allbery@ece.cmu.edu
 electrical and computer engineering, carnegie mellon univ.         KF8NH
 URGENT!  E-xpedient nuked APK subdomains; kf8nh.apk.net is DEAD.  Sorry.
 
State-Changed-From-To: open->closed 
State-Changed-By: fjoe 
State-Changed-When: Mon Oct 6 03:08:42 PDT 2003 
State-Changed-Why:  
I committed the fix that uses already existing patches for 5.x. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55928 
>Unformatted:
