Knowledge (XXG)

Global Descriptor Table

Source 📝

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

Index

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

cite

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