Using gdb
Looking at the backtrace output, which function called syscall?
可以看到是trap.c中usertrap函数调用了syscall函数
What is the value of p->trapframe->a7 and what does that value represent?
p->trapframe->a7的值为7,代表了函数sys_exec在数组syscalls中的索引值
What was the previous mode that the CPU was in?
sstatus值为0x22,翻译成二进制是100010,第8位SPP为0
说明进入supervisor mode之前是user mode
Write down the assembly instruction the kernel is panicing at. Which register corresponds to the variable num?
可以看到num对应于a3寄存器
Why does the kernel crash? Hint: look at figure 3-3 in the text; is address 0 mapped in the kernel address space? Is that confirmed by the value in scause above?
scause的值为0x0d,也就是十进制13,表示Load page fault
在RISC-V中有效地址从0x80000000开始,地址0x0是无效的