Subject: Re: Panic with apm enabled
To: None <port-i386@netbsd.org>
From: Gregory McGarry <g.mcgarry@qut.edu.au>
List: port-i386
Date: 03/28/2000 12:00:34
Following up my own mail:

> I have an NEC Versa V/75 which doesn't work with the apm driver.
> 
> NetBSD 1.4U (NOTEBOOK) #1: Sun Mar 19 08:12:58 GMT 2000
> 
> apm: bioscall return: 101 504d 3 0 c0250002 0 0
> apm0 at mainbus0: bioscall return: c0420101 c033504d c0430003 c0420000 c0420002 0 c0250000
> apm0: bioscall return: c0420304 c0330000 c0430000 c0420000 c0420003<CY> 0 c0250000
> apm0: bioscall return: c042e800 346e c043e800 c0423000 c0420002 0 c0250000
> apm0: lame v1.1 bios gave zero len code32, pegged to 64k
> apm0: lame v1.1 bios gave zero len code16, pegged to 64k
> apm0: lame v1.1 bios gave zero len data, tentative 64k
> apm0: bogus bios data seg location, ignoring
> apm0: code32len=10000, datalen=0
> apm0: detail 30101 32b:e8000/0xc0383000/10000 16b:e8000/0xc0383000/10000 data 0/0xc029b000/0 ep 346e (30:0xc038646e) 0xc0303ff0
> apm0: apmcall: func 14 from line 774 -> 0x0
> Power Management spec V1.1
> apmcall: func 15 from line 636 -> 0x0
> apmcall: func 10 from line 806uvm_fault(0xc02f0c80, 0x2000, 0, 1) -> 1
> kernel: page fault trap, code=0
> Stopped in swapper at   trap+0x2c5:     movzbl  0(%edi),%eax
> db>

It seems that the apm bios really does want a data segment to scratch
around in and specifies segment 0x30000.  My calculation puts it at 3MB.
The current apm code more-or-less only accepts data segments in the memory
hole.  In fact the code tries very hard to ensure it is only in the
memory hole; if it isn't then no data segment gets mapped.  Consequently,
when the apm bios is called, it accesses the data segment and causes a
page fault.

The machine runs OK now, if the data segment specified by the apm bios
is accepted.

Two questions about this.  Firstly, should the apm code ignore what the
apm bios says (and not map a data segment), or should it accept it
even if it could be dangerous?  In either case, if the wrong choice is
made the machine isn't going to work anyway.  Maybe another APM_ config
option.  (Nobody will notice another one!)

Secondly, where exactly is the kernel likely to be?  Is the kernel
likely to be clobbered by the apm bios, or will uvm fail to remap
the kernel memory for the data segment and apm safely fail?

	-- Gregory McGarry <g.mcgarry@qut.edu.au>