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

How to switch from real mode to protected mode

I am going to write a simple operating system. An error have been occurred while switch from 16 bits' real mode to 32 bits' protected mode. After loading the GDT register and setting the GDT, the protected mode has been turned on successfully. I'd…
Zhi-An Zhu
  • 49
  • 3
0
votes
2 answers

What are the sizes of GDTR, LDTR, IDTR and TR registers?

I've searched up on a lot on the net and every time I can only find the sizes of GDT, LDT and IDT. Here I'm not asking for the size of the table, but I'm asking about the sizes of the registers I know that GDTR is a 64 bit register, but clueless…
Marc Al
  • 27
  • 1
  • 6
0
votes
1 answer

Ask for clarification about "the segment registers continue to point to the same linear addresses as in real address mode"

The question is about persistent validity of code segment selector while switching from real mode to protected mode on intel i386. The switching code is as follows (excerpted from bootasm.S of xv6 x86 version): 9138 # Switch from real to protected…
zzzhhh
  • 319
  • 1
  • 8
0
votes
1 answer

enabling paging leads to triple fault

In case this helps somebody in the future: check if the global descriptor table is working check if the elements of page table entry struct are ordered correctly This code worked for me: gdt.s section .data gdt: .null: dq 0 .code: …
0
votes
0 answers

Why is the gdt not getting loaded in this code?

This is written in AT&T syntax. I'm asking if there is any issues with my gdt here, because my interrupts aren't working. Please point out any errors I may have I'm using GRUB as my bootloader and compiling for the i386 architecture. I already have…
0
votes
2 answers

How do operating systems isolate processes from each other?

Assuming the CPU is in protected mode: When a ring-0 kernel sets up a ring-3 userspace process, which CPU-level datastructure does it have to modify to indicate which virtual address space this specific process can access? Does it just set the…
2080
  • 1,223
  • 1
  • 14
  • 37
0
votes
0 answers

Is page table and GDT the same thing?

What're the differences between the "Page Table" concept and GDT? Are the two the same? Or GDT is just implementation to the Page Table concept?
smalinux
  • 1,132
  • 2
  • 13
  • 28
0
votes
2 answers

What's a theoretical example of GDT usage?

I am following a walk through of the GDT. I can get a grasp of how the data structure is implemented and it's purpose. However, what I don't understand is how the GDT is used. What is a scenario where the CPU needs to load a segment and how does…
Elliot
  • 3
  • 2
0
votes
1 answer

Why aren't bits 11 and 12 of a segment descriptor grouped together?

A question on definition: the Intel 64 and IA-32 Architectures Software Developer Manual, Vol 3A, summarises segment descriptor fields in section 5.2. How come the "type" field is defined as bits 8 through 11, and does not include bit 12, which is…
VortixDev
  • 965
  • 1
  • 10
  • 23
0
votes
1 answer

How are segment types distinguished from one another?

How are different types of segment identified as different? Wikipedia states: Segments can be defined to be either code, data, or system segments It also states: Descriptors with bit 12 clear are "system descriptors" and are used for…
VortixDev
  • 965
  • 1
  • 10
  • 23
0
votes
1 answer

Intel flat memory model

In intel flat memory model, mostly 2 GDT indices are used always, CODE segment, DATA segment, Can I use more GDT indices in flat memory model. My requirement is to have one memory region with RO which is now in data segment.
martin
  • 1
0
votes
1 answer

How can I initialise the GDT?

I'm making an operating system and I'm stuck at the GDT. I've tried different tutorials, such as http://www.osdever.net/bkerndev/Docs/gdt.htm and http://www.jamesmolloy.co.uk/tutorial_html/4.-The%20GDT%20and%20IDT.html, but my os crashes always. How…
user7330717
0
votes
1 answer

What happens if a process calls out to code belonging to another process?

What happens if a process calls out, for code execution, to a far pointer that belongs to another process? In 32-bit operating mode, the GDT is non-trivially used and segmentation can be fully used. So, what happens if the requested CS pointer…
0
votes
0 answers

Linear addressing and the GDT

I struggle to setup the GDT and to switch to protected mode. Mostly because i didn't understand linear addressing well enough. Here is my kernel code (kernel.asm): jmp main %include "gdt.inc" main: call InstallGDT cli mov eax,cr0 or eax,1 mov…
albert
  • 113
  • 1
  • 12
0
votes
0 answers

The program shows error when assembling using nasm

I modified an available code to enable a20 line to switch to protected mode. But an error pops out when assembling the code. The code is as follows : lb_a20_check: pushf push ds push es push di push si cli xor ax,…
Panther Coder
  • 1,058
  • 1
  • 16
  • 43