On Sun, 19 May 2024, Andrew Randrianasulu wrote:
> On Sun, May 19, 2024 at 1:46 PM BALATON Zoltan <balaton@eik.bme.hu> wrote:
>> On Sun, 19 May 2024, BALATON Zoltan wrote:
>>> On Sun, 19 May 2024, BALATON Zoltan wrote:
>>>> On Sun, 19 May 2024, Andrew Randrianasulu wrote:
>>>>> сб, 18 мая 2024 г., 23:33 BALATON Zoltan <balaton@eik.bme.hu>:
>>>>>
>>>>>> On Sat, 18 May 2024, Andrew Randrianasulu wrote:
>>>>>>> On Sat, May 18, 2024 at 11:14 PM BALATON Zoltan <balaton@eik.bme.hu>
>>>>>> wrote:
>>>>>>>
>>>>>>>> On Sat, 18 May 2024, Andrew Randrianasulu wrote:
>>>>>>>>> On Sat, May 18, 2024 at 10:24 PM BALATON Zoltan <
>> balaton@eik.bme.hu>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> On Sat, 18 May 2024, Andrew Randrianasulu wrote:
>>>>>>>>>>> Using attached patch I get this new dmesg:
>>>>>>>>>>>
>>>>>>>>>>> Quiescing Open Firmware ...
>>>>>>>>>>>>> of_client_interface: quiesce
>>>>>>>>>>>>> of_client_interface return:
>>>>>>>>>>> Booting Linux via __start() @ 0x01000000 ...
>>>>>>>>>>> Hello World !
>>>>>>>>>>> [ 0.000000] Total memory = 512MB; using 1024kB for hash table
>>>>>>>>>>> [ 0.000000] Activating Kernel Userspace Execution Prevention
>>>>>>>>>>> [ 0.000000] Activating Kernel Userspace Access Protection
>>>>>>>>>>> [ 0.000000] Linux version 5.13.12_1 (voidlinux@voidlinux)
>> (gcc
>>>>>>>> (GCC)
>>>>>>>>>> 10.2.1 20201203, GNU ld (GNU Binutils) 2.35.1) #1 SMP Thu Aug 19
>>>>>>>> 14:12:26
>>>>>>>>>> UTC 2021
>>>>>>>>>>> [ 0.000000] ioremap() called early from
>>>>>>>> pmac_feature_init+0xd4/0xad4.
>>>>>>>>>> Use early_ioremap() instead
>>>>>>>>>>> [ 0.000000] Found UniNorth memory controller & host bridge @
>>>>>>>>>> 0xf8000000 revision: 0x07
>>>>>>>>>>> [ 0.000000] Mapped at 0xf73c0000
>>>>>>>>>>> [ 0.000000] ioremap() called early from
>>>>>> probe_one_macio+0x17c/0x2b4.
>>>>>>>>>> Use early_ioremap() instead
>>>>>>>>>>> [ 0.000000] Found a Keylargo mac-io controller, rev: 0,
>> mapped at
>>>>>>>>>> 0x(ptrval)
>>>
>>> So the MACIO_OUT8 macro pokes macio->base and it's not listed here
>> unlike in
>>> the log from real machine so not sure it's writing the right address.
>> You can
>>> check witn info mtree in QEMU monitor where things appear but may need
>>> another kernel which logs thinks similar to the log you got from real
>>> machine. Does the finnix kernel work better with -append
>> debuglevel=<some
>>> number here but I don't know what's a good number". Maybe can also
>> enable
>>> openpic and macio traces to see if their regs are accessed. Something
>> like
>>> QEMU option -trace enable="macio*" maybe?
>>
>> The finnix kernel prints an address here which seems to match where mac-io
>> is mapped at. I believe the writes from smp_core99_kick_cpu() should end
>> up in QEMU's macio/gpio emulation in qemu/hw/misc/macio/gpio.c. You could
>> verify that with -trace eneable="macio*".
>
>
> It prints something like
>
> macio_nvram_read read addr=0x099e val=0x00
> macio_nvram_read read addr=0x099f val=0x00
> macio_nvram_read read addr=0x099f val=0x00
> macio_nvram_read read addr=0x09a0 val=0x00
> macio_nvram_read read addr=0x09a0 val=0x00
> macio_nvram_read read addr=0x09a1 val=0x00
> macio_nvram_read read addr=0x09a1 val=0x00
> macio_nvram_read read addr=0x09a2 val=0x00
> macio_nvram_read read addr=0x09a2 val=0x00
> macio_nvram_read read addr=0x09a3 val=0x00
> macio_nvram_read read addr=0x09a3 val=0x00
> macio_nvram_read read addr=0x09a4 val=0x00
> macio_nvram_read read addr=0x09a4 val=0x00
> macio_nvram_read read addr=0x09a5 val=0x00[ 0.000000] nvram: OF
> partition at 0xffffffff
> [ 0.000000] nvram: XP partition at 0xffffffff
> [ 0.000000] nvram: NR partition at 0xffffffff
>
> but I can't see it poking around smp init?
>
> [ 0.144619] PowerMac SMP probe found 2 cpus
> [ 0.147225] Processor timebase sync using GPIO 0x73
> [ 0.147847] mpic: requesting IPIs...
> [ 0.153859] CPU0: L2CR is 0
> [ 0.169098] rcu: Hierarchical SRCU implementation.
> [ 0.188753] smp: Bringing up secondary CPUs ...
> smp_core99_kick_cpu
> smp_core99_kick_cpu done
> [ 5.230919] Processor 1 is stuck.
> [ 5.238874] smp: Brought up 1 node, 1 CPU
>
> probably more tracing need to be added to macio.c ?
>
> Any ideas where to look for examples?
You can just add fprintf(stderr, ...) for debugging wherever you want but
in the same file there are already traces
well, I see timer traces, but for example if I want to look at writings to register not yet defined there - should I look at adding new static const MemoryRegionOps { } with my (trace only) implementation ?
so it should log if the gpio
region is accessed but maybe it does not have the right macio base for
some reason. If this is still the void Linux kernel, try with the Finnix
one, at least that seemed to find the macio base correctly.
well, this version of finnix was apparently compiled for non-smp? But I also have debian 8 ppc ....
Also add -d
unimp,guest_errors then if it accesses wrong address you may see logs
about that. (Yes, this may be a lot of logs, redirect to file so you can
analyse it afterwards.) If you need more traces look in trace-events in
the dir where the source is for a list of available trace events. See
also: https://www.qemu.org/docs/master/devel/tracing.html
> I also noticed that L2CR reg is 0 - shouldn't it represent some enabled L2
> cache on specifically PowerMacs ?
As QEMU does not emulate caches it probably does not matter (unless Linux
wants this non-0, but if it does not care this should not be a problem).
I noticed code for dealing with caches in Linux's smp.c ...
I also tried to remove "powered-off" we just added property while leaving secondary cpu reset and this hanged at very beginning before openfirmware start. This leaves me with question may be Linux do not know how to power-on secondary cpus on Powermacs. But yeah, hopefully it just missing gpio lines ... right now in gpio.c it only says about handling gpio 1/9 (9 being NMI)
Also it has this comment:
* Note that we probably need to get access to the MPIC config to
* decode polarity since qemu always use "raise" regardless.
*
* For now, we hard wire known GPIOs
*/
but I hope for testing just adding more cases like already there will be enough.
What's missing now is the Keylargo macio gpio lines to reset CPUs (after
that it probably will be interrupt routings that may need to be figured
out and fixed).
yeah, right now while finnix-110 cd starts up without openfirmware crashing it can't find itself and keyboard not working so I can't type cat /proc/interrupts :)
Just for experience I tried netbsd-10 macppc ISO
/dev/shm/qemu-9.0.0/build/qemu-system-ppc -m 1024 -M mac99,via=pmu -smp 1 -cdrom ~/ISO/NetBSD-10.0-macppc.iso -bios /dev/shm/openbios-qemu.elf -boot d -prom-env 'boot-device=cd:,ofwboot.xcf /netbsd.macppc' -nographic
====
>> 0x00770361 02 00 60 10 00 00 00 00 80 00 00 00 00 00 00 00 ..`.............
>> 0x00770371 00 08 00 00 __ __ __ __ __ __ __ __ __ __ __ __ ....
[ 1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
[ 1.0000000] 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
[ 1.0000000] 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023,
[ 1.0000000] 2024
[ 1.0000000] The NetBSD Foundation, Inc. All rights reserved.
[ 1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
[ 1.0000000] The Regents of the University of California. All rights reserved.
[ 1.0000000] NetBSD 10.0 (INSTALL) #0: Thu Mar 28 08:33:33 UTC 2024
[ 1.0000000] mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/macppc/compile/INSTALL
[ 1.0000000] total memory = 1024 MB
[ 1.0000000] oea_startup: failed to allocate DEAD ZONE: error=12
[ 1.0000000] avail memory = 978 MB
>> finddevice("/openprom") = [ 1.0000000] trap: kernel read DSI trap @ 0x3fc5a7a0 by 0xfff0bf24 (DSISR 0x40000000, err=14), lr 0xfff0bf20
[ 1.0000000] panic: trap
[ 1.0000000] trap: pid 0.0 (system): kernel ALI trap @ 0x32 by 0x117680 (DSISR 0x40000140)
[ 1.0000000] Skipping crash dump on recursive panic
[ 1.0000000] panic: trap
[ 1.0000000] rebooting
[ 1.0000000] trap: kernel read DSI trap @ 0x3fee2000 by 0x39ef80 (DSISR 0x40000000, err=14), lr 0x104fb4
[ 1.0000000] Skipping crash dump on recursive panic
[ 1.0000000] panic: trap
[ 1.0000000] rebooting
{repeats a lot}
There is some guide about booting OpenBSD, so I'll try this too
/dev/shm/qemu-9.0.0/build/qemu-system-ppc -m 512 -M mac99,via=pmu -smp 2 -nographic -kernel /mnt/tmp/boot/vmlinux -append "console=ttyPZ0 init=/bin/bash" -bios /dev/shm/openbios-qemu.elf -d guest_errors,unimp
result in
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
[ 0.000000] Invalid signature
[ 0.000000] Invalid checksum
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid read at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid read at addr 0x38, size 4, region '(null)', reason: rejected
Invalid write at addr 0x80000038, size 4, region '(null)', reason: rejected
Invalid write at addr 0x38, size 4, region '(null)', reason: rejected
I think 0x38 is KEYLARGO_FCR0 0x38 from Linux's Keylargo.h