chipsalliance / dromajo

RISC-V RV64GC emulator designed for RTL co-simulation
Apache License 2.0
213 stars 63 forks source link

Can't boot Linux anymore #13

Closed et-tommythorn closed 4 years ago

et-tommythorn commented 4 years ago

@abejgonzalez, this change

commit d8689621645be0270f324cdac3c5778f4628def3 Author: abejgonzalez abe.j.gonza@gmail.com Date: Mon Nov 18 16:53:43 2019 -0800

Update for Cosimulation (Parameter Overrides + Misc. Cleanup

broke the Linux booting example in run.

Prior it booted the OpenSBI and kernel as expected, after the change we get

riscv_cpu_write_memory: invalid physical address 0x0000000010000004
sbi_trap_error: hart0: page/access fault handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000010000004
sbi_trap_error: hart0: mepc=0x0000000080006f18 mstatus=0x8000000a00007800
sbi_trap_error: hart0: ra=0x00000000800031d4 sp=0x0000000080014d60
sbi_trap_error: hart0: gp=0x0000000000000000 tp=0x0000000080014e00
sbi_trap_error: hart0: s0=0x0000000080014d70 s1=0x0000000000000000
sbi_trap_error: hart0: a0=0x0000000010000004 a1=0x0000000000000035
...
abejgonzalez commented 4 years ago

Interesting. I've been able to boot Linux in co-simulation consistently (though not the example kernel in the repository). I'll try to take a look at this later today.

ss2783 commented 4 years ago

I am currently seeing this with the latest master:

[    0.002244] pid_max: default: 32768 minimum: 301
[    0.002910] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.003302] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 8796.091429] Unable to handle kernel NULL pointer dereference at virtual address 00000000000005dc
[ 8796.091852] Oops [#1]
[ 8796.091997] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W         5.3.0 #1
[ 8796.092359] sepc: ffffffe000423ca6 ra : ffffffe000284fc4 sp : ffffffe0004a1ed0
[ 8796.092721]  gp : ffffffe0004c0ce8 tp : ffffffe0004a7cc0 t0 : ffffffe03af95f3c
[ 8796.093081]  t1 : 0000000000000002 t2 : 00000000000003cd s0 : ffffffe0004a1ee0
[ 8796.093443]  s1 : ffffffe0004f0658 a0 : 0000000200000022 a1 : ffffffe0004a1f30
[ 8796.093801]  a2 : 0000000000000000 a3 : 0000000000000001 a4 : 00000000000005dc
[ 8796.094160]  a5 : 0000000000000008 a6 : 0000000000010000 a7 : 0000000000000000
[ 8796.094520]  s2 : ffffffe0004a1f30 s3 : 00000000000005dc s4 : 0000000000000002
[    0.001857]  s5 : 0000000000000000 s6 : 0000000000000000 s7 : ffffffe000265080
[    0.002216]  s8 : ffffffe0002601f8 s9 : 0000000000000000 s10: 0000000000000000
[    0.002576]  s11: 0000000000000000 t3 : 0000000000000402 t4 : ffffffe0004ae130
[    0.002930]  t5 : 0000000000000040 t6 : 00000000000003ff
[    0.003204] sstatus: 0000000200000100 sbadaddr: 00000000000005dc scause: 000000000000000d
[    0.003621] ---[ end trace 6da6143e95f213ce ]---
[ 8796.090329] Kernel panic - not syncing: Attempted to kill the idle task!
[ 8796.090672] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
et-tommythorn commented 4 years ago

Thanks! I should have run it to the end.

abejgonzalez commented 4 years ago

PR #14 solves part of this problem. However, the commit that seems to cause the next error seems to be c87251432897d665bf0767bbf45a8ce61b3a36e1 @ss2783. Here is what the log output looks like before the error. Note that the printk line diverges from what is expected.

image

ss2783 commented 4 years ago

@et-tommythorn and @abejgonzalez please check PR #15

Linux should be booting now. I picked the changes proposed in PR #14 as well to get this all working. Basically, I messed up two things (a) masks for clint reads/writes (b) enforcing dut marked pending interrupt checks to handle interrupts when actually executing in standalone mode. I added a flag to differentiate cosim vs. standalone mode.

et-tommythorn commented 4 years ago

It's still broken, starting with d8689621645be0270f324cdac3c5778f4628def3. I created a repo with a binary version of the kernel:

$ git clone git@github.com:chipsalliance/dromajo
$ git clone git@github.com:chipsalliance/dromajo-test
$ cd dromajo
$ git checkout v1.0
$ make -C src
$ src/dromajo ../dromajo-test/boot.cfg 

OpenSBI v0.5 (Dec 13 2019 21:44:52)
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
...
Welcome to Dromajo Buildroot
buildroot login: 

This is what is expected. It hasn't worked for a while now.

We need a CI test based on this.

et-tommythorn commented 4 years ago

Fixed via 983be07b9894dc90370a92e3e17217baa710eb37