diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2016-06-22 01:12:39 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2016-06-22 01:12:39 +0000 |
commit | 32245e4d12d02d78f28ec658568a7b77e78b0a74 (patch) | |
tree | 6589a39751de00f4e6398700e2700aa7ce86b696 | |
parent | 5d351881addd31e06f2da01f50040cf2fcd2b46c (diff) |
Setup Hyper-V hypercall page and an IDT vector.
ok mlarkin, kettenis, deraadt
-rw-r--r-- | sys/arch/amd64/amd64/intr.c | 17 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/lapic.c | 8 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/locore.S | 12 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/vector.S | 37 | ||||
-rw-r--r-- | sys/arch/amd64/include/i82489var.h | 10 | ||||
-rw-r--r-- | sys/arch/amd64/include/intrdefs.h | 3 |
6 files changed, 81 insertions, 6 deletions
diff --git a/sys/arch/amd64/amd64/intr.c b/sys/arch/amd64/amd64/intr.c index 8ee118278b4..15698844914 100644 --- a/sys/arch/amd64/amd64/intr.c +++ b/sys/arch/amd64/amd64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.47 2015/12/08 19:45:55 mikeb Exp $ */ +/* $OpenBSD: intr.c,v 1.48 2016/06/22 01:12:38 mikeb Exp $ */ /* $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $ */ /* @@ -55,6 +55,7 @@ #include "ioapic.h" #include "lapic.h" #include "xen.h" +#include "hyperv.h" #if NIOAPIC > 0 #include <machine/mpbiosvar.h> @@ -553,6 +554,9 @@ struct intrhand fake_ipi_intrhand; #if NXEN > 0 struct intrhand fake_xen_intrhand; #endif +#if NHYPERV > 0 +struct intrhand fake_hyperv_intrhand; +#endif #if NLAPIC > 0 && defined(MULTIPROCESSOR) && 0 static char *x86_ipi_names[X86_NIPI] = X86_IPI_NAMES; @@ -629,6 +633,17 @@ cpu_intr_init(struct cpu_info *ci) isp->is_pic = &local_pic; ci->ci_isources[LIR_XEN] = isp; #endif +#if NHYPERV > 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_hyperv_upcall; + isp->is_resume = Xresume_hyperv_upcall; + fake_hyperv_intrhand.ih_level = IPL_NET; + isp->is_handlers = &fake_hyperv_intrhand; + isp->is_pic = &local_pic; + ci->ci_isources[LIR_HYPERV] = isp; +#endif #endif /* NLAPIC */ intr_calculatemasks(ci); diff --git a/sys/arch/amd64/amd64/lapic.c b/sys/arch/amd64/amd64/lapic.c index 18b51a4cbb4..ad5ebb6f900 100644 --- a/sys/arch/amd64/amd64/lapic.c +++ b/sys/arch/amd64/amd64/lapic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lapic.c,v 1.43 2016/03/06 22:41:24 naddy Exp $ */ +/* $OpenBSD: lapic.c,v 1.44 2016/06/22 01:12:38 mikeb Exp $ */ /* $NetBSD: lapic.c,v 1.2 2003/05/08 01:04:35 fvdl Exp $ */ /*- @@ -56,6 +56,7 @@ #include "ioapic.h" #include "xen.h" +#include "hyperv.h" #if NIOAPIC > 0 #include <machine/i82093var.h> @@ -359,6 +360,11 @@ lapic_boot_init(paddr_t lapic_base) idt_allocmap[LAPIC_XEN_VECTOR] = 1; idt_vec_set(LAPIC_XEN_VECTOR, Xintr_xen_upcall); #endif +#if NHYPERV > 0 + /* Hyper-V Interrupt Vector */ + idt_allocmap[LAPIC_HYPERV_VECTOR] = 1; + idt_vec_set(LAPIC_HYPERV_VECTOR, Xintr_hyperv_upcall); +#endif evcount_attach(&clk_count, "clock", &clk_irq); #ifdef MULTIPROCESSOR diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S index a147f3dfcd2..52ae39cce42 100644 --- a/sys/arch/amd64/amd64/locore.S +++ b/sys/arch/amd64/amd64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.80 2016/06/06 06:02:02 deraadt Exp $ */ +/* $OpenBSD: locore.S,v 1.81 2016/06/22 01:12:38 mikeb Exp $ */ /* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */ /* @@ -110,6 +110,7 @@ #include "ksyms.h" #include "acpi.h" #include "xen.h" +#include "hyperv.h" #include <sys/errno.h> #include <sys/syscall.h> @@ -1195,3 +1196,12 @@ _C_LABEL(codepatch_end): _C_LABEL(xen_hypercall_page): .skip 0x1000, 0xcc #endif /* NXEN > 0 */ + +#if NHYPERV > 0 + /* Hypercall page needs to be page aligned */ + .text + .align NBPG, 0xcc + .globl _C_LABEL(hv_hypercall_page) +_C_LABEL(hv_hypercall_page): + .skip 0x1000, 0xcc +#endif /* NXEN > 0 */ diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S index 81759f91742..137ede9334c 100644 --- a/sys/arch/amd64/amd64/vector.S +++ b/sys/arch/amd64/amd64/vector.S @@ -1,4 +1,4 @@ -/* $OpenBSD: vector.S,v 1.45 2016/03/03 12:32:23 mpi Exp $ */ +/* $OpenBSD: vector.S,v 1.46 2016/06/22 01:12:38 mikeb Exp $ */ /* $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $ */ /* @@ -84,6 +84,7 @@ #include "lapic.h" #include "assym.h" #include "xen.h" +#include "hyperv.h" /*****************************************************************************/ @@ -468,6 +469,40 @@ IDTVEC(resume_xen_upcall) 3: INTRFASTEXIT #endif /* NXEN > 0 */ + +#if NHYPERV > 0 +/* + * Hyperv event channel upcall interrupt handler. + * Only used when the hypervisor supports direct vector callbacks. + */ +IDTVEC(recurse_hyperv_upcall) + INTR_RECURSE_HWFRAME + pushq $0 + subq $8,%rsp /* unused __if_trapno */ + INTRENTRY + jmp 1f +IDTVEC(intr_hyperv_upcall) + pushq $0 + subq $8,%rsp /* unused __if_trapno */ + INTRENTRY + movl CPUVAR(ILEVEL),%ebx + cmpl $IPL_NET,%ebx + jae 2f +IDTVEC(resume_hyperv_upcall) +1: + incl CPUVAR(IDEPTH) + movl $IPL_NET,CPUVAR(ILEVEL) + sti + cld + pushq %rbx + call _C_LABEL(hv_intr) + jmp _C_LABEL(Xdoreti) +2: + movq $(1 << LIR_HYPERV),%rax + orq %rax,CPUVAR(IPENDING) +3: + INTRFASTEXIT +#endif /* NHYPERV > 0 */ #endif /* NLAPIC > 0 */ #define voidop(num) diff --git a/sys/arch/amd64/include/i82489var.h b/sys/arch/amd64/include/i82489var.h index e67c97bc777..746e3436d93 100644 --- a/sys/arch/amd64/include/i82489var.h +++ b/sys/arch/amd64/include/i82489var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: i82489var.h,v 1.16 2015/12/08 19:45:55 mikeb Exp $ */ +/* $OpenBSD: i82489var.h,v 1.17 2016/06/22 01:12:38 mikeb Exp $ */ /* $NetBSD: i82489var.h,v 1.1 2003/02/26 21:26:10 fvdl Exp $ */ /*- @@ -107,6 +107,14 @@ extern void Xresume_xen_upcall(void); extern void Xrecurse_xen_upcall(void); #define LAPIC_XEN_VECTOR 0x70 +/* + * Vector used for Hyper-V Interrupts. + */ +extern void Xintr_hyperv_upcall(void); +extern void Xresume_hyperv_upcall(void); +extern void Xrecurse_hyperv_upcall(void); +#define LAPIC_HYPERV_VECTOR 0x71 + struct cpu_info; extern void lapic_boot_init(paddr_t); diff --git a/sys/arch/amd64/include/intrdefs.h b/sys/arch/amd64/include/intrdefs.h index 27d41d5a6ac..2cfe0ba61b6 100644 --- a/sys/arch/amd64/include/intrdefs.h +++ b/sys/arch/amd64/include/intrdefs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intrdefs.h,v 1.15 2015/12/08 19:45:55 mikeb Exp $ */ +/* $OpenBSD: intrdefs.h,v 1.16 2016/06/22 01:12:38 mikeb Exp $ */ /* $NetBSD: intrdefs.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */ #ifndef _AMD64_INTRDEFS_H @@ -55,6 +55,7 @@ #define SIR_TTY 59 #define LIR_XEN 58 +#define LIR_HYPERV 57 /* * Maximum # of interrupt sources per CPU. 64 to fit in one word. |