Questions tagged [gdt]

The Global Descriptor Table or GDT is a data structure used by Intel x86-family processors

Starting with the 80286 in order to define the characteristics of the various memory areas used during program execution, including the base address, the size and access privileges like executability and writability. These memory areas are called segments in Intel terminology.

The GDT can hold things other than segment descriptors as well. Every 8-byte entry in the GDT is a descriptor, but these can be Task State Segment (or TSS) descriptors, Local Descriptor Table (LDT) descriptors, or Call Gate descriptors. The last one, Call Gates, are particularly important for transferring control between x86 privilege levels although this mechanism is not used on most modern operating systems.

Loading a selector into a segment register automatically reads the GDT or the LDT and stores the properties of the segment inside the processor itself. Subsequent modifications to the GDT or LDT will not be effective unless the segment register is reloaded.

enter image description here

GDT in 64-bit

The GDT is still present in 64-bit mode; a GDT must be defined, but is generally never changed or used for segmentation. The size of the register has been extended from 48 to 80 bits, and 64-bit selectors are always "flat"

102 questions
1
vote
2 answers

Are there multiple LDTs?

The following Wikibooks page states: The GDT contains pointers to each LDT. I'm currently learning about segmentation, and this implies that there are multiple LDTs. As far as I can tell there is only one: multiple references I've read refer to…
VortixDev
  • 965
  • 1
  • 10
  • 23
1
vote
1 answer

Trouble simplifying GDT on x86

I'm trying to simplify a GDT table with contains 6 segments but in which 2 are really necessary (from what I gather). I cannot make the changes work. The code is from Cromwell, a Xbox (Original) bootloader. The CPU is a Pentium III . There is no…
1
vote
1 answer

After load the GDT

# Load the GDT. mov $gdt_descriptor, %ecx lgdt (%ecx) mov $0x10, %cx mov %cx, %ds mov %cx, %es mov %cx, %fs mov %cx, %gs mov %cx, %ss ljmp $0x8, $1f 1: mov $kernel_stack, %esp I am unable to understand what this code does. Why mov $0x10 to cx and…
Junping Qv
  • 21
  • 4
1
vote
0 answers

Long jump to 32-bit code does not seem to take effect after switching to protected mode

After much debate with myself, I have finally decided to move my OS to Protected Mode. However, I am having a few issues executing Protected Mode code. The first step on the OSDev wiki was to enable the A20 line, something I had little trouble with…
1
vote
1 answer

Constant reboot after setting up the Global Descriptor Table and protected mode

I must have done something wrong with the GDT setup and the switch to protected mode because it keeps constantly rebooting. Here is my kernel.asm that should setup the GDT and switch to protected mode: bits 16 jmp main %include…
user7329614
1
vote
1 answer

What is the relation between Selector and GDT in PM?

I went through many of the tutorials available on the Net about the Global Descriptor Table. But I couldn't find a site which explains all the fields in the 64-bit descriptor in detail. Moreover I was stuck with the selector concept in the GDT. I…
Panther Coder
  • 1,058
  • 1
  • 16
  • 43
1
vote
1 answer

x86 interrupt service routine causes general protection fault

I have my common isr stub defined as: isr_common_stub: pusha ; Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax mov ax, ds ; Lower 16-bits of eax = ds. push eax ; save the data segment descriptor mov ax, 0x10…
The amateur programmer
  • 1,238
  • 3
  • 18
  • 38
1
vote
2 answers

How do I find out the contents of GDT

I am analyzing a disassembled dll and got stuck on the line mov ebx,fs:[00000004h] I want to find out the exact physical address of the data that is written into ebx with this instruction. gdb tells me that fs = 0x53. I already found out that the…
Nukualofa
  • 11
  • 2
1
vote
1 answer

Why is the GDT not considered a segment?

Besides code, data, and stack segments that make up the execution environment of a program or procedure, the architecture defines two system segments: the task-state segment (TSS) and the LDT. The GDT is not considered a segment because it is not…
yuan
  • 2,434
  • 1
  • 21
  • 29
0
votes
1 answer

bochs: fetch_raw_descriptor: GDT: index (bf) 17 > limit (17)

I'm trying to make a simple OS and I'm currently working on interrupts and the IDT. So I implemented the IDT and a default exception handler that currently doe's nothing. And when I run my OS in bochs I see that the OS triple faults right when it is…
neta cohen
  • 137
  • 11
0
votes
0 answers

Switching to GDT/Protected Mode - Things not printing

I'm trying to switch my code over to use GDT and protected mode, however I'm having an issue to where the new print.asm file isn't printing anything anymore, any help would be appreciated I've tried debugging this for about 30 minutes and I can't…
Pigioty
  • 11
  • 6
0
votes
0 answers

Waiting for DRQ on ATA driver loops for infinity

i have written a super simple os and i decided to start using grub to boot it, so i started a new projected and im getting my old kernel functions to the new kernel and the ATA driver is not working stuck when i wait for DRQ void ATA_wait_DRQ() //…
Rabyt
  • 61
  • 6
0
votes
0 answers

How to get invisible part of segment register

I want to start virtual technology on my AMD computer. So I need to get the invisible part of the segment register, such as limit, base and attribute to fill the state save area of vmcb. I tried to use the following code to read the invisible part…
fahuifai
  • 1
  • 1
0
votes
0 answers

How is task register updated in xv6 on x86 platform?

In the xv6 source code for x86 architecture, in the switchuvm function, the TSS is being updated (as well as the page table but that's not my concern here). I've been struggling with the concept of the GDT and TSS and so I want to attempt to lay…
shafe
  • 53
  • 1
  • 6
0
votes
0 answers

How does the place of global descriptor table affects the program?

My code looks like so: [org 0x7c00] [bits 16] cli ; %include 'gdt.asm' , what is wrong if i set the gdt here instead of bellow the long jump? lgdt [gdt_32_descriptor] ; gdt_32_descriptor is contained in gdt.asm mov eax, cr0 or eax,…