I am working on a small OS that will use a separate local descriptor table for each process. I understand that I will need to use the lldt to load the LDT segment from my GDT. I already have my kernel working in protected mode with a valid GDT, but I cannot figure out what the GDT record should look like for my LDT. I understand that its base address should point to my LDT, but I do not know what the privilege level and other attributes should be. Here is the NASM code that represents the LDT entry in my GDT:
localTable equ $-gdt ; GDT entry
If you are not familiar with NASM syntax, this table entry has a base address of 0x8000 and a limit of 511 (a total of 512 bytes or 64 entries). I read the section on GDT and LDT in the i486 programmer's reference manual, but I cannot completely understand how my GDT record should look.
Anyway, I load LDT like this:
mov ax, 0x20 lldt ax
This code causes the processor to generate a general security error (I process it interruptively). I would like to know two things:
1) Did I correctly describe my LDT in GDT? If not, what needs to be changed? 2) Can the lldt command fail because there is an invalid selector in my LDT itself? I read the specification of the LLDT instruction and it seems to me that it does not even read LDT memory, but I just want to be sure that LLDT does not fail, because I have a typo in my LDT data.
source share