Doubts regarding GDT/LDT

hai all,

I am a student, and please help me to clear some doubts regarding GDT an LDT. I am asking these doubts based on the NT/2000/Xp OS.

  1. According to intels’s docs both GDT and LDT contains the segment descriptors. what are the difference between descriptors in these two tables?

  2. Is GDT - contains the descriptors for the entire OS and LDT contains the descriptors for each process. If it is true when a new thread is scheduled to run, will the LDT will get a set of values specific to that process ?

  3. What are the details NT/200/xp keeps in these tables ?

  4. Is there any relation between GDT/LDT and the virtual memory management in NT/2000/xp?

Thanks,
Deepu.L.R

> 1) According to intels’s docs both GDT and LDT contains the segment
descriptors. what are

the difference between descriptors in these two tables?

No differences, except that some kinds of descriptors can occur in GDT
only.

  1. Is GDT - contains the descriptors for the entire OS and LDT
    contains the descriptors for
    each process. If it is true when a new thread is scheduled to run,
    will the LDT will get a set of
    values specific to that process ?

NT used LDT for 16bit apps only.

  1. What are the details NT/200/xp keeps in these tables ?

Some essential segments necessary for CPU to run, a segment per each
CPU and a segment for thread local storage.

  1. Is there any relation between GDT/LDT and the virtual memory
    management in
    NT/2000/xp?

No.

Max

GDT has segments descriptors which describe segments which are global to the system. You can assume these segments to be in the upper 2GB of the memory in NT, which you will be knowing won’t change from process to process.

But LDT’s are specific to a process (Eventhough segments can be shared between process, lets ignore that here).

LDT’s are formed using the data described in the .exe file, or a dll, for instance. As you know the basic segments in any exe can be code, data segments, which some times can be in multiple numbers. These form the Local segments (and hence local Desriptors) for this process and will be referenced by a Segment Descriptor each.

As u can easily make out, Segment Descriptor specifies things like starting address of the segment, length of the segment, protection on the segment etc.

GDT’s LDT’s exists irrespective of whether Virtual Memory is present or not. For ex, if virtual memory is not used, the address obtained after Segment Translation is the Linear physical address of the location. When Virtual Memory is supported, you need to translate the address obtained from Segment Translation, which will be the Virtual Address, to get the actual Physical address.

Giri.
----- Original Message -----
From: Deepu.L.R
To: NT Developers Interest List
Sent: Friday, December 20, 2002 11:58 AM
Subject: [ntdev] Doubts regarding GDT/LDT

hai all,

I am a student, and please help me to clear some doubts regarding GDT an LDT. I am asking these doubts based on the NT/2000/Xp OS.

  1. According to intels’s docs both GDT and LDT contains the segment descriptors. what are the difference between descriptors in these two tables?

  2. Is GDT - contains the descriptors for the entire OS and LDT contains the descriptors for each process. If it is true when a new thread is scheduled to run, will the LDT will get a set of values specific to that process ?

  3. What are the details NT/200/xp keeps in these tables ?

  4. Is there any relation between GDT/LDT and the virtual memory management in NT/2000/xp?

Thanks,
Deepu.L.R

You are currently subscribed to ntdev as: xxxxx@sasken.com
To unsubscribe send a blank email to %%email.unsub%%

hai Max, Giri and all

thanks for the reply…

  1. Similarlly the intel docs says that, Memory management software has an option of using one page directory for all tasks,one page directory for each task or some combination of two. Which method is used by NT/200/xp?

  2. Since each process has it own address space, when a new process is scheduled for running, will the previous process’s Page directory and Page Table will become invalid and OS will create/load PD & PT of the new process?

  3. what is the total size of memory required to keep Page direcotry + Page Table . is it like this? and where is this tables created ? In paged pool or in non paged pool ? will these tables itself gets paged out?

Page Directory - 1024 (PD entries) * 4 byte (size of one entry) = 4 k

Pagetable - 1024 (total page tables ) * 1024 (entries in each page table) * 4 byte = 4 mb -

total (4Mb + 4 k).

Thanks,
Deepu.
----- Original Message -----
From: Seshagiri Babu K V
To: NT Developers Interest List
Sent: Friday, December 20, 2002 3:02 PM
Subject: [ntdev] Re: Doubts regarding GDT/LDT

GDT has segments descriptors which describe segments which are global to the system. You can assume these segments to be in the upper 2GB of the memory in NT, which you will be knowing won’t change from process to process.

But LDT’s are specific to a process (Eventhough segments can be shared between process, lets ignore that here).

LDT’s are formed using the data described in the .exe file, or a dll, for instance. As you know the basic segments in any exe can be code, data segments, which some times can be in multiple numbers. These form the Local segments (and hence local Desriptors) for this process and will be referenced by a Segment Descriptor each.

As u can easily make out, Segment Descriptor specifies things like starting address of the segment, length of the segment, protection on the segment etc.

