Read-only pages in ring 0
Posted: Sat Jun 06, 2009 10:35 am
Hi,
I've lurked these forums for too long, so here is a question, a thing that puzzles me.
I've setup basic identity-mapped paging. I use a page directory, where the first entry points to a page table. The page table identity maps the first 4 MB. I think it works (sort of), because if I mark a page Not Present and try to access it, it triple-faults. Also Bochs debugger tells me the right mapping by "info tab".
I want to map some pages read-only (the kernel .text/.rodata sections and the BIOS area except 0xB8000-0xB8FFF for text screen output). However when I do so they are still writable. I tried combinations of the Read/Write bit in the page directory and the page table, but I see no effect. I tested in QEMU and Bochs. They show the same behavior. Is it because I'm in ring 0 and this causes every page to be read-write without regard to the flag? Or is it because QEMU and Bochs doesn't pay attention to the flag? I haven't tested it on a real computer. Maybe I have to enable some bit in CR4?
I'll continue searching the web, but if you can provide some hints it would be nice.
I've lurked these forums for too long, so here is a question, a thing that puzzles me.
I've setup basic identity-mapped paging. I use a page directory, where the first entry points to a page table. The page table identity maps the first 4 MB. I think it works (sort of), because if I mark a page Not Present and try to access it, it triple-faults. Also Bochs debugger tells me the right mapping by "info tab".
I want to map some pages read-only (the kernel .text/.rodata sections and the BIOS area except 0xB8000-0xB8FFF for text screen output). However when I do so they are still writable. I tried combinations of the Read/Write bit in the page directory and the page table, but I see no effect. I tested in QEMU and Bochs. They show the same behavior. Is it because I'm in ring 0 and this causes every page to be read-write without regard to the flag? Or is it because QEMU and Bochs doesn't pay attention to the flag? I haven't tested it on a real computer. Maybe I have to enable some bit in CR4?
I'll continue searching the web, but if you can provide some hints it would be nice.