"Kirk True" <ktrue@movaris.com> writes: > Hi Ed, > >> For example, if the kernel tries to write through an invalid pointer, >> you get something predictable like an oops. That's because the MMU >> catches the invalid address, even though the CPU is in superuser mode. >> Then do_page_fault runs and handles the kernel bug. > > So the kernel uses paging too? What is the reason/benefit for doing > so? To me it seems the above scenario is a huge benefit. Instead of unpredictable things happenning in hardware and software, you get a helpful bug message and the system (or part of it) stops before it can do harm. > Is it so the kernel doesn't have to turn paging off and on when > going back and forth between kernel and user mode? I don't know whether that would be practical. I wouldn't want to use an O.S. like that because kernel bugs would be too dangerous. >> I don't think you can do this: >> >> *(__pa(p)) = 100; >> >> ... because (in lowmem x86), that __pa macro is going to subtract >> 0xc0000000 from the (virtual) address, meaning that it's now a >> userland address! > > But the addresses from pgd_offset and pmd_offset don't call __va() before > returning the value, so that means what they return is a physical address, > right? It's all virtual addresses. The usual case is for kernel pointers to be virtual addresses. There are exceptions, of course, but the return values of pgd_offset and pmd_offset are not among them. You can tell by the way they're used: the value returned by them is assigned to regular pointer variables and dereferenced normally. >> It's not magic. The translations for addresses greater than >> 0xC0000000 are in the TLB and the page tables just like the others. > > Where is this set up? Is it in head.S? I mentioned that in the last email: > The kernel's page tables are set up in pagetable_init in > arch/i386/mm/init.c. The kernel's "pgd" is swapper_pg_dir. ... but I haven't looked at it much. Maybe I'm wrong. I wonder why the list is so quiet. I didn't think OLS was going on yet. -- --Ed L Cashin PGP public key: http://noserose.net/e/pgp/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/