NASM Forum > Programming with NASM

What exactly is the structure of an LDT entry?

(1/3) > >>

ben321:
I know what GDT entries look like as they can be seen here https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/SegmentDescriptor.svg/1024px-SegmentDescriptor.svg.png (though the byte order needs to be swapped for actual usage, going from bottom right on that diagram to upper left, as x86 is a little-endian CPU). What I don't know though is what is the structure of an LDT entry. I know that I need to allocate memory for the LDT in the GDT, and then use the LLDT instruction to tell the CPU which GDT entry points to the memory used by the LDT. But I don't know the actual structure of the LDT entries. If anybody has a good diagram for that, please post it here. Thanks in advance.

fredericopissarra:
Intel Software Developement Manuals, volume 3.

ben321:

--- Quote from: fredericopissarra on February 15, 2023, 02:54:31 PM ---Intel Software Developement Manuals, volume 3.

--- End quote ---

I'm trying to write down the most useful info from that manual regarding segments and the GDT and LDT, into a nice HTML file that summarizes this info in a way I can understand it and use it for actually programming something. Below are 3 statements I've written about conforming and non-conforming code sections, based on my understanding of what I read in the manual. Can you tell me if I got any of this incorrect? I don't want to write down bad info.

--- Quote ---If a code segment is conforming, it means that code from a lower privilege segment (higher DPL number) can far-jump into that higher privilege segment (lower DPL number).
If a code segment is not conforming, it means that only code from a segment that has the same privilege level (same DPL number) can far-jump into it.
In no case can code in a segment with higher privilege (such as kernel code) far-jump into a segment with lower privilege (such as an application).
--- End quote ---

I'm questioning if this is accurate because something seems off about it. I mean the operating system (kernel level) is in fact responsible for starting applications (user-mode level). That's what happens when you double-click on an EXE file. The OS runs your application. So I think I need some clarification about what conforming code means, because I think I may have misinterpreted what the Intel manual says.

fredericopissarra:

--- Quote from: ben321 on February 17, 2023, 09:45:37 AM ---
--- Quote ---If a code segment is conforming, it means that code from a lower privilege segment (higher DPL number) can far-jump into that higher privilege segment (lower DPL number).
If a code segment is not conforming, it means that only code from a segment that has the same privilege level (same DPL number) can far-jump into it.
In no case can code in a segment with higher privilege (such as kernel code) far-jump into a segment with lower privilege (such as an application).
--- End quote ---

--- End quote ---
Which page is this? In 3.4.5.1 it is clear that:

--- Code: ---Execution cannot be transferred by a call or a jump to a less-privileged (numerically higher
privilege level) code segment, regardless of whether the target segment is a conforming or
nonconforming code segment. Attempting such an execution transfer will result in a general-
protection exception.[/quote]
--- End code ---

ben321:

--- Quote from: fredericopissarra on February 17, 2023, 11:45:56 AM ---Which page is this?

--- End quote ---
It's not from any page. If you read my post, you would see I was basically taking notes from what I was reading in the manual. I was (for my own use) writing a summary of what I was reading in the manual, in order to provide myself a much smaller reference than the manual, while still providing usable info for my programming. My summary obviously doesn't contain exact quotes from the manual.

I was just writing about it here to make sure my understanding of what the manual was saying was in fact correct. I didn't want to write down summary info for myself, if my summary was based on any misunderstanding of what the manual was saying. I didn't want to write down or commit to memory, any misunderstandings of what was in the manual, because that would result in me writing buggy software.

Navigation

[0] Message Index

[#] Next page

Go to full version