汇编 – IA-32e 64位IDT门描述符

英特尔的64位IDT门描述符中有一个段选择器.但是,根据我对5部分英特尔手册的理解,中断处理程序的线性地址从IDT门描述符中指定的64位偏移量加载到RIP中.

段选择器的唯一用途是检查:

>如果特权级别发生变化
>中断处理程序真正指向代码段

我的问题是:

> RIP仅从64位偏移量中获取吗?或者RIP =偏移(符号扩展到64位)段选择器基数?
> IDT门描述符中的段选择器指向的基址是否被忽略?或者它有用吗?

提前谢谢了!

如果我正确地解释这一点,根据英特尔手册,x64不使用分段.我读了 AMD’s System programming for AMD64来理解这一点,因为我发现他们的解释更容易理解,因为他们明确地处理x86_64(他们确实发明了它,我想);他们说:

In long mode, the effects of segmentation depend on whether the processor is running in compatibility
mode or 64-bit mode:

  • In compatibility mode, segmentation functions just as it does in legacy mode, using legacy 16-bit or 32-bit protected mode semantics.
  • 64-bit mode, segmentation is disabled, creating a flat 64-bit virtual-address space. As will be seen, certain functions of some
    segment registers, particularly the system-segment registers, continue
    to be used in 64-bit mode.

具体来说,查看4.8节长模式段描述符.回答你的第二个问题:

Fields Ignored in 64-Bit Mode. Segmentation is disabled in 64-bit
mode, and code segments span all of virtual memory. In this mode, code-segment base addresses are ignored. For the purpose of virtual-address calculations, the base address is treated as if it has a value of zero.

解释:因为x86_64中的“段”是整个地址空间,除了0之外,基址没有意义,因为偏移都是绝对的(相对于0).

因此,这将回答我认为的第一个问题 – RIP被视为64位偏移值.从同章的门描述符页面:

In long mode, gate descriptors are expanded by 64 bits, allowing them to hold 64-bit offsets.

在处理数据段时,它变得更加复杂:

Data segments referenced by the FS and GS segment registers receive special treatment in 64-bit
mode. For these segments, the base address field is not ignored, and a non-zero value can be used
in virtual-address calculations. A 64-bit segment-base address can be specified using model-
specific registers. See “FS and GS Registers in 64-Bit Mode” on page 70 for more information.

该部分指出:

FS and GS Registers in 64-Bit Mode. Unlike the CS, DS, ES, and SS segments, the FS and GS
segment overrides can be used in 64-bit mode. When FS and GS segment overrides are used in 64-bit
mode, their respective base addresses are used in the effective-address (EA) calculation. The complete
EA calculation then becomes (FS or GS).base + base + (scale ∗ index) + displacement. The FS.base
and GS.base values are also expanded to the full 64-bit virtual-address size, as shown in Figure 4-5.
The resulting EA calculation is allowed to wrap across positive and negative addresses.

In 64-bit mode, FS-segment and GS-segment overrides are not checked for limit or attributes. Instead,
the processor checks that all virtual-address references are in canonical form.

换句话说,数据段可以像使用分段一样,尽管只检查分段的形式,而不是检查访问的形式是否在段的边界内.

我认为这是正确的解释;但是,更正/指针非常赞赏.

相关文章
相关标签/搜索