linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH 0/6] x86/traps,VMX: implement software based NMI/IRQ dispatch for VMX NMI/IRQ reinjection
@ 2022-11-10  6:15 Xin Li
  2022-11-10  6:15 ` [RESEND PATCH 1/6] x86/traps: let common_interrupt() handle IRQ_MOVE_CLEANUP_VECTOR Xin Li
                   ` (5 more replies)
  0 siblings, 6 replies; 56+ messages in thread
From: Xin Li @ 2022-11-10  6:15 UTC (permalink / raw)
  To: linux-kernel, x86, kvm
  Cc: tglx, mingo, bp, dave.hansen, hpa, seanjc, pbonzini, kevin.tian

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(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2022-11-28 19:05 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10  6:15 [RESEND PATCH 0/6] x86/traps,VMX: implement software based NMI/IRQ dispatch for VMX NMI/IRQ reinjection Xin Li
2022-11-10  6:15 ` [RESEND PATCH 1/6] x86/traps: let common_interrupt() handle IRQ_MOVE_CLEANUP_VECTOR Xin Li
2022-11-10 18:59   ` Ashok Raj
2022-11-10 22:09     ` Li, Xin3
2022-11-10  6:15 ` [RESEND PATCH 2/6] x86/traps: add a system interrupt table for system interrupt dispatch Xin Li
2022-11-10  8:56   ` Peter Zijlstra
2022-11-10 19:55     ` Li, Xin3
2022-11-10 20:36       ` Li, Xin3
2022-11-10 21:12         ` Nathan Chancellor
2022-11-10 23:00           ` Li, Xin3
2022-11-11  0:08             ` Nathan Chancellor
2022-11-11  3:03               ` Li, Xin3
2022-11-11  8:58         ` Peter Zijlstra
2022-11-11  1:12       ` Tian, Kevin
2022-11-11  3:54         ` Li, Xin3
2022-11-11  8:55       ` Peter Zijlstra
2022-11-11 22:07       ` H. Peter Anvin
2022-11-12  9:47         ` Peter Zijlstra
2022-11-10  6:15 ` [RESEND PATCH 3/6] x86/traps: add install_system_interrupt_handler() Xin Li
2022-11-10  6:15 ` [RESEND PATCH 4/6] x86/traps: add external_interrupt() to dispatch external interrupts Xin Li
2022-11-10 16:24   ` Sean Christopherson
2022-11-10 18:02     ` Li, Xin3
2022-11-10 20:10       ` Sean Christopherson
2022-11-10  6:15 ` [RESEND PATCH 5/6] KVM: x86/VMX: add kvm_vmx_reinject_nmi_irq() for NMI/IRQ reinjection Xin Li
2022-11-10  9:03   ` Peter Zijlstra
2022-11-10 20:53     ` Li, Xin3
2022-11-11  9:15       ` Peter Zijlstra
2022-11-11 12:04         ` Paolo Bonzini
2022-11-11 12:19           ` Peter Zijlstra
2022-11-11 12:48             ` Paolo Bonzini
2022-11-11 14:23               ` Peter Zijlstra
2022-11-11 16:35                 ` Andrew Cooper
2022-11-11 22:22                   ` H. Peter Anvin
2022-11-12  0:08                     ` Andrew Cooper
2022-11-11 18:06                 ` Li, Xin3
2022-11-11 19:33                   ` Peter Zijlstra
2022-11-12  6:35                     ` Li, Xin3
2022-11-14  4:39                     ` Li, Xin3
2022-11-14  9:08                       ` Peter Zijlstra
2022-11-15  7:50                         ` Li, Xin3
2022-11-15  9:17                           ` Peter Zijlstra
2022-11-17  3:37                             ` Li, Xin3
2022-11-17 15:51                               ` Sean Christopherson
2022-11-18  0:05                                 ` Li, Xin3
2022-11-22 13:00                                   ` Li, Xin3
2022-11-22 20:52                                     ` Sean Christopherson
2022-11-23  8:31                                       ` Li, Xin3
2022-11-23 20:42                                         ` Sean Christopherson
2022-11-24  3:40                                           ` Li, Xin3
2022-11-28 16:26                                             ` Sean Christopherson
2022-11-24  9:46                                           ` Peter Zijlstra
2022-11-28 19:05                                             ` Sean Christopherson
2022-11-23  9:16                                       ` Peter Zijlstra
2022-11-23 19:18                                         ` Sean Christopherson
2022-11-11 22:15                 ` H. Peter Anvin
2022-11-10  6:15 ` [RESEND PATCH 6/6] x86/traps: remove unused NMI entry exc_nmi_noist() Xin Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).