do_IRQ 處理文件:arch/x86/vmx/vmx.c → vmx_vmexit_handler()
switch (exit_reason) {
case EXIT_REASON_EXCEPTION_NMI: {
unsigned int intr_info = __vmread(VM_EXIT_INTR_INFO);
BUG_ON(!(intr_info & INTR_INFO_VALID_MASK));
unsigned int vector = intr_info & INTR_INFO_VECTOR_MASK;
// 【Hook 點】中斷向量攔截
if (hook_idt) {
joan_dprintk("Int:%d\n", vector);
}
// 處理 NMI 陰影、IRET 故障等...
}
}
文件:arch/x86/irq.c → do_IRQ()
spin_lock(&desc->lock);
desc->handler->ack(vector);
if (likely(desc->status & IRQ_GUEST)) {
// 【Hook 點】Guest 中斷攔截
if (hook_idt) {
joan_dprintk("Int:%d\n", vector);
}
irq_enter();
__do_IRQ_guest(vector);
irq_exit();
spin_unlock(&desc->lock);
return;
}
// Host 中斷處理邏輯...
while (desc->status & IRQ_PENDING) {
// 【Hook 點】併發處理循環攔截
if (hook_idt) {
joan_dprintk("Int:%d\n", vector);
}
// ...
}
irq_enter() 之前,縮短高 IRQL 執行時間spin_lock 保護 irq_desc,Hook 內不得睡眠hook_idt 內核參數/proc/interrupts 驗證分發正確性Xen Guest 中斷處理呈現「硬件經 VM-exit、軟件經 do_IRQ」雙軌制。關鍵 Hook 點位於 vmx_vmexit_handler 異常分支與 do_IRQ Guest 分支。掌握此架構對虛擬化安全監控、性能分析、設備直通開發至關重要。