From adrian@briton.neuro.virginia.edu  Tue Jan 21 14:38:28 1997
Received: from who.cdrom.com (who.cdrom.com [204.216.27.3])
          by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id OAA18657
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 21 Jan 1997 14:38:28 -0800 (PST)
Received: from briton.neuro.virginia.edu (briton.neuro.Virginia.EDU [128.143.244.32])
          by who.cdrom.com (8.7.5/8.6.11) with ESMTP id OAA12595
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 21 Jan 1997 14:38:16 -0800 (PST)
Received: (from adrian@localhost)
          by briton.neuro.virginia.edu (8.8.4/8.8.4)
	  id RAA00554; Tue, 21 Jan 1997 17:31:50 -0500 (EST)
Message-Id: <199701212231.RAA00554@briton.neuro.virginia.edu>
Date: Tue, 21 Jan 1997 17:31:50 -0500 (EST)
From: adrian@virginia.edu
Reply-To: adrian@virginia.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: moused caused panic
X-Send-Pr-Version: 3.2

>Number:         2553
>Category:       kern
>Synopsis:       loading moused panics kernel when no mouse is installed.
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 21 14:40:01 PST 1997
>Closed-Date:    Tue Jan 21 16:23:06 PST 1997
>Last-Modified:  Tue Jan 21 17:20:02 PST 1997
>Originator:     Adrian Filipi-Martin
>Release:        FreeBSD 2.2-BETA_A i386
>Organization:
UVA
>Environment:

	GW2K P5/60 (upgraded to P5/120), 40MB, IDE, PS/2 mouse on motherboard.

>Description:

	When booting without a mouse plugged in, moused causes the kernel 
	to panic.  Here is the panic message:

	Page fault while in kernel mode
	  fault virt. addr	= 0x8
	  fault code		= supervisor read, page not present
	  IP			= 0x8:0xf01b453b
	  SP			= 0x10:0xefbffdb0
	  FP			= 0x10:0xefbffdc8
	  CS			= base 0x0, limit 0xfffff, type 0x1b
	  proc. eflags		= inerrupt era, resume, IOPL = 0
	  cur. proc.		= 153 (moused)
	  panic: page fault

>How-To-Repeat:

	Unplug my mouse and reboot.

	N.B. Did not check whether starting moused at a leter time had the 
	same problems.

>Fix:
	
	Workaround: Plug my mouse in or make sure moused is not 
	loaded at boot time.

	A real fix probably involves the psm driver, which is beyond me.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: nate 
State-Changed-When: Tue Jan 21 16:23:06 PST 1997 
State-Changed-Why:  
This is due to a bug in the ps/2 mouse driver that was fixed post 2.2-Beta. 


From: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To: adrian@virginia.edu
Cc: FreeBSD-gnats-submit@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp
Subject: Re: kern/2553: moused caused panic 
Date: Wed, 22 Jan 1997 10:21:06 +0900

 >>Description:
 >
 >	When booting without a mouse plugged in, moused causes the kernel 
 >	to panic.  Here is the panic message:
 
 The problem has been fixed and committed to the source tree.
 Apply the first patch to /usr/src/sys/i386/isa/psm.c and the second
 patch to /usr/src/usr.sbin/moused/moused.c (if you don't run moused,
 you don't need this one, though).
 
 >>Fix:
 >	
 >	Workaround: Plug my mouse in or make sure moused is not 
 >	loaded at boot time.
 >
 >	A real fix probably involves the psm driver, which is beyond me.
 
 You are right, and it's done.
 
 Thank you for your report.
 
 Kazu
 
 <<<< patch to the psm driver >>>>
 
 --- psm.c-dist	Mon Dec  2 06:37:16 1996
 +++ psm.c	Sat Jan  4 11:54:32 1997
 @@ -508,6 +508,8 @@
      if (unit >= NPSM)
          return (0);
  
 +    psm_softc[unit] = NULL;
 +
      sc =  malloc(sizeof *sc, M_DEVBUF, M_NOWAIT);
  
      bzero(sc, sizeof *sc);
 @@ -745,6 +747,9 @@
      int unit = dvp->id_unit;
      struct psm_softc *sc = psm_softc[unit];
  
 +    if (sc == NULL)	/* shouldn't happen */
 +	return (0);
 +
      /* initial operation mode */
      sc->mode.accelfactor = PSM_ACCEL;
      sc->mode.protocol = MOUSE_PROTO_PS2;
 @@ -786,6 +791,8 @@
  
      /* Get device data */
      sc = psm_softc[unit];
 +    if (sc == NULL)
 +	return (ENXIO);
      if ((sc->state & PSM_VALID) == 0)
  	/* the device is no longer valid/functioning */
          return (ENXIO);
 
 
 
 <<<< patch to moused >>>>
 
 --- moused.c-dist	Wed Sep 11 05:03:37 1996
 +++ moused.c	Fri Dec 27 17:05:45 1996
 @@ -53,6 +53,9 @@
  #include <fcntl.h>
  #include <termios.h>
  #include <machine/console.h>
 +#include <sys/types.h>
 +#include <sys/time.h>
 +#include <unistd.h>
  
  #define debug(fmt,args...) \
  	if (debug&&nodaemon) fprintf(stderr,"%s: " fmt "\n", progname, ##args)
 @@ -150,6 +153,7 @@
      struct termios	t;
      struct mouse_info 	mouse;
      int			saved_buttons = 0;
 +    fd_set		fds;
  
      progname = argv[0];
  
 @@ -243,6 +247,9 @@
  
      for(;;)
      {
 +	FD_ZERO(&fds);
 +	FD_SET(rodent.mfd,&fds);
 +	select(FD_SETSIZE,&fds,NULL,&fds,NULL);
  	i = read(rodent.mfd,&b,1);	/* get a byte */
  	if (i != 1)			/* read returned or error; goodbye */
  	{
 
 
 
>Unformatted:
