Why does the kernel have a separate virtual address for the custom page?

I am confused by this statement:

From http://web.stanford.edu/class/cs140/projects/pintos/pintos_4.html#SEC63 :

In Pintos, each custom virtual page has an alias for its virtual core page.

I thought the kernel would be able to just use the user's virtual address to link to the user page, with the kernel's virtual addresses above it. For example, the image below will not have the entire VAS just 0 to 4 GB, and the user's virtual address space will be limited to addresses below PHYS_BASE, while the kernel can also access addresses above it?

virtual memory map
(from http://web.stanford.edu/class/cs140/cgi-bin/section/10sp-proj3.pdf )

This doesn't seem to be how it works, as the PintOS documentation continues:

You have to manage these aliases somehow. For example, your code can check and update the available and dirty bits for both addresses. Alternatively, the kernel could avoid the problem of passing user data through the user's virtual address.

This means that the kernel can access user data through a separate kernel virtual address. I'm not sure why the two addresses would be different.

Thanks for any clarification.

+3


source to share


1 answer


To access a page, it needs to be mapped in the current virtual address space.

So, if the kernel wants to access the user page, there are 2 solutions:



  • Map the page in our current address space, the kernel address space, and make sure the entries in the table of the two pages stay the same (you don't need to keep them consistent all the time, but you really want to).
  • Switch to address space where this page is already displayed, custom address space

The kernel seems to pick option 1, which is good for performance. Switching to another address space and back takes a lot of time. He could choose option 2 instead and switch to a custom address space every time he wants to access the user's page, this might simplify the code by avoiding some of the bookkeeping operations, but that would be terribly slow.

+1


source







All Articles