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
12
votes
1 answer

Far jump in gdt in bootloader

flush_gdt: lgdt [gdtr] jmp 0x08:complete_flush complete_flush: mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax ret I am unable to understand what this code does . flush_gdt is a label okay ,…
abkds
  • 1,764
  • 7
  • 27
  • 43
11
votes
2 answers

What is the use of defining a Global Descriptor Table?

I read a tutorial on GDT (Global Descriptor Table) which defines GDT as " the one that defines base access privileges for certain parts of memory ". That means GDT is used for memory protection. Does it perform any other tasks other than the…
Panther Coder
  • 1,058
  • 1
  • 16
  • 43
9
votes
1 answer

Where Linux Kernel Setup GDT

I am reading through Linux Kernel code. I have some doubt regarding GDT(Global Descriptor Table) in Linux. My Questions are: Where Linux Kernel Setup Large GDT? I know that in pm.c [http://lxr.free-electrons.com/source/arch/x86/boot/pm.c#L123]…
8
votes
1 answer

How do I enter 32-bit protected mode in NASM assembly?

I'm learning x86 assembly, and I'm trying to make a toy operating system in NASM, but I don't understand some things. I made a bootloader that is successfully boots my kernel: Loads 14 sectors from the diskette which contains the kernel…
Axl Zorion
  • 81
  • 1
  • 3
8
votes
1 answer

Can I print the gdtr and gdt descriptor under gdb?

I want to use gdb to see my GDTR/LDTR/TTR and segment register invisiable part(x86) so in gdb I enter "p/x $gdtr"....etc but the result is "$6 = Value can't be converted to integer" and in gdb I enter "p/x $cs" the only result is…
Colin
  • 81
  • 1
  • 2
6
votes
1 answer

How are LDT and GDT used differently in intel x86?

I understand that both tables contain segment descriptors that provide access details for each segment, including the base address, type, length, access rights ...etc. Looking at this blog describes the differences as follows: 1. GDT have only one…
Abundance
  • 1,963
  • 3
  • 24
  • 46
5
votes
1 answer

Change GDT and update CS while in long mode

I'm writing a simple home-made 64-bit OS, booting it via UEFI. This means that when my code starts executing, it is already in long mode, with paging enabled. Now, after exiting the UEFI boot services, I want to replace all control structures built…
lodo
  • 2,314
  • 19
  • 31
4
votes
0 answers

How to enable paging in x86 and display GDT in UEFI

My goal is to enable paging in x86 in UEFI. My professor said, that I may first try to display GDT in UEFI - that way I will also see if paging works. The problem is, that I have no idea how to do it. I used this tutorial to enable EDK2 in Visual…
Corson
  • 167
  • 1
  • 1
  • 10
4
votes
1 answer

What exactly does the granularity bit of a GDT change about addressing memory?

If this bit is zero, then memory is addressed byte by byte? And if it is 1, then memory is addressed 4Kb by 4Kb? So for example, if this bit was set to 0, and i addressed memory location a000h, then i would be addressing the byte at that location…
kbzombie
  • 322
  • 2
  • 12
4
votes
0 answers

virtual address of gs:0x14

if we compile some C code with gcc we often see the following assembly result 0x08048494 <+0>: push ebp 0x08048495 <+1>: mov ebp,esp 0x08048497 <+3>: and esp,0xfffffff0 0x0804849a <+6>: sub esp,0x130 0x080484a0 <+12>: mov …
daehee
  • 5,047
  • 7
  • 44
  • 70
3
votes
1 answer

Qemu is infinitely rebooting when setting GDT

I am making an OS mostly in C++, but for the bootloader, I'm using FASM. When I try to set the GDT, Qemu clears the screen and re-prints "SeaBIOS" at the top. It continues in a loop like that until I close it. Here is a gif of it: I tried running…
Lysander Mealy
  • 113
  • 1
  • 6
3
votes
1 answer

Triple fault on interrupts

I'm new to all this, so I apologize in advance if I missed something really obvious So, I'm trying to make a simple kernel in x86 assembly and C. I was trying to get interrupts working. I am defining the GDT, IDT in assembly. I'm not even sure…
3
votes
1 answer

If LDT does not exist in 64-bit architecture how are 32-bit systems that use it emulated on a 64-bit architecture?

I read that LDT (Local Descriptor Table) does not exist in 64-bit architecture and was wondering how a 32-bit system that uses it is emulated.
3
votes
0 answers

Why are the code and data segment selectors 0x8 and 0x10 in MIT's JOS Bootloader?

In an MIT course section on bootloaders, the following code is used to set up kernel code segment and data segment selectors: .set PROT_MODE_CSEG, 0x8 # kernel code segment selector .set PROT_MODE_DSEG, 0x10 # kernel data segment…
Alexander Guyer
  • 2,063
  • 1
  • 14
  • 20
3
votes
2 answers

Read value of GDTR

I find out that it's possibly to read GDTR by SGDT assembly command. Inserting this piece of assembly in my C code I get Error: operand type mismatch for 'sgdt' unsigned long j; asm("sgdt %0" : "=r"(j));
Pirate
  • 97
  • 8
1
2 3 4 5 6 7