如何在同一系统上发送 nmi
我需要在我正在使用的系统上发送 nmi。我想测试我已经实现的一些东西。有没有 Windows 驱动程序例程可以让我们做到这一点?我想我可以使用 __outword 写入端口。还有其他方法吗?
我还有一个问题。是否有任何特定情况会导致 NMI? (但是,我不希望系统出现 BSOD 或三重故障。)
谢谢
I need to send an nmi on the system I am working on. I want to test few things which I have implemented. Is there any windows driver routine which allows us to do that? I think I can write to a port using __outword. Is there any other way to do it?
I have one more question. Are there any specific scenarios which causes an NMI? (However, I dont want system to BSOD or triple fault.)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 英特尔软件开发手册:系统编程指南:
和
因此,如果您只想触发 NMI 处理程序,则只需使用
int $2
(英特尔语法中的int 02h
)即可。但是,如果您需要确保它不被屏蔽,则需要外部硬件来触发它,或者使用 APIC。如果您选择使用 APIC 发送 NMI,最简单的方法是发送处理器间中断。为此,您需要访问本地 APIC 的寄存器,这些寄存器映射到物理内存,默认位于地址 0xFEE00000,尽管可以更改。您需要找到包含 APIC 寄存器的物理页并将其映射到虚拟内存中,以便您可以访问它们。
为了发送IPI,您需要写入中断配置寄存器。 ICR 的低 32 位位于 APIC 页内的 0x300,高 32 位位于 0x310。要发送 NMI,您需要:
写入 APIC 寄存器时,必须写入完整的 32 位值。此外,ICR 中的位 13、16-17 和 20-55 是保留的,因此不应更改它们的值。您还必须在写入低位之前写入 ICR 的高位,因为 IPI 是由写入低位触发的。
下面是用 C 语言向当前处理器发送 NMI 的示例。
From Intel's Software Development Manual: System Programming Guide:
and
So, if all you want to do is trigger the NMI handler, you can simply use
int $2
(int 02h
in Intel syntax). But, if you need to ensure that it is not masked, you will either need external hardware to trigger it, or to use the APIC.If you choose to use the APIC to send an NMI, the easiest way to do it is to send an inter-processor interrupt. To do this, you will need access to the local APIC's registers, which are mapped into physical memory, by default at the address 0xFEE00000, although that can be changed. You will need to find the physical page containing the APIC's registers and map it into virtual memory so that you can access them.
In order to send an IPI, you need to write into the interrupt configuration register. The ICR's low 32 bits are located at 0x300 within the APIC's page, and the upper 32 bits are at 0x310. To send the NMI, you need to:
When writing to an APIC register, you must write a full 32 bit value. Also, bits 13, 16-17, and 20-55 in the ICR are reserved, so you should not change their values. You also must write to the high bits of the ICR before the low bits, since the IPI is triggered by the write to the low bits.
Here is an example of sending an NMI to the current processor in C.