[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linux/i386 mm



Lorenzo Allegrucci wrote:
> 
> At 17.02 03/02/01 -0700, you wrote:
> >My MM notes, at the moment covering only initialization and the
> >zone allocator, are now available at:
> >
> >http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html
> >
> >Comments are welcome.
> 
> I have some questions:
> 
> - On your MM notes you say:
> >Apparently kernel virtual memory must map all of physical memory. Why?
> >Must be so that kernel code can access any page. OK, so why is PAGE_OFFSET
> >so large? Why not just make it 4K? Hypothesis: all processes are going to
> >share (at least in kernel mode) the mapping starting at PAGE_OFFSET.
> >That means that if user processes are going to have address space starting
> >at 0, PAGE_OFFSET has to be big enough to allow some room for user-mode
> >addresses. There's no reason user processes couldn't have a totally
> >separate address mapping from the kernel, and both could start at low
> >addresses; but that would make it a pain for the kernel to access
> >user-space memory, and would mean that entry into the kernel would
> >require icky page-table manipulation.
> 
> Why would mean that entry into the kernel would require icky page-table
> manipulations? A simple switch of cr3 to the user page table
> (and vice versa) wouldn't be enough?

That would still be icky. Reloading cr3 is expensive I think (forces
unnecessary TLB flush, etc). Also, kernel would need to do tricks
to map user pages when copying user data in and out of kernel
space. Icky.
 
> - From head.S:
> /*
>  * Enable paging
>  */
> 3:
>         movl $swapper_pg_dir-__PAGE_OFFSET,%eax
> 
> At this point paging is not enabled yet (it will in the next lines)
> so we are working with physical addresses.
> If $swapper_pg_dir already has physical address 0x00101000 and cr3 is
> loaded with physical addresses, why compute $swapper_pg_dir-__PAGE_OFFSET?

I think swapper_pg_dir is the address the kernel sees its page
directory at after paging is enabled, so it's really
PAGE_OFFSET+0x00101000.

Regards,

-- Joe Knapka
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.surriel.com/kernelnewbies.shtml