Intel Manual Questions
Posted: Fri Jun 08, 2007 11:02 am
...
Thanks everyone,
Lster
Thanks everyone,
Lster
The Place to Start for Operating System Developers
http://f.osdev.org/
#PF is an exception, specifically the page fault exception (number 14). When an exception is triggered (jn pmode), the processor looks up the exception handler in the IDT. The exact mechanism is described in 3A:5.12.1. Certain exceptions, however, have what is called an error code. Specifically, these are numbers 8, 10, 11, 12, 13, 14 and 17.Lprogster wrote:1. What is the idea with #PF(0) and #PF(fault code)? What do they represent - I found the intel manual a bit unclear...
Generally not, although some people do use them and I have no problem with that. Segmentation is pretty much obsolete in 64-bit long mode, however.Lprogster wrote:2. LDTs aren't used generally any more are they? Are TSSs used in software task-switching?
Only code segments can be conforming.Lprogster wrote:3. What is a conforming segment?
Yes, the user/supervisor bit in a page table entry merely defines access rights for that page - whether currently running code can access it depends on the CPL.Lprogster wrote:When using paging, are segments still used to determine the PL of the current application?
Segments are of two types, either code/data segments or system segments. If S is clear (unlike what I said above ) then it is a system segment. If S is set it is a code or data segment.Lprogster wrote:1. (In 3.4.5.1) Could you explain the S flag - I found the intel manual a bit confusing here...
The D/B flag tells the processor what type of code or data to expect in a segment. If you set it for a code segment, then it expects 32-bit code (e.g. references to ax actually refer to eax), such as the code produced by gcc. If it is clear for a code segment, then the processor expects 16-bit code such that references to ax do point to ax - if you want to use eax from a 16-bit pmode code segment you need to use a register size prefix, which is described (I think) at the start of the second volume (the assembly bit).Lprogster wrote:2. (Also in 3.4.5.1) I really don't understand the D/ B flag. It appears that I should just set it (to 1) and forget about it - would this be OK or will I need to use it for more advance things?
Close. A selectors RPL is made up by the lowest two bits of that selector value. This includes code selectors(yes you can use a CS with different values for RPL/CPL and DPL). Since a segment selector contains separate fields for descriptor index and RPL you can mix them at will. That includes having two selectors pointing to the same descriptor with different RPLs.The RPL is the first two bits of a segment register (except cs?). Does that mean there can be many different RPLs at once? (for example: ds = 11h and es = 12h.)
In addition to checking segment limits, the processor also checks descriptor table
limits. The GDTR and IDTR registers contain 16-bit limit values that the processor
uses to prevent programs from selecting a segment descriptors outside the respec-
tive descriptor tables. The LDTR and task registers contain 32-bit segment limit value
(read from the segment descriptors for the current LDT and TSS, respectively). The
processor uses these segment limits to prevent accesses beyond the bounds of the
current LDT and TSS. See Section 3.5.1, “Segment Descriptor Tables,â€