简体   繁体   English

是否定义了Global Descriptor和Local Descriptor表的数据结构的文件?

[英]File in which the data structure for Global Descriptor and Local Descriptor table is defined?

I am reading Understanding Linux Kernel , and in it I read about the Global Descriptor table and the Local Descriptor Table. 我正在阅读了解Linux内核 ,其中我读到了全局描述符表和本地描述符表。

In which source file(s)(of linux kernel) the data structure for GDT and LDT are defined? 在哪个源文件(linux内核)中定义了GDT和LDT的数据结构?

A google search for the term " Linux Kernel file gdt " yields the exact results that you are looking for. 谷歌搜索术语“ Linux内核文件gdt ”会产生您正在寻找的确切结果。 This is the link to the search result of the book with the contents describing where the GDT and LDT are defined. 是指向书籍搜索结果的链接,其内容描述了GDT和LDT的定义位置。

  • All GDTs are stored in the cpu_gdt_table array. 所有GDT都存储在cpu_gdt_table数组中。

  • If you look in the source code index, you can see that these symbols are defined in the file arch/i386/kernel/head.S . 如果查看源代码索引,可以看到这些符号是在arch/i386/kernel/head.S文件中定义的。 However, I think the source code index can be viewed when you have a copy of the book. 但是,我认为当您拥有该书的副本时,可以查看源代码索引。 But nevertheless, the file where GDT is defined is given. 但是,给出了定义GDT的文件。

For the latest kernel, the GDT seems to be defined in at least 3 separate files. 对于最新的内核,GDT似乎至少在3个单独的文件中定义。

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

The layout of the main GDT seems to be defined in arch/x86/include/asm/segment.h around line 91 . 主GDT的布局似乎在第91行的 arch/x86/include/asm/segment.h定义。 There are comments about the layout above this line. 关于此行上方的布局有评论。

The completed table is loaded in arch/x86/include/asm/desc.h with the function static inline void native_load_gdt(const struct desc_ptr *dtr) which just calls the assembly opcode lgdt . 已完成的表在arch/x86/include/asm/desc.h ,函数为static inline void native_load_gdt(const struct desc_ptr *dtr)lgdt调用程序集操作码lgdt This is consistent with the way older kernels load the table into the processor. 这与旧内核将表加载到处理器中的方式一致。 See line 303 here . 这里的第303行。 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 defining the constants of the actual table as in line 479 in newer kernels. 另外,我找不到相应的定义实际表的常量,如新行内核中的第479行所示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM