Skip to content

x86/traps,VMX: implement software based NMI/IRQ dispatch for VMX NMI/IRQ reinjection

Xin Li kvm lkml llvm 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v1 Latest posting 2/26 patches 49 repliesIn review
  2. v1 posting 1/26 patches 11 repliesSuperseded

Patches in v1 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6x86/traps: let common_interrupt() handle IRQ_MOVE_CLEANUP_VECTORarch/x86/kernel/irq.c+4 -02 replies
2/6x86/traps: add a system interrupt table for system interrupt dispatcharch/x86/include/asm/traps.h arch/x86/kernel/traps.c+63 -013 replies
3/6x86/traps: add install_system_interrupt_handler()arch/x86/include/asm/traps.h arch/x86/kernel/cpu/acrn.c arch/x86/kernel/cpu/mshyperv.c +3 more+37 -130 replies
4/6x86/traps: add external_interrupt() to dispatch external interruptsarch/x86/kernel/traps.c+21 -03 replies
5/6KVM: x86/VMX: add kvm_vmx_reinject_nmi_irq() for NMI/IRQ reinjectionarch/x86/include/asm/traps.h arch/x86/kernel/traps.c arch/x86/kvm/vmx/vmenter.S +1 more+32 -4531 replies
6/6x86/traps: remove unused NMI entry exc_nmi_noist()arch/x86/include/asm/idtentry.h arch/x86/kernel/nmi.c+0 -250 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RESEND PATCH 0/6] x86/traps,VMX: implement software based NMI/IRQ dispatch for VMX NMI/IRQ reinjection

Resend for a typo in the LKML address in the previous patch sending.

Upon receiving an external interrupt, KVM VMX reinjects it through calling the interrupt handler in its IDT descriptor on the current kernel stack, which essentially uses the IDT as an interrupt dispatch table.

However the IDT is one of the lowest level critical data structures between a x86 CPU and the Linux kernel, we should avoid using it *directly* whenever possible, espeically in a software defined manner.

On x86, external interrupts are divided into the following groups
1) system interrupts
2) external device interrupts
With the IDT, system interrupts are dispatched through the IDT directly, while external device interrupts are all routed to the external interrupt dispatch function common_interrupt(), which dispatches external device interrupts through a per-CPU external interrupt dispatch table vector_irq.

Implement software based NMI/IRQ dispatch for VMX NMI/IRQ reinjection to eliminate dispatching external interrupts through the IDT with adding a system interrupt handler table for dispatching a system interrupt to its corresponding handler directly. Thus a software based dispatch function will be:

  void external_interrupt(struct pt_regs *regs, u8 vector)
  {
    if (is_system_interrupt(vector))
      system_interrupt_handler_table[vector_to_sysvec(vector)](regs);
    else /* external device interrupt */
      common_interrupt(regs, vector);
  }

And the software dispatch approach nukes a bunch of assembly.

What's more, with the Intel FRED (Flexible Return and Event Delivery) architecture, IDT, the hardware based event dispatch table, is gone, and the Linux kernel needs to dispatch events to their handlers with vector to handler mappings, the dispatch function external_interrupt() is also needed.

H. Peter Anvin (Intel) (1):
x86/traps: let common_interrupt() handle IRQ_MOVE_CLEANUP_VECTOR

Xin Li (5):
x86/traps: add a system interrupt table for system interrupt dispatch x86/traps: add install_system_interrupt_handler() x86/traps: add external_interrupt() to dispatch external interrupts
KVM: x86/VMX: add kvm_vmx_reinject_nmi_irq() for NMI/IRQ reinjection x86/traps: remove unused NMI entry exc_nmi_noist()

 arch/x86/include/asm/idtentry.h  |  15 -----
 arch/x86/include/asm/traps.h     |  12 ++++
 arch/x86/kernel/cpu/acrn.c       |   7 +-
 arch/x86/kernel/cpu/mshyperv.c   |  22 ++++---
 arch/x86/kernel/irq.c            |   4 ++
 arch/x86/kernel/kvm.c            |   4 +-
 arch/x86/kernel/nmi.c            |  10 ---
 arch/x86/kernel/traps.c          | 107 +++++++++++++++++++++++++++++++
 arch/x86/kvm/vmx/vmenter.S       |  33 ----------
 arch/x86/kvm/vmx/vmx.c           |  19 ++----
 drivers/xen/events/events_base.c |   5 +-
 11 files changed, 156 insertions(+), 82 deletions(-)
Signature · 1 line
2.34.1