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

How to update GDT entries after initial loading?

Once I initialize and load my GDT into the GDTR using lgdt, how can I update the GDT later? Am I correct if I use the sgdt command to get the base address and then update or add entries followed by reloading it again with the lgdt? Is there some…
2
votes
0 answers

Confusion of NULL selectors in 64bit processors

I'm sorry my English is not good. In protection mode, Out of segment limit will trigger #GP. But I have a strange problem on 64 bit processor(I7-3840,i5-3540): initialize DS or ES to 0 in real mode, then switch to protection mode, and still use the…
lgj1107
  • 21
  • 1
  • 2
2
votes
2 answers

OS & Assembly: What prevents user mode from setting selector to arbitrary value?

I know that operating system restricts the access to kernel code & data by using segmentation and privilege level. However, users can change the segment register value and seems that we can access the kernel data if the following code executes…
Changda Li
  • 123
  • 1
  • 8
2
votes
1 answer

Bochs GDT Segment limit is shifted left 3 times in hex and 0xFFF is added. Is this normal?

Im currently setting up a GDT for my bootloader. I have 3 (4) segments: (zero segment) 4GB Kernel Code segment 4GB Kernel Data segment 2GB Stack Data section (i forgot to set 1 bit to 0 when i made the screenshots. Later this will be 1mb) Here is…
Toboxos
  • 170
  • 9
2
votes
1 answer

How to update Data Segment Selector in Protected mode

I want to update Data Segment selector to point to some other entry in GDT. But Since I am very new to assembly, I can not do it in my code. However I have updated the Code Segment Selector by using following assembly instruction: ljmp…
2
votes
1 answer

What is the purpose of the AVL bit in a segment descriptor?

What is the AVL bit in the GDT used for? Wikipedia doesn't provide any information that I can find other than "For software use, not used by hardware".
VortixDev
  • 965
  • 1
  • 10
  • 23
2
votes
1 answer

Address translation in big real mode

I have some questions regarding how address translation happens in big real mode, as http://wiki.osdev.org/Unreal_Mode says Unreal mode consist of breaking the '64Kb' limit of real mode segments, but still keeping 16 bits instruction and…
Arka Sharma
  • 289
  • 1
  • 3
  • 10
2
votes
2 answers

I failed in switching the cpu from real-mode to protected-mode

I do this according a book by Nick Blundell. I write a MBR program, which runs in real-mode firstly, and some instructions in the program will switch the cpu to protected-mode. First I set the GDT like this: gdt_start: gdt_null: dd 0x0 dd…
Akr
  • 179
  • 2
  • 4
  • 13
2
votes
1 answer

Access GDT after data segment had been set?

This is a really stupid question, but I can't seem to solve it. In my OS the GDT is setup via assembly code that links upped with the kernel. When that happens, of course the data segment and code segment are set up when the GDT is loaded. The this…
user1454902
  • 750
  • 9
  • 24
2
votes
1 answer

Is it possible to get the address of the GDT?

I have a bootloader that is setting up the GDT for me. Is it possible to find out the address of this GDT so I can use it?
user1454902
  • 750
  • 9
  • 24
1
vote
0 answers

why my os doesn't switch to protected mode

I started creating an os entirely in assembly thinking I wanted to do it completely in real-mode, but as soon as I realized the limitations I had, I decided to create the bootloader in real-mode and the kernel in protected-mode I tried to set the…
1
vote
0 answers

If I set a register, completely unrelated memory location gets changed

I am creating a 32 bit operating system. I have enabled paging and it works fine, until the kernel_main function returns to the assembly code (which calls the kernel_main function). The assembly code is like this: call kernel_main jmp $ But when…
modlegend
  • 11
  • 5
1
vote
1 answer

Will it be OK to access data through a data segment register after I disturb gdt table?

I had set the gdt table using this data uint16_t gdt_table[][4] = { { 0, 0, 0, 0 }, { 0xFFFF, 0x0000, 0x9a00, 0x00cf }, { 0xFFFF, 0x0000, 0x9200, 0x00cf }, }; And I do mov $16, %eax ; mov %eax, %ds…
Markity
  • 193
  • 8
1
vote
2 answers

The relation between I386 GDT and display memory address 0xa0000?

I believe I have set up the GDT correctly like this: # Start the CPU: switch to 32-bit protected mode, jump into C. # The BIOS loads this code from the first sector of the hard disk into # memory at physical address 0x7c00 and starts executing in…
lewis
  • 51
  • 3
1
vote
0 answers

Loading global descriptor table causes error

I have a subroutine 'switch32' on my bootloader which is supposed to make the transition to 32 bit protected mode, however the lgdt instruction seems to be causing trouble. Here is the code for "switch32.asm": gdt_start: gdt_null: dq…
MottLx
  • 53
  • 1
  • 7