GDT’s LDT’s exists irrespective of whether Virtual Memory is present or not. For ex, if virtual memory is not used, the address obtained after Segment Translation is the Linear physical address of the location. When Virtual Memory is supported, you need to translate the address obtained from Segment Translation, which will be the Virtual Address, to get the actual Physical address.

Giri.
----- Original Message -----
From: Deepu.L.R
To: NT Developers Interest List
Sent: Friday, December 20, 2002 11:58 AM
Subject: [ntdev] Doubts regarding GDT/LDT

hai all,

I am a student, and please help me to clear some doubts regarding GDT an LDT. I am asking these doubts based on the NT/2000/Xp OS.

  1. According to intels’s docs both GDT and LDT contains the segment descriptors. what are the difference between descriptors in these two tables?

  2. Is GDT - contains the descriptors for the entire OS and LDT contains the descriptors for each process. If it is true when a new thread is scheduled to run, will the LDT will get a set of values specific to that process ?

  3. What are the details NT/200/xp keeps in these tables ?

  4. Is there any relation between GDT/LDT and the virtual memory management in NT/2000/xp?

Thanks,
Deepu.L.R

You are currently subscribed to ntdev as: xxxxx@sasken.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntdev as: xxxxx@m2comsys.com
To unsubscribe send a blank email to %%email.unsub%%

First of all iam feeling overjoyed cos u put my name beside Maxs’ :wink:

>Which method is used by NT/200/xp?

Page directories are different for each task, though the info can be shared between directories

>when a new process is scheduled for running

Contents of the Register holding the Page Directory Pointer, ie, CR3 is updated for each process switch. OS will create those only the first time process is loaded, later on it’ll only be updates, trivial :slight_smile:

Your calculation is correct!! Yeah…these page tables can be swapped out.And so they will can be created from PagedPool itself. Its only necessary that TaskSegment, which is a descriptor of each process be resident (someone can clarify more).

Giri.
----- Original Message -----
From: Deepu.L.R
To: NT Developers Interest List
Sent: Friday, December 20, 2002 5:09 PM
Subject: [ntdev] Re: Doubts regarding GDT/LDT

hai Max, Giri and all

thanks for the reply…

  1. Similarlly the intel docs says that, Memory management software has an option of using one page directory for all tasks,one page directory for each task or some combination of two. Which method is used by NT/200/xp?

  2. Since each process has it own address space, when a new process is scheduled for running, will the previous process’s Page directory and Page Table will become invalid and OS will create/load PD & PT of the new process?

  3. what is the total size of memory required to keep Page direcotry + Page Table . is it like this? and where is this tables created ? In paged pool or in non paged pool ? will these tables itself gets paged out?

Page Directory - 1024 (PD entries) * 4 byte (size of one entry) = 4 k

Pagetable - 1024 (total page tables ) * 1024 (entries in each page table) * 4 byte = 4 mb -

total (4Mb + 4 k).

Thanks,
Deepu.
----- Original Message -----
From: Seshagiri Babu K V
To: NT Developers Interest List
Sent: Friday, December 20, 2002 3:02 PM
Subject: [ntdev] Re: Doubts regarding GDT/LDT

GDT has segments descriptors which describe segments which are global to the system. You can assume these segments to be in the upper 2GB of the memory in NT, which you will be knowing won’t change from process to process.

But LDT’s are specific to a process (Eventhough segments can be shared between process, lets ignore that here).

LDT’s are formed using the data described in the .exe file, or a dll, for instance. As you know the basic segments in any exe can be code, data segments, which some times can be in multiple numbers. These form the Local segments (and hence local Desriptors) for this process and will be referenced by a Segment Descriptor each.

As u can easily make out, Segment Descriptor specifies things like starting address of the segment, length of the segment, protection on the segment etc.

GDT’s LDT’s exists irrespective of whether Virtual Memory is present or not. For ex, if virtual memory is not used, the address obtained after Segment Translation is the Linear physical address of the location. When Virtual Memory is supported, you need to translate the address obtained from Segment Translation, which will be the Virtual Address, to get the actual Physical address.

Giri.
----- Original Message -----
From: Deepu.L.R
To: NT Developers Interest List
Sent: Friday, December 20, 2002 11:58 AM
Subject: [ntdev] Doubts regarding GDT/LDT

hai all,

I am a student, and please help me to clear some doubts regarding GDT an LDT. I am asking these doubts based on the NT/2000/Xp OS.

  1. According to intels’s docs both GDT and LDT contains the segment descriptors. what are the difference between descriptors in these two tables?

  2. Is GDT - contains the descriptors for the entire OS and LDT contains the descriptors for each process. If it is true when a new thread is scheduled to run, will the LDT will get a set of values specific to that process ?

  3. What are the details NT/200/xp keeps in these tables ?

  4. Is there any relation between GDT/LDT and the virtual memory management in NT/2000/xp?

Thanks,
Deepu.L.R

You are currently subscribed to ntdev as: xxxxx@sasken.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntdev as: xxxxx@m2comsys.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntdev as: xxxxx@sasken.com
To unsubscribe send a blank email to %%email.unsub%%

