"Acknowledge interrupt on exit" VT-x 中的控制导致 CPU 锁定

"Acknowledge interrupt on exit" control in VT-x causes CPU lockup

我正致力于在我正在编写的使用 Intel VT-x 虚拟化的 VMM 中支持发布中断。启用发布中断的文档中指定的 VM 进入要求之一是 "Acknowledge interrupt on exit" VM 退出控制必须设置为 1。

当我将此控件设置为 1 时,我的来宾 OS 在停止响应之前运行了一小段时间。然后,主机 OS 也停止响应,并向主机内核日志打印一条消息,指出来宾 OS 所在的 CPU 内核 运行经历了一次硬锁定(NMI watchdog: Watchdog detected hard LOCKUP on cpu 10)。

我正在阅读英特尔文档并试图仔细思考这个问题,但想知道是否还有其他人知道发生了什么。我现在的一般想法是,主机 OS 必须向客户机 OS 正在 运行 的核心发送中断(即我的客户机 OS 正在不参与发送中断),这会导致 VM 退出。由于我将 "Acknowledge interrupt on exit" 控件设置为 1,处理器向中断控制器确认收到中断,并将向量放入 VM-exit 中断信息字段。此外,由于我目前没有对我的 VMM 中的中断信息字段执行任何操作,因此中断不会被主机 OS 处理,这导致了问题。我的方向对吗?

是的,不允许主机 OS 处理设备中断将是一个问题。与其将 "acknowledge interrupt on exit" 控件设置为 1,不如将其设置为 0。然后,当由于硬件中断导致 VM 退出时,您应该设置处理器中断启用标志以允许中断被正常确认和服务在主机中。

来自 Intel 64 和 IA-32 架构软件开发人员手册:

33.2 INTERRUPT HANDLING IN VMX OPERATION

  • Acknowledge interrupt on exit. The “acknowledge interrupt on exit” VM-exit control in the controlling VMCS controls processor behavior for external interrupt acknowledgement. If the control is 1, the processor acknowledges the interrupt controller to acquire the interrupt vector upon VM exit, and stores the vector in the VM-exit interruption-information field. If the control is 0, the external interrupt is not acknowledged during VM exit. Since RFLAGS.IF is automatically cleared on VM exits due to external interrupts, VMM re-enabling of interrupts (setting RFLAGS.IF = 1) initiates the external interrupt acknowledgement and vectoring of the external interrupt through the monitor/host IDT

或者,如果你有充分的理由设置这个位,比如你需要将某些硬件中断路由到客户机,那么你需要调用主机 OS 的中断处理程序就好像它是由 CPU.

调用的一样