-/* $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 $ */
/*
#include "ioapic.h"
#include "lapic.h"
#include "xen.h"
+#include "hyperv.h"
#if NIOAPIC > 0
#include <machine/mpbiosvar.h>
#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;
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);
-/* $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 $ */
/*-
#include "ioapic.h"
#include "xen.h"
+#include "hyperv.h"
#if NIOAPIC > 0
#include <machine/i82093var.h>
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
-/* $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 $ */
/*
#include "ksyms.h"
#include "acpi.h"
#include "xen.h"
+#include "hyperv.h"
#include <sys/errno.h>
#include <sys/syscall.h>
_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 */
-/* $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 $ */
/*
#include "lapic.h"
#include "assym.h"
#include "xen.h"
+#include "hyperv.h"
/*****************************************************************************/
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)
-/* $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 $ */
/*-
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);
-/* $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
#define SIR_TTY 59
#define LIR_XEN 58
+#define LIR_HYPERV 57
/*
* Maximum # of interrupt sources per CPU. 64 to fit in one word.