The only descriptors that I know are GDT-only are the LDT descriptors, are
there any others ?

Also, LDTs aren’t necessarily attached to processes, neither is a process,
or a machine, restricted to one LDT. At architectural level, the two tables
are pretty much equivalent, the distinction between the two being a bit in
the selector. All you need to establish an LDT is to load the LDTR -
likewise, it’s quite feasible to switch the GDT in midair just by reloading
the GDTR.

Makes for a great OS-under-the-OS strategy, eh ? Just flip those GDTRs and
IDTRs, and Windows is out of the picture. :slight_smile:

Alberto.

-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Friday, December 20, 2002 4:19 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Doubts regarding GDT/LDT

  1. According to intels’s docs both GDT and LDT contains the segment
    descriptors. what are
    the difference between descriptors in these two tables?

No differences, except that some kinds of descriptors can occur in GDT
only.

  1. Is GDT - contains the descriptors for the entire OS and LDT
    contains the descriptors for
    each process. If it is true when a new thread is scheduled to run,
    will the LDT will get a set of
    values specific to that process ?

NT used LDT for 16bit apps only.

  1. What are the details NT/200/xp keeps in these tables ?

Some essential segments necessary for CPU to run, a segment per each
CPU and a segment for thread local storage.

  1. Is there any relation between GDT/LDT and the virtual memory
    management in
    NT/2000/xp?

No.

Max


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

Your Q2 pretty much answered your Q1. However, since modern 32-bit OSes use
flat 32-bit mode. Segment descriptors are pretty much all describe 0-4GB
flat virtual address space, except FS (if I recall correctly) is different
to map certain thread structure so it is harder for errant app to corrupt
thread structure. I heard Microsoft will do away with that too.

A3: Descriptor contents are kept in _KPROCESS (windbg or softice will show
you the structure). TSS are kept in _KTHREAD

A4: Not much. However IA32 you have to set it up. Early NT OSes supports
RISC which may/may not have GDT/LDT at all. In emulation real mode (16-bit
VM) LDT is nevertheless used.

Bi

-----Original Message-----
From: Deepu.L.R [mailto:xxxxx@m2comsys.com]
Sent: Thursday, December 19, 2002 10:28 PM
To: NT Developers Interest List
Subject: [ntdev] Doubts regarding GDT/LDT

hai all,

I am a student, and please help me to clear some doubts regarding GDT an
LDT. I am asking these doubts based on the NT/2000/Xp OS.

  1. According to intels’s docs both GDT and LDT contains the segment
    descriptors. what are the difference between descriptors in these two
    tables?

  2. Is GDT - contains the descriptors for the entire OS and LDT contains the
    descriptors for each process. If it is true when a new thread is scheduled
    to run, will the LDT will get a set of values specific to that process ?

  3. What are the details NT/200/xp keeps in these tables ?

  4. Is there any relation between GDT/LDT and the virtual memory management
    in NT/2000/xp?

Thanks,
Deepu.L.R

You are currently subscribed to ntdev as: xxxxx@appstream.com
To unsubscribe send a blank email to %%email.unsub%%

hai all,

thanks for the replies.

Deepu.L.R
----- Original Message -----
From: Bi Chen
To: NT Developers Interest List
Sent: Friday, December 20, 2002 11:47 PM
Subject: [ntdev] RE: Doubts regarding GDT/LDT

Your Q2 pretty much answered your Q1. However, since modern 32-bit OSes use flat 32-bit mode. Segment descriptors are pretty much all describe 0-4GB flat virtual address space, except FS (if I recall correctly) is different to map certain thread structure so it is harder for errant app to corrupt thread structure. I heard Microsoft will do away with that too.

A3: Descriptor contents are kept in _KPROCESS (windbg or softice will show you the structure). TSS are kept in _KTHREAD

A4: Not much. However IA32 you have to set it up. Early NT OSes supports RISC which may/may not have GDT/LDT at all. In emulation real mode (16-bit VM) LDT is nevertheless used.

Bi
-----Original Message-----
From: Deepu.L.R [mailto:xxxxx@m2comsys.com]
Sent: Thursday, December 19, 2002 10:28 PM
To: NT Developers Interest List
Subject: [ntdev] Doubts regarding GDT/LDT

hai all,

I am a student, and please help me to clear some doubts regarding GDT an LDT. I am asking these doubts based on the NT/2000/Xp OS.

  1. According to intels’s docs both GDT and LDT contains the segment descriptors. what are the difference between descriptors in these two tables?

  2. Is GDT - contains the descriptors for the entire OS and LDT contains the descriptors for each process. If it is true when a new thread is scheduled to run, will the LDT will get a set of values specific to that process ?

  3. What are the details NT/200/xp keeps in these tables ?

  4. Is there any relation between GDT/LDT and the virtual memory management in NT/2000/xp?

Thanks,
Deepu.L.R

You are currently subscribed to ntdev as: xxxxx@appstream.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntdev as: xxxxx@m2comsys.com
To unsubscribe send a blank email to %%email.unsub%%