Jos-lab2(Exercise 5)

13 篇文章 0 订阅
10 篇文章 0 订阅

Question

2. What entries (rows) in the page directory have been filled in at this point? What addresses do they map and where do they point? In other words, fill out this table as much as possible:

  1. EntryBase Virtual AddressPoints to (logically):
    10230xfffc00000Page table for top 4MB of phys memory
    10220xfff800000?
    .??
    .??
    .??
    20x00800000?
    10x00400000?
    00x00000000[see next question]

     

3. (From Lecture 3) We have placed the kernel and user environment in the same address space. Why will user programs not be able to read or write the kernel's memory? What specific mechanisms protect the kernel memory?

参考mem_init()里的最后一段code,关于控制寄存器cr0~cr3的作用参考i386手册的4.1.3。

在这之前,paging机制没有打开,也就是说虚拟地址va一次转换就成了pa,pa = la = va - KERNBASE, 在这之后,就要通过cr3里存放的pgdir地址来映射查找物理地址。

 225         // Switch from the minimal entry page directory to the full kern_pgdir
 226         // page table we just created.  Our instruction pointer should be
 227         // somewhere between KERNBASE and KERNBASE+4MB right now, which is
 228         // mapped the same way by both page tables.
 229         //
 230         // If the machine reboots at this point, you've probably set up your
 231         // kern_pgdir wrong.
 232         lcr3(PADDR(kern_pgdir));
 233
 234         check_page_free_list(0);
 235
 236         // entry.S set the really important flags in cr0 (including enabling
 237         // paging).  Here we configure the rest of the flags that we care about.
 238         cr0 = rcr0();
 239         cr0 |= CR0_PE|CR0_PG|CR0_AM|CR0_WP|CR0_NE|CR0_MP;
 240         cr0 &= ~(CR0_TS|CR0_EM);
 241         lcr0(cr0);
 242

4. What is the maximum amount of physical memory that this operating system can support? Why?

参考pgdir所能映射的地址大小。

5. How much space overhead is there for managing memory, if we actually had the maximum amount of physical memory? How is this overhead broken down?

sizeof(pgdir) + sizeof(page table) * 1024, a little bit more than 4MB.

6. Revisit the page table setup in kern/entry.S and kern/entrypgdir.c. Immediately after we turn on paging, EIP is still a low number (a little over 1MB). At what point do we transition to running at an EIP above KERNBASE? What makes it possible for us to continue executing at a low EIP between when we enable paging and when we begin running at an EIP above KERNBASE? Why is this transition necessary?


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值