Lab2: system calls

环境搭建:解决不存在riscv64-linux-gnu-gdb的问题

  • 窗口1运行:make qemu-gdb
    • 这里会有一个端口号,如tcp::26000
  • 窗口2运行:gdb-multiarch
    • 先回车,再执行target remote localhost:26000即可

Using gdb

Looking at the backtrace output, which function called syscall?

image.png

What is the value of p->trapframe->a7 and what does that value represent? (Hint: look user/initcode.S, the first user program xv6 starts.)

image.png
image.png

What was the previous mode that the CPU was in?

  • 通过(gdb) p /x $sstatus得到sstatus寄存器的值为0x22,在书riscv-privileged-20211203的64页找到如下描述
    • image.png
    • The SPP bit indicates the privilege level at which a hart was executing before entering supervisor mode. When a trap is taken, SPP is set to 0 if the trap originated from user mode, or 1 otherwise.
    • image.png
    • 0x22=0b00100010,可见SPP及以前的位数空缺,补零,即SPP为0,所以为User Mode

Write down the assembly instruction the kernel is panicing at. Which register corresponds to the varialable num?

  • image.png
  • image.png
  • image.png

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? (See description of scause in RISC-V privileged instructions)

  • 0xd=13
  • image.png|325
  • image.png|425
  • The kernel crashed due to loading an unused memory data at address 0. As we can see from Figure 3.3, address 0 does not map into kernel space. The abnormal code in scause is 0xd(13), corresponding to the “Load page fault”, which confirms the above view.

What is the name of the binary that was running when the kernel paniced? What is its process id (pid)?

image.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值