user3230774
user3230774

Reputation: 21

Address of gdtr in Linux

I am not clear about the address of gdtr.

from the book "Understanding The Linux Kernel". 2.2.2 Segment Descriptor( page 38)


"The address of the GDT in main memory is contained in the gdtr processor register and the address of the currently used LDT is contained in the ldtr processor egister."


My question: is the address in gdtr logical address/linear address or physical address?

I think it should be physical address, because paging has not implemented before that. Need someone help to confirm it and provide better explanation

Another question about paragraph: book "Understanding The Linux Kernel". 2.2.4 Segment Linux (page 43).


For each process, therefore, the GDT contains two different Segment Descriptors: one for the TSS segment and one for the LDT segment. The maximum number of entries allowed in the GDT is 12+2xNR_TASKS, where, in turn, NR_TASKS denotes the maximum number of processes.where, in turn, NR_TASKS denotes the maximum number of processes. In the previous list we described the six main Segment Descriptors used by Linux. Four additional Segment Descriptors cover Advanced Power Management (APM) features, and four entries of the GDT are left unused, for a grand total of 14.


12+2xNR TASKS, where does the 12 come from? I think it should be 14 as "In the previous list we described the six main Segment Descriptors used by Linux. Four additional Segment Descriptors cover Advanced Power Management (APM) features, and four entries of the GDT are left unused, for a grand total of 14."

I might misunderstand something, please help to make me clear.

Thanks, $XSM

Upvotes: 2

Views: 1182

Answers (3)

Tokubara
Tokubara

Reputation: 470

I want to say why GDTR must be linear address. Because there is an instruction lgdt, that means programmers can set GDTR. But as physical address is invisible to programmers, then GDTR must be linear address.

Upvotes: 0

Hds
Hds

Reputation: 31

The Intel manual(64-ia-32-architectures-software-developer-vol-3a-part-1-manual) says that the linear address of GDT is stored in the GDTR register, and the linear address of LDT is stored in the LDTR register。

enter image description here

Upvotes: 3

syed
syed

Reputation: 183

I believe the address is a linear address. Paging is turned on in startup_32() just after the segment registers (ds, es, fs, gs) are set to a known value (0x18 for i386). The page directory is located at 0x00101000 (also called swapper_pg_dir). Initialization of GDT and IDT comes way after paging is setup.

For more information, you can look at the source listing here

Upvotes: 0

Related Questions