Page 1 of 1
GDT and IDT with application paging.
Posted: Sun Sep 21, 2008 2:50 pm
by andypatterson
Hi,
I am currently writing a kernel which is to use a separate linear address space (i.e. a different page directory) for each application. All over the internet tutorials say this allows applications to appear as if they are the only process on the machine. This is all well and good, but wouldnt changing the page directory for the new application mean that the GDT and IDT would stop working, as these memory locations are specified by linear addresses? If so, does this mean the GDT and IDT need to be present in the application's linear address space?
Re: GDT and IDT with application paging.
Posted: Sun Sep 21, 2008 3:32 pm
by ru2aqare
andypatterson wrote:Hi,
I am currently writing a kernel which is to use a separate linear address space (i.e. a different page directory) for each application. All over the internet tutorials say this allows applications to appear as if they are the only process on the machine. This is all well and good, but wouldnt changing the page directory for the new application mean that the GDT and IDT would stop working, as these memory locations are specified by linear addresses? If so, does this mean the GDT and IDT need to be present in the application's linear address space?
The GDTR and IDTR specify physical memory locations (which are no affected by any form of paging). The descriptors in the GDT and IDT specify virtual address ranges, to which paging translation is applied. So when you change to a new task (or process), and reload the segment registers from the TSS (if you use hardware multitasking) or some structure maintained by the kernel, the processor accesses memory specified by the GDTR and IDTR registers. I think the GDT and IDT need not be present in the application's address space, but I haven't gotten that far to test that.
Re: GDT and IDT with application paging.
Posted: Sun Sep 21, 2008 4:29 pm
by geppy
ru2aqare wrote:
The GDTR and IDTR specify physical memory locations (which are no affected by any form of paging).
you are contradicting yourself
http://forum.osdev.org/viewtopic.php?p=136854#p136854
ru2aqare wrote:
The GDTR contains the linear address and the limit of the GDT.
Re: GDT and IDT with application paging.
Posted: Mon Sep 22, 2008 12:00 am
by egos
andypatterson wrote:Hi,
I am currently writing a kernel which is to use a separate linear address space (i.e. a different page directory) for each application. All over the internet tutorials say this allows applications to appear as if they are the only process on the machine. This is all well and good, but wouldnt changing the page directory for the new application mean that the GDT and IDT would stop working, as these memory locations are specified by linear addresses? If so, does this mean the GDT and IDT need to be present in the application's linear address space?
You must map GDT and IDT into all virtual address spaces with same addresses. The kernel and all its global structures must are placed in global memory region(s).
Re: GDT and IDT with application paging.
Posted: Mon Sep 22, 2008 2:11 am
by ru2aqare
geppy wrote:ru2aqare wrote:
The GDTR and IDTR specify physical memory locations (which are no affected by any form of paging).
you are contradicting yourself
http://forum.osdev.org/viewtopic.php?p=136854#p136854
ru2aqare wrote:
The GDTR contains the linear address and the limit of the GDT.
Sorry about that. I checked the Intel Manuals and they state that the GDTR contains linear addresses. My bad.
Re: GDT and IDT with application paging.
Posted: Mon Sep 22, 2008 3:34 am
by Combuster
You don't need to map the same tables to every address space. It may even be worth it to not do so. Like if you have a different TSS per address space, you would give each separate address space a separate I/O permission bitmap, so you can regulate port accesses on a per-process basis. You can use different IDTs to have some exceptions be handled in userland (like the overflow and bound exceptions, emulating *nix' int 0x80). And for the Segmentation fans, you can have a different GDT for programs that wish to use both segmentation and paging at the same time too.