xv6-lab/answers-syscall.txt
2023-01-06 21:45:16 +08:00

17 lines
1.1 KiB
Plaintext

Q: Looking at the backtrace output, which function called syscall?
A: usertrap
Q: What is the value of p->trapframe->a7 and what does that value represent?
A: a7 is 0x7. It represents the number of syscall SYS_exec.
Q: What was the previous mode that the CPU was in?
A: $sstatus is now 0x22, which is 0b0000_0010_0010, with SPP(bit-8) 0, so its previous privilege is User Mode.
Q: Write down the assembly instruction the kernel is panicing at. Which register corresponds to the varialable num?
A: The kernel is panicing at instruct `lw a3,0(zero)` at 0x80001ff6. The register corresponding to the variable num is a3.
Q: 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?
A: $scause is 0xd(13) which corresponds to 'Load page fault'. According to figure 3-3, this address is not mapped in the kernel address space, so this causes page fault.
Q: What is the name of the binary that was running when the kernel paniced? What is its process id (pid)?
A: The name of the binary is "initcode", and its pid is 1.