A file that defines the data structure for the Global Descriptor and Local Descriptor tables?

I read Understanding the Linux kernel , and in it I read about the global descriptor table and the local descriptor table.

In which source file (s) (Linux kernel) is the data structure defined for GDT and LDT?

+5
source share
2 answers

A google search for the term " Linux kernel gdt file " gives the exact results you are looking for. This is a link to a book search result with content describing where GDT and LDT are defined.

  • All GDTs are stored in the cpu_gdt_table array.

  • If you look in the source code index, you will see that these symbols are defined in the file arch/i386/kernel/head.S However, I think the source code index can be viewed when you have a copy of the book. Nevertheless, a file is given that defines GDT.

+2
source

In the latest kernel, GDT is defined in at least 3 separate files.

  • arch/x86/include/asm/desc_defs.h
  • arch/x86/include/asm/desc.h
  • arch/x86/include/asm/segment.h

The structure of the main GDT seems to be defined in arch/x86/include/asm/segment.h around line 91 . There are comments above the line above.

The populated table is loaded into arch/x86/include/asm/desc.h using the static inline void native_load_gdt(const struct desc_ptr *dtr) function, which simply calls the assembly operation code lgdt . This is consistent with the way old kernels load the table into the processor. See line 303 here . However, I cannot find any calls to this function in the code base. Someone please help figure this out.

Also, I cannot find the equivalent of determining the constants of the actual table, as in line 479 in newer kernels.

0
source

Source: https://habr.com/ru/post/1202187/


All Articles