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
0 answers

Assembly: How to use the segment selector in win7x64? JMP FAR or CALL FAR in x64 in protected mode

I know how the 32-bit protected mode implements the jump by modifying the segment selector, but the 64-bit situation is different from what I imagined. I wrote the descriptor in gdt.they are both same I wrote a code segment descriptor where the…
CHAOSYD
  • 15
  • 1
  • 5
1
vote
1 answer

Why does this assembly code does more than just lgdt?

So, I am beginning the development of a x86_64 hobby kernel and I found this code to load the GDT (Global Descriptor Table), but I don't understand what it does. load_gdt: lgdt [rdi] mov ax, 0x10 mov ss, ax mov ds, ax mov es, ax mov rax,…
Quentin
  • 61
  • 1
  • 5
1
vote
1 answer

Use of gs register on a 32 bit program over a 64 bit linux

In a 64 bit program the selector:offset used to get the stack protector is fs:0x28, where fs=0. This poses no problem because in 64 bit we have the MSR fs_base (which is set to point to the TLS) and the GDT is completely ignored. But with 32 bit…
Arget
  • 86
  • 8
1
vote
0 answers

Where and When Linux Kernel Setup GDT?

I have some doubt regarding GDT in linux. I try to get GDT info in kernel space (Ring0), and my test code called in system call context. In the test code, I try to print ss register (Segment Selector), and get ss segment descriptor by GDTR and…
wywan
  • 11
  • 2
1
vote
2 answers

Assempler - PC crashes after execution of LGDT instruction

Contents I want to jump to diskette_initialisation with the jmp instruction after executing the lgdt instruction, but it crashes What is the cause? If the cause is known, why did the designers of the Intel cpu do it? Environment cpu: …
user15233325
1
vote
1 answer

Triple fault when loading the GDT

I am trying to set up the GDT in rust and global asm but it seems to triple fault when I try to load the GDT. # init_gdt.asm. .intel_syntax noprefix # **Notes**: 0x00: The Kernel Null Segment. # 0x10: The Kernel Data Segment. # …
Anhad Singh
  • 49
  • 1
  • 3
1
vote
0 answers

Reboot After LGDT Instruction And Far Jump To Protected Mode

So I have ran into a problem which I've been stuck on now for what seems like eternity, about 3 days without sleep trying to solve the issue on my own now, and it's kinda depressing to me as I feel as if it should honestly be a relatively simple…
GodDamn
  • 161
  • 1
  • 8
1
vote
0 answers

GDTR and Segmentation in x86_64

As per the Intel® 64 and IA-32 Architectures Software Developer’s Manual In 64-bit mode, segmentation is generally (but not completely) disabled, creating a flat 64-bit linear-address space. Does that mean GDTR is not needed/present in a x86_64…
Franc
  • 319
  • 9
  • 28
1
vote
1 answer

How can the x86 processor fetch the instruction just after GDT is loaded by a bootloader?

In a typical simple bootloader writing for x86, we have the following code to load the GDT and perform a far jump (note that CS is 0x0 before executing the following code): lgdt gdtdesc movl %cr0, %eax orl $1, %eax movl %eax, %cr0 # Jump to next…
1
vote
1 answer

What will happen if the GDT is changed as the program is executing?

What will happen if the GDT is changed as the program is executing? Is there any physical register or anything else that monitors whether the GDT is changed when executing program?
Jack Smith
  • 13
  • 2
1
vote
1 answer

How is a GDT invoked?

I know how a GDT (Global Descriptor Table) is implemented and the use of segment registers and segment descriptors. However how/when is a GDT entry accessed? Is it accessed in basic mov instructions like mov [eax],ebx Does this implicitly invoke…
Apoorv Jain
  • 113
  • 9
1
vote
1 answer

Why does my inline assembly code cause a triple fault?

I compile my code using GCC with the -masm=intel option. My kernel is loaded by a Multiboot loader like GRUB. I want to load the address of my GDT and then I reload all segment registers but this causes a triple fault (virtual machine restarts).…
Grevak
  • 533
  • 5
  • 17
1
vote
1 answer

Which segment descriptor does Intel assembly command "sgdt" returns

I want to implement 32-bit 4Gb Flat Memory mapping for an application, for this purpose I have to get and update Data Segment Descriptor and Code Segment Descriptors. By using assembly command "sgdt" i can get Global Descriptor Table but I am not…
1
vote
0 answers

Ring transitioning using call gates

I'm trying to perform a Ring 3 to Ring 0 transition using Call Gates rather than SYSRET & SYSENTER to see how call gates work on IA-32e (64 Bit) processors. What I know is Call Gates are special structure that you can put into GDT so it can be used…
Mohammad Sina Karvandi
  • 1,064
  • 3
  • 25
  • 44
1
vote
1 answer

Can there be multiple segment descriptors for one segment?

Could one utilise multiple segment descriptors for a single segment in order to give different privilege levels separate permissions in that segment? For example, allowing ring 2 to read or write to a data segment via one descriptor, and then…
VortixDev
  • 965
  • 1
  • 10
  • 23