gpt4 book ai didi

assembly - 为什么我的中断处理程序没有触发?

转载 作者:行者123 更新时间:2023-12-01 02:35:01 24 4
gpt4 key购买 nike

我正在尝试在 Bochs 中安装一个中断处理程序,但由于某种原因,我的中断处理程序没有触发。

首先我设置一个断点:

00036440222i[CPU0 ] [36440222] Stopped on MAGIC BREAKPOINT
(0) [0x0000000000703044] 0008:00000000c0003044 (unk. ctxt): int3

然后我尝试执行 int 3 .

但是,当我这样做时,错误显示 int_trap_gate(): selector null ,这似乎是在告诉我某个表中的选择器为空。

但是,GDT 如下所示:
<bochs:2> info gdt
Global Descriptor Table (base=0x0000000000007c08, limit=23):
GDT[0x00]=??? descriptor hi=0x00000000, lo=0x00000000
GDT[0x01]=Code segment, base=0x00000000, limit=0xffffffff, Execute/Read, Accessed, 32-bit
GDT[0x02]=Data segment, base=0x00000000, limit=0xffffffff, Read/Write, Accessed

IDT 也是如此:
<bochs:3> info idt
Interrupt Descriptor Table (base=0x00000000c0101020, limit=2047):
IDT[0x00]=32-Bit Interrupt Gate target=0x0001:0xc0004148, DPL=0
IDT[0x01]=32-Bit Interrupt Gate target=0x0001:0xc0004154, DPL=0
IDT[0x02]=32-Bit Interrupt Gate target=0x0001:0xc0004160, DPL=0
IDT[0x03]=32-Bit Interrupt Gate target=0x0001:0xc000416c, DPL=0
IDT[0x04]=32-Bit Interrupt Gate target=0x0001:0xc0004178, DPL=0
IDT[0x05]=32-Bit Interrupt Gate target=0x0001:0xc0004184, DPL=0
IDT[0x06]=32-Bit Interrupt Gate target=0x0001:0xc0004190, DPL=0
IDT[0x07]=32-Bit Interrupt Gate target=0x0001:0xc000419c, DPL=0
IDT[0x08]=32-Bit Interrupt Gate target=0x0001:0xc00041a8, DPL=0
IDT[0x09]=32-Bit Interrupt Gate target=0x0001:0xc00041b0, DPL=0
IDT[0x0a]=32-Bit Interrupt Gate target=0x0001:0xc00041bc, DPL=0
IDT[0x0b]=32-Bit Interrupt Gate target=0x0001:0xc00041c4, DPL=0
IDT[0x0c]=32-Bit Interrupt Gate target=0x0001:0xc00041cc, DPL=0
IDT[0x0d]=32-Bit Interrupt Gate target=0x0001:0xc00041d4, DPL=0
IDT[0x0e]=32-Bit Interrupt Gate target=0x0001:0xc00041dc, DPL=0
IDT[0x0f]=32-Bit Interrupt Gate target=0x0001:0xc00041e4, DPL=0
IDT[0x10]=32-Bit Interrupt Gate target=0x0001:0xc00041f0, DPL=0
IDT[0x11]=32-Bit Interrupt Gate target=0x0001:0xc00041fc, DPL=0
IDT[0x12]=32-Bit Interrupt Gate target=0x0001:0xc0004208, DPL=0
IDT[0x13]=32-Bit Interrupt Gate target=0x0001:0xc0004214, DPL=0
IDT[0x14]=32-Bit Interrupt Gate target=0x0001:0xc0004220, DPL=0
IDT[0x15]=32-Bit Interrupt Gate target=0x0001:0xc000422c, DPL=0
IDT[0x16]=32-Bit Interrupt Gate target=0x0001:0xc0004238, DPL=0
IDT[0x17]=32-Bit Interrupt Gate target=0x0001:0xc0004244, DPL=0
IDT[0x18]=32-Bit Interrupt Gate target=0x0001:0xc0004250, DPL=0
IDT[0x19]=32-Bit Interrupt Gate target=0x0001:0xc000425c, DPL=0
IDT[0x1a]=32-Bit Interrupt Gate target=0x0001:0xc0004268, DPL=0
IDT[0x1b]=32-Bit Interrupt Gate target=0x0001:0xc0004274, DPL=0
IDT[0x1c]=32-Bit Interrupt Gate target=0x0001:0xc0004280, DPL=0
IDT[0x1d]=32-Bit Interrupt Gate target=0x0001:0xc000428c, DPL=0
IDT[0x1e]=32-Bit Interrupt Gate target=0x0001:0xc0004298, DPL=0
IDT[0x1f]=??? descriptor hi=0x00000000, lo=0x00000000
<...>
IDT[0xff]=??? descriptor hi=0x00000000, lo=0x00000000

在我看来,IDT 条目具有有效的 GDT 选择器,所以我不明白执行中断时是什么导致了问题:
<bochs:5> s                   ; step
(0).[36440222] [0x0000000000703044] 0008:00000000c0003044 (unk. ctxt): int3
CPU 0: Interrupt 0x03 occured (error_code=0x0000)
00036440222e[CPU0 ] int_trap_gate(): selector null
CPU 0: Exception 0x0d - (#GP) general protection fault occured (error_code=0x0000)
CPU 0: Interrupt 0x0d occured (error_code=0x0000)
00036440222e[CPU0 ] int_trap_gate(): selector null
CPU 0: Exception 0x0d - (#GP) general protection fault occured (error_code=0x0000)
CPU 0: Exception 0x08 - (#DF) double fault occured (error_code=0x0000)
CPU 0: Interrupt 0x08 occured (error_code=0x0000)
00036440222e[CPU0 ] int_trap_gate(): selector null
CPU 0: Exception 0x0d - (#GP) general protection fault occured (error_code=0x0000)

问题是什么?

最佳答案

这里:

IDT[0x03]=32-Bit Interrupt Gate target=0x0001:0xc000416c, DPL=0

0x0001 是选择器值。它的 2 个最低有效位是 RPL位。其余位用作段描述符表(GDT 或 LDT)的索引。这些位是 0。对于所有意图和目的,这是一个 NULL 选择器。

很可能你想要 8 个,而不是 1 个。

请参阅 CPU 文档了解如何使用选择器。

关于assembly - 为什么我的中断处理程序没有触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10598790/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com