Subject: port-ofppc/14497: OF_buf isn't in OF address space
To: None <>
From: None <>
List: netbsd-bugs
Date: 11/07/2001 13:02:55
>Number:         14497
>Category:       port-ofppc
>Synopsis:       OF_buf isn't in OF address space
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-ofppc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 07 13:04:00 PST 2001
>Originator:     Andrew Cagney
>Release:        1.5.2 userland, current kernel
NetBSD localhost 1.5Y NetBSD 1.5Y (NETLUX) #1: Thu Nov  1 05:53:32 EST 2001     boor@localhost:/usr/src/sys/arch/macppc/compile/NETLUX macppc

The OFPPC locore.s files both allocate space for OF_buf by extending the .bss section by one page.

This only works if the OpenFirmware has 1:1 mapped all of memory.  PSIM doesn't do this so that 4k page of memory isn't in the VM shared by the kernel and OF.

The code could instead:
  - claim() the memory using an OF call
  - shove the page into the .bss so it is part of the kernel and is already mapped in.

I suspect NetBSD/MacPPC has a similar problem.

bash-2.04# gdb netbsd.gdb 
GNU gdb 2001-11-06-cvs
This GDB was configured as "powerpc-apple-netbsd1.5X"...
(gdb) target sim -r 0x400000 -t os-emul
Connected to the simulator.
(gdb) load
chirp: note descriptor missing load-base
(gdb) run
Starting program: /usr/src/sys/arch/ofppc/compile/GENERIC/netbsd.gdb 
emul_chirp.c:1982: finddevice called from 0x287898 with args 0x2bad0c
emul_chirp.c:718: finddevice - in - device_specifier=`/chosen'
emul_chirp.c:729: finddevice - out - phandle=0x4(0x1c0c380`chosen')
emul_chirp.c:1982: getprop called from 0x287898 with args 0x2bacd0
emul_chirp.c:518: getprop - in - phandle=0x4(0x1c0c380`chosen') name=`stdin' buf=0x2ef000 buflen=4
cpu 1, cia 0x80004000: double interrupt - MSR[RI] bit clear when attempting to deliver interrupt, cia=0x80004000, msr=0x30; srr0=0x0(cia), srr1=0x0(msr); trap-vector=0x300, trap-msr=0x0

Program terminated with signal ?, Unknown signal.
The program no longer exists.
[Switching to process 0]

The hack below works.

bash-2.04# diff -c locore.S fixed-locore.S 
*** locore.S    Wed Nov  7 15:43:45 2001
--- fixed-locore.S      Fri Oct 26 21:25:01 2001
*** 77,82 ****
--- 77,86 ----
        .long   0                       /* openfirmware entry point */
+       .section .bss
+ OF_buffer:    
+       .space 0x1000
   * This symbol is here for the benefit of kvm_mkdb, and is supposed to
   * mark the start of kernel text.
*** 146,151 ****
--- 150,158 ----
        li      9,PGOFSET
        add     8,8,9
        andc    8,8,9
+ /*   having worked all this out just ignore it.  */
+       lis     8,OF_buffer@ha
+       addi    8,8,OF_buffer@l
        lis     9,_C_LABEL(OF_buf)@ha
        stw     8,_C_LABEL(OF_buf)@l(9)
        addi    8,8,NBPG