Knowledge (XXG)

Global Descriptor Table

Source 📝

285: 330: 33: 522:. The limited size of the LDT means the virtual flat address space has to be limited to 512 megabytes (8191 times 64 KiB) - this is what happens on OS/2, although this limitation was fixed in version 4.5. It is also necessary to make sure that objects allocated in the 32-bit environment do not cross 64 KiB boundaries; this generates some address space waste. 132: 74: 503:- allocating separate physical memory pages (themselves very small units of memory) at the same virtual addresses, with the advantage that disk paging is far faster and more efficient than segment swapping. Therefore, modern 32-bit x86 operating systems use the LDT very little, primarily to run legacy 486:
Segments have a "Present" flag in their descriptors, allowing them to be removed from memory if the need arises. For example, code segments or unmodified data segments can be thrown away, and modified data segments can be swapped out to disk. However, because entire segments need to be operated on as
300:
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 descriptors are always "flat" (thus, from 0x0000000000000000 to 0xFFFFFFFFFFFFFFFF). However, the base of
468:
Creating shared memory through the GDT has some drawbacks. Notably such memory is visible to every process and with equal rights. In order to restrict visibility and to differentiate the protection of shared memory, for example to only allow read-only access for some processes, one can use separate
304:
If the System bit (4th bit of the Access field) is cleared, the size of the descriptor is 16 bytes instead of 8. This is because, even though code/data segments are ignored, TSS are not, but the TSS pointer can be 64bit long and thus the descriptor needs more space to insert the higher dword of the
413:
LDTs are the siblings of the Global Descriptor Table (GDT), and each define up to 8192 memory segments accessible to programs - note that unlike the GDT, the zeroeth entry is a valid entry, and can be used like any other LDT entry. Also note that unlike the GDT, the LDT cannot be used to store
250:
There is also a Local Descriptor Table (LDT). Multiple LDTs can be defined in the GDT, but only one is current at any one time: usually associated with the current Task. While the LDT contains memory segments which are private to a specific process, the GDT contains global segments. The x86
465:-based multitasking is used, while this is not possible for the GDT. The LDT also cannot store certain privileged types of memory segments (e.g. TSSes). Finally, the LDT is actually defined by a descriptor inside the GDT, while the GDT is directly defined by a linear address. 483:, where everything is located in the same memory segment, must use separate selectors for code and data/stack, making both selectors technically "aliases" as well.) In the case of the GDT, aliases are also created in order to get access to system segments like the TSSes. 487:
a unit, it is necessary to limit their size in order to ensure that swapping can happen in a timely fashion. However, using smaller, more easily swappable segments means that segment registers must be reloaded more frequently which is itself a time-consuming operation.
280:
Loading a selector into a segment register reads the GDT or LDT entry at the time it is loaded, and caches the properties of the segment in a hidden register. Subsequent modifications to the GDT or LDT will not take effect until the segment register is reloaded.
218:
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
277:(IDT), in memory, every machine instruction referencing memory has an implicit segment register, occasionally two. Most of the time this segment register can be overridden by adding a segment prefix before the instruction. 476:. Aliases are also typically created in order to get write access to code segments: an executable selector cannot be used for writing. (Protected mode programs constructed in the so-called 554: 150: 301:
FS and GS are not constrained to 0, and they continue to be used as pointers to the offset of items such as the process environment block and the thread information block.
262:
segment offsets and limits, it is possible to make segments cover the entire addressable memory, which makes segment-relative addressing transparent to the user.
469:
LDT entries, pointed at the same physical memory areas and only created in the LDTs of processes which have requested access to a given shared memory area.
251:
processors have facilities for automatically switching the current LDT on specific machine events, but no facilities for automatically switching the GDT.
435: 518:(paged) address has also a selector in the LDT (typically this results in the LDT being filled with 64 KiB entries). This technique is sometimes called 247:. Call gates were designed for transferring control between x86 privilege levels, although this mechanism is not used on most modern operating systems. 461:
The lack of symmetry between both tables is underlined by the fact that the current LDT can be automatically switched on certain events, notably if
351: 46: 567:
If the operating system detects one of these modifications or any other unauthorized patch, it will generate a bug check and shut down the system.
582: 550: 410:, just like the GDT: address start in linear memory, size, executability, writability, access privilege, actual presence in memory, etc. 377: 186: 168: 113: 60: 525:
If 32-bit code does not have to pass arbitrary memory objects to 16-bit code, e.g. presumably in the OS/2 1.x emulation present in
355: 590: 628: 616: 52: 340: 91: 84: 652: 274: 265:
In order to reference a segment, a program must use its index inside the GDT or the LDT. Such an index is called a
434:
for multiple processes. There will be generally one LDT per user process, describing privately held memory, while
359: 344: 647: 603: 480: 273:
to be used. Apart from the machine instructions which allow one to set/get the position of the GDT, and of the
446:
will switch the current LDT when scheduling a new process, using the LLDT machine instruction or when using a
510:
Should 16-bit code need to run in a 32-bit environment while sharing memory (this happens e.g. when running
451: 439: 220: 240: 530: 462: 447: 415: 407: 289: 236: 232: 443: 399: 270: 266: 632: 620: 607: 594: 403: 95: 514:
1.x programs on OS/2 2.0 and later), the LDT must be written in such a way that every
17: 641: 431: 625: 533:, it is not necessary to artificially limit the size of the 32-bit address space. 450:. On the contrary, the GDT is generally not switched (although this may happen if 254:
Every memory access performed by a process always goes through a segment. On the
587: 496: 427: 329: 284: 255: 90:
The references used may be made clearer with a different or consistent style of
613: 526: 313: 244: 472:
LDT (and GDT) entries which point to identical memory areas are called
309: 600: 504: 500: 455: 259: 283: 215: 208: 511: 231:
The GDT is a table of 8-byte entries. Each entry may refer to a
323: 211: 125: 67: 26: 312:
of the GDT; attempting to do so will cause the machine to
426:
On x86 processors not having paging features, like the
146: 418:
or LDTs. Call Gates and Task Gates are fine, however.
141:
may be too technical for most readers to understand
269:(or selector). The selector must be loaded into a 430:, the LDT is essential to implementing separate 583:Intel Architecture Software Developer's Manual 8: 358:. Unsourced material may be challenged and 61:Learn how and when to remove these messages 442:memory will be described by the GDT. The 378:Learn how and when to remove this message 187:Learn how and when to remove this message 169:Learn how and when to remove this message 153:, without removing the technical details. 114:Learn how and when to remove this message 551:"Patching Policy for x64-Based Systems" 542: 214:-family processors starting with the 151:make it understandable to non-experts 7: 557:from the original on 19 January 2022 356:adding citations to reliable sources 308:64-bit versions of Windows forbid 25: 42:This article has multiple issues. 398:) is a memory table used in the 328: 258:processor and later, because of 130: 72: 31: 50:or discuss these issues on the 614:Bran's Kernel Dev GDT Tutorial 458:are running on the computer). 207:) is a data structure used by 1: 669: 626:BrokenThorn Protected Mode 499:microprocessor introduced 275:Interrupt Descriptor Table 452:virtual machine monitors 414:certain system entries: 201:Global Descriptor Table 529:or in the Windows 3.1 406:and containing memory 392:Local Descriptor Table 320:Local Descriptor Table 292: 241:Local Descriptor Table 223:in Intel terminology. 18:Local Descriptor Table 287: 352:improve this section 408:segment descriptors 631:2018-04-23 at the 619:2008-02-03 at the 606:2009-02-14 at the 593:2009-10-17 at the 553:. 8 October 2009. 293: 290:segment descriptor 237:Task State Segment 233:segment descriptor 653:Memory management 388: 387: 380: 197: 196: 189: 179: 178: 171: 124: 123: 116: 65: 16:(Redirected from 660: 648:X86 architecture 570: 569: 564: 562: 547: 444:operating system 400:x86 architecture 383: 376: 372: 369: 363: 332: 324: 271:segment register 267:segment selector 192: 185: 174: 167: 163: 160: 154: 134: 133: 126: 119: 112: 108: 105: 99: 76: 75: 68: 57: 35: 34: 27: 21: 668: 667: 663: 662: 661: 659: 658: 657: 638: 637: 633:Wayback Machine 621:Wayback Machine 608:Wayback Machine 595:Wayback Machine 579: 574: 573: 560: 558: 549: 548: 544: 539: 531:emulation layer 493: 424: 384: 373: 367: 364: 349: 333: 322: 298: 229: 193: 182: 181: 180: 175: 164: 158: 155: 147:help improve it 144: 135: 131: 120: 109: 103: 100: 89: 83:has an unclear 77: 73: 36: 32: 23: 22: 15: 12: 11: 5: 666: 664: 656: 655: 650: 640: 639: 636: 635: 623: 611: 598: 585: 578: 577:External links 575: 572: 571: 541: 540: 538: 535: 492: 489: 432:address spaces 423: 420: 404:protected mode 386: 385: 336: 334: 327: 321: 318: 297: 294: 228: 225: 195: 194: 177: 176: 138: 136: 129: 122: 121: 104:September 2009 85:citation style 80: 78: 71: 66: 40: 39: 37: 30: 24: 14: 13: 10: 9: 6: 4: 3: 2: 665: 654: 651: 649: 646: 645: 643: 634: 630: 627: 624: 622: 618: 615: 612: 609: 605: 602: 599: 596: 592: 589: 586: 584: 581: 580: 576: 568: 556: 552: 546: 543: 536: 534: 532: 528: 523: 521: 517: 513: 508: 506: 502: 498: 490: 488: 484: 482: 479: 475: 470: 466: 464: 459: 457: 453: 449: 445: 441: 437: 436:shared memory 433: 429: 421: 419: 417: 411: 409: 405: 401: 397: 393: 382: 379: 371: 368:November 2007 361: 357: 353: 347: 346: 342: 337:This section 335: 331: 326: 325: 319: 317: 315: 311: 306: 305:TSS pointer. 302: 296:GDT in 64-bit 295: 291: 286: 282: 278: 276: 272: 268: 263: 261: 257: 252: 248: 246: 242: 238: 234: 226: 224: 222: 217: 213: 210: 206: 202: 191: 188: 173: 170: 162: 159:December 2012 152: 148: 142: 139:This article 137: 128: 127: 118: 115: 107: 97: 93: 87: 86: 81:This article 79: 70: 69: 64: 62: 55: 54: 49: 48: 43: 38: 29: 28: 19: 610:at OSDev.org 601:GDT Tutorial 597:at OSDev.org 566: 559:. Retrieved 545: 524: 519: 515: 509: 494: 491:Modern usage 485: 481:memory model 477: 473: 471: 467: 460: 425: 412: 395: 391: 389: 374: 365: 350:Please help 338: 307: 303: 299: 288:Format of a 279: 264: 253: 249: 230: 204: 200: 198: 183: 165: 156: 140: 110: 101: 82: 58: 51: 45: 44:Please help 41: 561:11 December 497:Intel 80386 428:Intel 80286 227:Description 642:Categories 537:References 527:Windows NT 520:LDT tiling 243:(LDT), or 96:footnoting 47:improve it 588:GDT Table 339:does not 314:bug check 245:call gate 53:talk page 629:Archived 617:Archived 604:Archived 591:Archived 555:Archived 221:segments 92:citation 474:aliases 422:History 360:removed 345:sources 310:hooking 239:(TSS), 145:Please 507:code. 505:16-bit 501:paging 456:VMware 440:kernel 260:32-bit 454:like 256:80386 216:80286 209:Intel 563:2020 516:flat 512:OS/2 495:The 478:tiny 438:and 416:TSSs 343:any 341:cite 199:The 94:and 463:TSS 448:TSS 402:in 396:LDT 354:by 212:x86 205:GDT 149:to 644:: 565:. 390:A 316:. 235:, 56:. 394:( 381:) 375:( 370:) 366:( 362:. 348:. 203:( 190:) 184:( 172:) 166:( 161:) 157:( 143:. 117:) 111:( 106:) 102:( 98:. 88:. 63:) 59:( 20:)

Index

Local Descriptor Table
improve it
talk page
Learn how and when to remove these messages
citation style
citation
footnoting
Learn how and when to remove this message
help improve it
make it understandable to non-experts
Learn how and when to remove this message
Learn how and when to remove this message
Intel
x86
80286
segments
segment descriptor
Task State Segment
Local Descriptor Table
call gate
80386
32-bit
segment selector
segment register
Interrupt Descriptor Table

segment descriptor
hooking
bug check

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.