diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2015-12-08 19:45:56 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2015-12-08 19:45:56 +0000 |
commit | 26e528f31ad7acdba365c3446b044bed991d3210 (patch) | |
tree | 5cc577d94c9908bb557c339ca37ce0bb76dbb9c9 /sys/arch/amd64 | |
parent | c4e44c96360a5b0d19616deaff9eecc41e81ca01 (diff) |
Set up an IDT vector for Xen callbacks
This adds support for delivering the combined Xen interrupt
that later fans out into event port specific (device specific)
interrupts via an IDT of a guest system.
The Xen IDT vector is set to be the first of the IPL_NET group
and is implemented the same way LAPIC timer and IPIs are done.
The additional machinery is there to be able to mask it via
standard mechanisms (e.g. splnet).
Discussed with kettenis@, OK mlarkin, reyk
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/intr.c | 18 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/lapic.c | 9 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/vector.S | 39 | ||||
-rw-r--r-- | sys/arch/amd64/include/i82489var.h | 9 | ||||
-rw-r--r-- | sys/arch/amd64/include/intrdefs.h | 3 |
5 files changed, 71 insertions, 7 deletions
diff --git a/sys/arch/amd64/amd64/intr.c b/sys/arch/amd64/amd64/intr.c index 022ae1f15cb..8ee118278b4 100644 --- a/sys/arch/amd64/amd64/intr.c +++ b/sys/arch/amd64/amd64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.46 2015/09/13 11:48:17 kettenis Exp $ */ +/* $OpenBSD: intr.c,v 1.47 2015/12/08 19:45:55 mikeb Exp $ */ /* $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $ */ /* @@ -54,6 +54,7 @@ #include "ioapic.h" #include "lapic.h" +#include "xen.h" #if NIOAPIC > 0 #include <machine/mpbiosvar.h> @@ -549,6 +550,9 @@ struct intrhand fake_softnet_intrhand; struct intrhand fake_softtty_intrhand; struct intrhand fake_timer_intrhand; struct intrhand fake_ipi_intrhand; +#if NXEN > 0 +struct intrhand fake_xen_intrhand; +#endif #if NLAPIC > 0 && defined(MULTIPROCESSOR) && 0 static char *x86_ipi_names[X86_NIPI] = X86_IPI_NAMES; @@ -613,9 +617,19 @@ cpu_intr_init(struct cpu_info *ci) isp->is_handlers = &fake_ipi_intrhand; isp->is_pic = &local_pic; ci->ci_isources[LIR_IPI] = isp; - #endif +#if NXEN > 0 + isp = malloc(sizeof (struct intrsource), M_DEVBUF, M_NOWAIT|M_ZERO); + if (isp == NULL) + panic("can't allocate fixed interrupt source"); + isp->is_recurse = Xrecurse_xen_upcall; + isp->is_resume = Xresume_xen_upcall; + fake_xen_intrhand.ih_level = IPL_NET; + isp->is_handlers = &fake_xen_intrhand; + isp->is_pic = &local_pic; + ci->ci_isources[LIR_XEN] = isp; #endif +#endif /* NLAPIC */ intr_calculatemasks(ci); diff --git a/sys/arch/amd64/amd64/lapic.c b/sys/arch/amd64/amd64/lapic.c index 29a8a6c71df..e39e656bb63 100644 --- a/sys/arch/amd64/amd64/lapic.c +++ b/sys/arch/amd64/amd64/lapic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lapic.c,v 1.41 2015/07/18 19:21:02 sf Exp $ */ +/* $OpenBSD: lapic.c,v 1.42 2015/12/08 19:45:55 mikeb Exp $ */ /* $NetBSD: lapic.c,v 1.2 2003/05/08 01:04:35 fvdl Exp $ */ /*- @@ -55,6 +55,7 @@ #include <dev/ic/i8253reg.h> #include "ioapic.h" +#include "xen.h" #if NIOAPIC > 0 #include <machine/i82093var.h> @@ -353,6 +354,12 @@ lapic_boot_init(paddr_t lapic_base) idt_allocmap[LAPIC_TIMER_VECTOR] = 1; idt_vec_set(LAPIC_TIMER_VECTOR, Xintr_lapic_ltimer); +#if NXEN > 0 + /* Xen HVM Event Channel Interrupt Vector */ + idt_allocmap[LAPIC_XEN_VECTOR] = 1; + idt_vec_set(LAPIC_XEN_VECTOR, Xintr_xen_upcall); +#endif + evcount_attach(&clk_count, "clock", &clk_irq); #ifdef MULTIPROCESSOR evcount_attach(&ipi_count, "ipi", &ipi_irq); diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S index 3d752abfc1e..f60d725215d 100644 --- a/sys/arch/amd64/amd64/vector.S +++ b/sys/arch/amd64/amd64/vector.S @@ -1,4 +1,4 @@ -/* $OpenBSD: vector.S,v 1.43 2015/07/17 15:37:58 guenther Exp $ */ +/* $OpenBSD: vector.S,v 1.44 2015/12/08 19:45:55 mikeb Exp $ */ /* $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $ */ /* @@ -83,6 +83,7 @@ #include "ioapic.h" #include "lapic.h" #include "assym.h" +#include "xen.h" /*****************************************************************************/ @@ -435,8 +436,42 @@ IDTVEC(resume_lapic_ltimer) movq $(1 << LIR_TIMER),%rax orq %rax,CPUVAR(IPENDING) INTRFASTEXIT -#endif /* NLAPIC > 0 */ +#if NXEN > 0 +/* + * Xen event channel upcall interrupt handler. + * Only used when the hypervisor supports direct vector callbacks. + */ +IDTVEC(recurse_xen_upcall) + INTR_RECURSE_HWFRAME + pushq $0 + subq $8,%rsp /* unused __if_trapno */ + INTRENTRY + jmp 1f +IDTVEC(intr_xen_upcall) + pushq $0 + subq $8,%rsp /* unused __if_trapno */ + INTRENTRY + call _C_LABEL(xen_intr_ack) + movl CPUVAR(ILEVEL),%ebx + cmpl $IPL_NET,%ebx + jae 2f +IDTVEC(resume_xen_upcall) +1: + incl CPUVAR(IDEPTH) + movl $IPL_NET,CPUVAR(ILEVEL) + sti + cld + pushq %rbx + call _C_LABEL(xen_intr) + jmp _C_LABEL(Xdoreti) +2: + movq $(1 << LIR_XEN),%rax + orq %rax,CPUVAR(IPENDING) +3: + INTRFASTEXIT +#endif /* NXEN > 0 */ +#endif /* NLAPIC > 0 */ #define voidop(num) diff --git a/sys/arch/amd64/include/i82489var.h b/sys/arch/amd64/include/i82489var.h index 4eb199984d2..e67c97bc777 100644 --- a/sys/arch/amd64/include/i82489var.h +++ b/sys/arch/amd64/include/i82489var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: i82489var.h,v 1.15 2015/04/19 19:45:21 sf Exp $ */ +/* $OpenBSD: i82489var.h,v 1.16 2015/12/08 19:45:55 mikeb Exp $ */ /* $NetBSD: i82489var.h,v 1.1 2003/02/26 21:26:10 fvdl Exp $ */ /*- @@ -99,6 +99,13 @@ extern void Xintr_lapic3(void); extern void Xintr_lapic4(void); extern void Xintr_lapic5(void); +/* + * Vector used for Xen HVM Event Channel Interrupts. + */ +extern void Xintr_xen_upcall(void); +extern void Xresume_xen_upcall(void); +extern void Xrecurse_xen_upcall(void); +#define LAPIC_XEN_VECTOR 0x70 struct cpu_info; diff --git a/sys/arch/amd64/include/intrdefs.h b/sys/arch/amd64/include/intrdefs.h index 0d152869613..27d41d5a6ac 100644 --- a/sys/arch/amd64/include/intrdefs.h +++ b/sys/arch/amd64/include/intrdefs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intrdefs.h,v 1.14 2015/11/13 07:52:20 mlarkin Exp $ */ +/* $OpenBSD: intrdefs.h,v 1.15 2015/12/08 19:45:55 mikeb Exp $ */ /* $NetBSD: intrdefs.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */ #ifndef _AMD64_INTRDEFS_H @@ -54,6 +54,7 @@ #define SIR_NET 60 #define SIR_TTY 59 +#define LIR_XEN 58 /* * Maximum # of interrupt sources per CPU. 64 to fit in one word. |