Are GDT addresses logical or physical when paging is on?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
GMorgan
Posts: 22
Joined: Sun Jul 14, 2019 4:27 pm

Are GDT addresses logical or physical when paging is on?

Post by GMorgan »

Hi Guys,

Are GDT addresses logical or physical once paging is enabled?

I've been looking for an answer to this as most sources just say "address" and don't tell you if that is relative to the real memory position or in the logical space. I'm looking for the best way to control port access to user space drivers in a micro kernel and I'm thinking about having the OS map different IOPB pages for each process depending upon what ports have been granted access (rather than have a TSS for every process that needs its own IOPB). The idea being that the kernel will map all ports other than what it needs to sigma0 on startup. Any process that owns a port can pass it to another process via a syscall. Sigma0 accepts requests from the root task to transfer ports (so the root task kicks off the serial port driver and immediately requests all the ports for that process). All dead processes get their ports allocated back to sigma0.

Obviously this only works to begin with if the GDT offset is into the current logical space and not into the physical one.

Thanks in advance.
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Are GDT addresses logical or physical when paging is on?

Post by alexfru »

GMorgan wrote:Are GDT addresses logical or physical once paging is enabled?
Virtual (in segment descriptors and GDTR). LGDT still takes a logical address (which then translates into virtual and so on).
GMorgan
Posts: 22
Joined: Sun Jul 14, 2019 4:27 pm

Re: Are GDT addresses logical or physical when paging is on?

Post by GMorgan »

Thanks. This raises the question of what the difference between a logical and virtual address is. Does logical contain a segment and a pointer?
Octocontrabass
Member
Member
Posts: 5581
Joined: Mon Mar 25, 2013 7:01 pm

Re: Are GDT addresses logical or physical when paging is on?

Post by Octocontrabass »

GMorgan wrote:Are GDT addresses logical or physical once paging is enabled?
There's no such thing as a "logical" address in x86. Maybe you're thinking of linear addresses?

Segmentation is used to translate from virtual to linear addresses, and paging is used to translate from linear to physical addresses. This means addresses in the GDT and GDTR will be linear addresses.
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Are GDT addresses logical or physical when paging is on?

Post by alexfru »

Octocontrabass wrote:There's no such thing as a "logical" address in x86.
There is.
Section 3.3.1 IA-32 Memory Models of Intel® 64 and IA-32 Architectures Software Developer’s Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D and 4 wrote: To address a byte in a segment, a program issues a logical address. This consists of a segment selector and an offset (logical addresses are often referred to as far pointers).
Octocontrabass
Member
Member
Posts: 5581
Joined: Mon Mar 25, 2013 7:01 pm

Re: Are GDT addresses logical or physical when paging is on?

Post by Octocontrabass »

Whoops, that's what I get for reading too many MIPS manuals.

Segmentation is used to translate from logical to linear addresses, and paging is used to translate from linear to physical addresses.

There's no such thing as virtual addresses in x86. ;)
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Are GDT addresses logical or physical when paging is on?

Post by alexfru »

Octocontrabass wrote:There's no such thing as virtual addresses in x86. ;)
You'll be surprised.
Post Reply