Skip to content

Commit f6b3c72

Browse files
Feng WuKAGA-KOKO
authored andcommitted
x86/irq: Define a global vector for VT-d Posted-Interrupts
Currently, we use a global vector as the Posted-Interrupts Notification Event for all the vCPUs in the system. We need to introduce another global vector for VT-d Posted-Interrtups, which will be used to wakeup the sleep vCPU when an external interrupt from a direct-assigned device happens for that vCPU. [ tglx: Removed a gazillion of extra newlines ] Signed-off-by: Feng Wu <feng.wu@intel.com> Cc: jiang.liu@linux.intel.com Link: http://lkml.kernel.org/r/1432026437-16560-4-git-send-email-feng.wu@intel.com Suggested-by: Yang Zhang <yang.z.zhang@intel.com> Acked-by: H. Peter Anvin <hpa@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent a2f1c8b commit f6b3c72

File tree

8 files changed

+40
-0
lines changed

8 files changed

+40
-0
lines changed

arch/x86/include/asm/entry_arch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR)
2323
#ifdef CONFIG_HAVE_KVM
2424
BUILD_INTERRUPT3(kvm_posted_intr_ipi, POSTED_INTR_VECTOR,
2525
smp_kvm_posted_intr_ipi)
26+
BUILD_INTERRUPT3(kvm_posted_intr_wakeup_ipi, POSTED_INTR_WAKEUP_VECTOR,
27+
smp_kvm_posted_intr_wakeup_ipi)
2628
#endif
2729

2830
/*

arch/x86/include/asm/hardirq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ typedef struct {
1414
#endif
1515
#ifdef CONFIG_HAVE_KVM
1616
unsigned int kvm_posted_intr_ipis;
17+
unsigned int kvm_posted_intr_wakeup_ipis;
1718
#endif
1819
unsigned int x86_platform_ipis; /* arch dependent */
1920
unsigned int apic_perf_irqs;

arch/x86/include/asm/hw_irq.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
extern asmlinkage void apic_timer_interrupt(void);
3030
extern asmlinkage void x86_platform_ipi(void);
3131
extern asmlinkage void kvm_posted_intr_ipi(void);
32+
extern asmlinkage void kvm_posted_intr_wakeup_ipi(void);
3233
extern asmlinkage void error_interrupt(void);
3334
extern asmlinkage void irq_work_interrupt(void);
3435

@@ -58,6 +59,7 @@ extern void trace_call_function_single_interrupt(void);
5859
#define trace_irq_move_cleanup_interrupt irq_move_cleanup_interrupt
5960
#define trace_reboot_interrupt reboot_interrupt
6061
#define trace_kvm_posted_intr_ipi kvm_posted_intr_ipi
62+
#define trace_kvm_posted_intr_wakeup_ipi kvm_posted_intr_wakeup_ipi
6163
#endif /* CONFIG_TRACING */
6264

6365
#ifdef CONFIG_X86_LOCAL_APIC

arch/x86/include/asm/irq.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ extern void fixup_irqs(void);
3030
extern void irq_force_complete_move(int);
3131
#endif
3232

33+
#ifdef CONFIG_HAVE_KVM
34+
extern void kvm_set_posted_intr_wakeup_handler(void (*handler)(void));
35+
#endif
36+
3337
extern void (*x86_platform_ipi_callback)(void);
3438
extern void native_init_IRQ(void);
3539
extern bool handle_irq(unsigned irq, struct pt_regs *regs);

arch/x86/include/asm/irq_vectors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
/* Vector for KVM to deliver posted interrupt IPI */
8787
#ifdef CONFIG_HAVE_KVM
8888
#define POSTED_INTR_VECTOR 0xf2
89+
#define POSTED_INTR_WAKEUP_VECTOR 0xf1
8990
#endif
9091

9192
/*

arch/x86/kernel/entry_64.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,8 @@ apicinterrupt X86_PLATFORM_IPI_VECTOR \
916916
#ifdef CONFIG_HAVE_KVM
917917
apicinterrupt3 POSTED_INTR_VECTOR \
918918
kvm_posted_intr_ipi smp_kvm_posted_intr_ipi
919+
apicinterrupt3 POSTED_INTR_WAKEUP_VECTOR \
920+
kvm_posted_intr_wakeup_ipi smp_kvm_posted_intr_wakeup_ipi
919921
#endif
920922

921923
#ifdef CONFIG_X86_MCE_THRESHOLD

arch/x86/kernel/irq.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,18 @@ __visible void smp_x86_platform_ipi(struct pt_regs *regs)
242242
}
243243

244244
#ifdef CONFIG_HAVE_KVM
245+
static void dummy_handler(void) {}
246+
static void (*kvm_posted_intr_wakeup_handler)(void) = dummy_handler;
247+
248+
void kvm_set_posted_intr_wakeup_handler(void (*handler)(void))
249+
{
250+
if (handler)
251+
kvm_posted_intr_wakeup_handler = handler;
252+
else
253+
kvm_posted_intr_wakeup_handler = dummy_handler;
254+
}
255+
EXPORT_SYMBOL_GPL(kvm_set_posted_intr_wakeup_handler);
256+
245257
/*
246258
* Handler for POSTED_INTERRUPT_VECTOR.
247259
*/
@@ -254,6 +266,20 @@ __visible void smp_kvm_posted_intr_ipi(struct pt_regs *regs)
254266
exiting_irq();
255267
set_irq_regs(old_regs);
256268
}
269+
270+
/*
271+
* Handler for POSTED_INTERRUPT_WAKEUP_VECTOR.
272+
*/
273+
__visible void smp_kvm_posted_intr_wakeup_ipi(struct pt_regs *regs)
274+
{
275+
struct pt_regs *old_regs = set_irq_regs(regs);
276+
277+
entering_ack_irq();
278+
inc_irq_stat(kvm_posted_intr_wakeup_ipis);
279+
kvm_posted_intr_wakeup_handler();
280+
exiting_irq();
281+
set_irq_regs(old_regs);
282+
}
257283
#endif
258284

259285
__visible void smp_trace_x86_platform_ipi(struct pt_regs *regs)

arch/x86/kernel/irqinit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ static void __init apic_intr_init(void)
144144
#ifdef CONFIG_HAVE_KVM
145145
/* IPI for KVM to deliver posted interrupt */
146146
alloc_intr_gate(POSTED_INTR_VECTOR, kvm_posted_intr_ipi);
147+
/* IPI for KVM to deliver interrupt to wake up tasks */
148+
alloc_intr_gate(POSTED_INTR_WAKEUP_VECTOR, kvm_posted_intr_wakeup_ipi);
147149
#endif
148150

149151
/* IPI vectors for APIC spurious and error interrupts */

0 commit comments

Comments
 (0)