Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Added Microsoft Hyper-V support. It ported from OpenBSD...
details: https://anonhg.NetBSD.org/src/rev/126d69463098
branches: trunk
changeset: 448948:126d69463098
user: nonaka <nonaka%NetBSD.org@localhost>
date: Fri Feb 15 08:54:01 2019 +0000
description:
Added Microsoft Hyper-V support. It ported from OpenBSD and FreeBSD.
graphical console is not work on Gen.2 VM yet. To use the serial console,
enter "consdev com,0x3f8,115200" on efiboot.
diffstat:
sys/arch/amd64/amd64/genassym.cf | 4 +-
sys/arch/amd64/amd64/vector.S | 47 +-
sys/arch/amd64/conf/GENERIC | 13 +-
sys/arch/amd64/conf/files.amd64 | 8 +-
sys/arch/i386/conf/GENERIC | 13 +-
sys/arch/i386/conf/files.i386 | 8 +-
sys/arch/i386/i386/genassym.cf | 4 +-
sys/arch/i386/i386/vector.S | 46 +-
sys/arch/x86/conf/files.x86 | 6 +-
sys/arch/x86/include/cpu.h | 4 +-
sys/arch/x86/include/intrdefs.h | 13 +-
sys/arch/x86/isa/clock.c | 8 +-
sys/arch/x86/x86/cpu.c | 16 +-
sys/arch/x86/x86/hyperv.c | 919 ++++++++++++++++
sys/arch/x86/x86/hypervreg.h | 155 ++
sys/arch/x86/x86/intr.c | 33 +-
sys/arch/x86/x86/lapic.c | 50 +-
sys/arch/x86/x86/x86_machdep.c | 35 +-
sys/dev/acpi/vmbus_acpi.c | 106 +
sys/dev/hyperv/files.hyperv | 34 +
sys/dev/hyperv/hvheartbeat.c | 198 +++
sys/dev/hyperv/hvs.c | 1139 ++++++++++++++++++++
sys/dev/hyperv/hvshutdown.c | 233 ++++
sys/dev/hyperv/hvtimesync.c | 338 ++++++
sys/dev/hyperv/hyperv_common.c | 183 +++
sys/dev/hyperv/hypervreg.h | 453 ++++++++
sys/dev/hyperv/hypervvar.h | 115 ++
sys/dev/hyperv/if_hvn.c | 1849 +++++++++++++++++++++++++++++++++
sys/dev/hyperv/if_hvnreg.h | 204 +++
sys/dev/hyperv/vmbus.c | 2112 ++++++++++++++++++++++++++++++++++++++
sys/dev/hyperv/vmbusic.c | 271 ++++
sys/dev/hyperv/vmbusicreg.h | 248 ++++
sys/dev/hyperv/vmbusicvar.h | 68 +
sys/dev/hyperv/vmbusvar.h | 273 ++++
sys/dev/ic/ndisreg.h | 435 +++++++
sys/dev/ic/rndisreg.h | 61 +-
36 files changed, 9637 insertions(+), 65 deletions(-)
diffs (truncated from 10251 to 300 lines):
diff -r b35df4cde884 -r 126d69463098 sys/arch/amd64/amd64/genassym.cf
--- a/sys/arch/amd64/amd64/genassym.cf Fri Feb 15 05:06:38 2019 +0000
+++ b/sys/arch/amd64/amd64/genassym.cf Fri Feb 15 08:54:01 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.73 2019/02/11 14:59:32 cherry Exp $
+# $NetBSD: genassym.cf,v 1.74 2019/02/15 08:54:01 nonaka Exp $
#
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -317,11 +317,13 @@
define IPL_NONE IPL_NONE
define IPL_PREEMPT IPL_PREEMPT
+define IPL_NET IPL_NET
define IPL_CLOCK IPL_CLOCK
define IPL_HIGH IPL_HIGH
define LIR_IPI LIR_IPI
define LIR_TIMER LIR_TIMER
+define LIR_HV LIR_HV
define SIR_NET SIR_NET
define SIR_CLOCK SIR_CLOCK
diff -r b35df4cde884 -r 126d69463098 sys/arch/amd64/amd64/vector.S
--- a/sys/arch/amd64/amd64/vector.S Fri Feb 15 05:06:38 2019 +0000
+++ b/sys/arch/amd64/amd64/vector.S Fri Feb 15 08:54:01 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vector.S,v 1.68 2019/02/14 08:18:25 cherry Exp $ */
+/* $NetBSD: vector.S,v 1.69 2019/02/15 08:54:01 nonaka Exp $ */
/*
* Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -84,6 +84,9 @@
#include "ioapic.h"
#include "lapic.h"
#include "assym.h"
+#ifndef XEN
+#include "hyperv.h"
+#endif
.text
@@ -262,6 +265,48 @@
IDTVEC_END(intr_lapic_ltimer)
TEXT_USER_END
+#if NHYPERV > 0
+ /*
+ * Hyper-V event channel upcall interrupt handler.
+ * Only used when the hypervisor supports direct vector callbacks.
+ */
+IDTVEC(recurse_hyperv_hypercall)
+ INTR_RECURSE_HWFRAME
+ pushq $0
+ pushq $T_ASTFLT
+ INTR_RECURSE_ENTRY
+ jmp 1f
+IDTVEC_END(recurse_hyperv_hypercall)
+NENTRY(handle_hyperv_hypercall)
+ movl CPUVAR(ILEVEL),%ebx
+ cmpl $IPL_NET,%ebx
+ jae 2f
+ jmp 1f
+END(handle_hyperv_hypercall)
+IDTVEC(resume_hyperv_hypercall)
+1:
+ incl CPUVAR(IDEPTH)
+ movl $IPL_NET,CPUVAR(ILEVEL)
+ sti
+ pushq %rbx
+ movq %rsp,%rsi
+ call _C_LABEL(hyperv_hypercall_intr)
+ jmp _C_LABEL(Xdoreti)
+2:
+ orl $(1 << LIR_HV),CPUVAR(IPENDING)
+ INTRFASTEXIT
+IDTVEC_END(resume_hyperv_hypercall)
+
+ TEXT_USER_BEGIN
+IDTVEC(intr_hyperv_hypercall)
+ pushq $0
+ pushq $T_ASTFLT
+ INTRENTRY
+ jmp _C_LABEL(handle_hyperv_hypercall)
+IDTVEC_END(intr_hyperv_hypercall)
+ TEXT_USER_END
+#endif /* NHYPERV > 0 */
+
#endif /* NLAPIC > 0 */
#ifndef XENPV
diff -r b35df4cde884 -r 126d69463098 sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC Fri Feb 15 05:06:38 2019 +0000
+++ b/sys/arch/amd64/conf/GENERIC Fri Feb 15 08:54:01 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.515 2019/01/01 08:09:30 maya Exp $
+# $NetBSD: GENERIC,v 1.516 2019/02/15 08:54:01 nonaka Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.515 $"
+#ident "GENERIC-$Revision: 1.516 $"
maxusers 64 # estimated number of users
@@ -87,6 +87,7 @@
acpicpu* at cpu? # ACPI CPU (including frequency scaling)
coretemp* at cpu? # Intel on-die thermal sensor
est0 at cpu0 # Intel Enhanced SpeedStep (non-ACPI)
+hyperv0 at cpu0 # Microsoft Hyper-V
#odcm0 at cpu0 # On-demand clock modulation
powernow0 at cpu0 # AMD PowerNow! and Cool'n'Quiet (non-ACPI)
vmt0 at cpu0 # VMware Tools
@@ -1080,6 +1081,14 @@
viornd* at virtio? # Virtio entropy device
vioscsi* at virtio? # Virtio SCSI device
+# Hyper-V devices
+vmbus* at acpi? # Hyper-V VMBus
+hvn* at vmbus? # Hyper-V NetVSC
+hvs* at vmbus? # Hyper-V StorVSC
+hvheartbeat* at vmbus? # Hyper-V Heartbeat
+hvshutdown* at vmbus? # Hyper-V Shutdown
+hvtimesync* at vmbus? # Hyper-V Timesync
+
# Pull in optional local configuration
cinclude "arch/amd64/conf/GENERIC.local"
diff -r b35df4cde884 -r 126d69463098 sys/arch/amd64/conf/files.amd64
--- a/sys/arch/amd64/conf/files.amd64 Fri Feb 15 05:06:38 2019 +0000
+++ b/sys/arch/amd64/conf/files.amd64 Fri Feb 15 08:54:01 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.amd64,v 1.111 2019/01/27 02:08:37 pgoyette Exp $
+# $NetBSD: files.amd64,v 1.112 2019/02/15 08:54:01 nonaka Exp $
#
# new style config file for amd64 architecture
#
@@ -189,5 +189,11 @@
include "dev/acpi/files.acpi"
file arch/amd64/acpi/acpi_wakeup_low.S acpi
+# Microsoft Hyper-V
+include "dev/hyperv/files.hyperv"
+
+attach vmbus at acpinodebus with vmbus_acpi
+file dev/acpi/vmbus_acpi.c vmbus_acpi
+
include "arch/amd64/conf/majors.amd64"
endif #xen
diff -r b35df4cde884 -r 126d69463098 sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC Fri Feb 15 05:06:38 2019 +0000
+++ b/sys/arch/i386/conf/GENERIC Fri Feb 15 08:54:01 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1200 2019/01/27 08:53:30 maxv Exp $
+# $NetBSD: GENERIC,v 1.1201 2019/02/15 08:54:01 nonaka Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.1200 $"
+#ident "GENERIC-$Revision: 1.1201 $"
maxusers 64 # estimated number of users
@@ -37,6 +37,7 @@
acpicpu* at cpu? # ACPI CPU (including frequency scaling)
coretemp* at cpu? # Intel on-die thermal sensor
est0 at cpu0 # Intel Enhanced SpeedStep (non-ACPI)
+hyperv0 at cpu0 # Microsoft Hyper-V
#odcm0 at cpu0 # On-demand clock modulation
#padlock0 at cpu0 # VIA PadLock
powernow0 at cpu0 # AMD PowerNow! and Cool'n'Quiet (non-ACPI)
@@ -1420,6 +1421,14 @@
viornd* at virtio? # Virtio entropy device
vioscsi* at virtio? # Virtio SCSI device
+# Hyper-V devices
+vmbus* at acpi? # Hyper-V VMBus
+hvn* at vmbus? # Hyper-V NetVSC
+hvs* at vmbus? # Hyper-V StorVSC
+hvheartbeat* at vmbus? # Hyper-V Heartbeat
+hvshutdown* at vmbus? # Hyper-V Shutdown
+hvtimesync* at vmbus? # Hyper-V Timesync
+
# Pull in optional local configuration
cinclude "arch/i386/conf/GENERIC.local"
diff -r b35df4cde884 -r 126d69463098 sys/arch/i386/conf/files.i386
--- a/sys/arch/i386/conf/files.i386 Fri Feb 15 05:06:38 2019 +0000
+++ b/sys/arch/i386/conf/files.i386 Fri Feb 15 08:54:01 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.i386,v 1.399 2018/12/22 07:45:58 cherry Exp $
+# $NetBSD: files.i386,v 1.400 2019/02/15 08:54:01 nonaka Exp $
#
# new style config file for i386 architecture
#
@@ -405,6 +405,12 @@
include "dev/acpi/files.acpi"
file arch/i386/acpi/acpi_wakeup_low.S acpi
+# Microsoft Hyper-V
+include "dev/hyperv/files.hyperv"
+
+attach vmbus at acpinodebus with vmbus_acpi
+file dev/acpi/vmbus_acpi.c vmbus_acpi
+
# Obsolete vesabios/vesafb flags
obsolete defflag opt_vesabios.h VESABIOSVERBOSE
obsolete defparam opt_vesafb.h VESAFB_WIDTH VESAFB_HEIGHT VESAFB_DEPTH
diff -r b35df4cde884 -r 126d69463098 sys/arch/i386/i386/genassym.cf
--- a/sys/arch/i386/i386/genassym.cf Fri Feb 15 05:06:38 2019 +0000
+++ b/sys/arch/i386/i386/genassym.cf Fri Feb 15 08:54:01 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.110 2019/02/11 14:59:32 cherry Exp $
+# $NetBSD: genassym.cf,v 1.111 2019/02/15 08:54:01 nonaka Exp $
#
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -321,6 +321,7 @@
define IPL_NONE IPL_NONE
define IPL_PREEMPT IPL_PREEMPT
+define IPL_NET IPL_NET
define IPL_SCHED IPL_SCHED
define IPL_CLOCK IPL_CLOCK
define IPL_HIGH IPL_HIGH
@@ -331,6 +332,7 @@
define LIR_IPI LIR_IPI
define LIR_TIMER LIR_TIMER
+define LIR_HV LIR_HV
define SIR_NET SIR_NET
define SIR_CLOCK SIR_CLOCK
diff -r b35df4cde884 -r 126d69463098 sys/arch/i386/i386/vector.S
--- a/sys/arch/i386/i386/vector.S Fri Feb 15 05:06:38 2019 +0000
+++ b/sys/arch/i386/i386/vector.S Fri Feb 15 08:54:01 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vector.S,v 1.82 2019/02/14 08:18:25 cherry Exp $ */
+/* $NetBSD: vector.S,v 1.83 2019/02/15 08:54:01 nonaka Exp $ */
/*
* Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.82 2019/02/14 08:18:25 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.83 2019/02/15 08:54:01 nonaka Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -85,6 +85,9 @@
#include "ioapic.h"
#include "lapic.h"
+#ifndef XEN
+#include "hyperv.h"
+#endif
#include "assym.h"
@@ -317,6 +320,45 @@
orl $(1 << LIR_TIMER),CPUVAR(IPENDING)
INTRFASTEXIT
IDTVEC_END(resume_lapic_ltimer)
+
+#if NHYPERV > 0
+ /*
+ * Hyper-V event channel upcall interrupt handler.
+ * Only used when the hypervisor supports direct vector callbacks.
+ */
+IDTVEC(recurse_hyperv_hypercall)
+ INTR_RECURSE_HWFRAME
+ pushl $0
+ pushl $T_ASTFLT
+ INTRENTRY
+ jmp 1f
+IDTVEC_END(recurse_hyperv_hypercall)
+IDTVEC(intr_hyperv_hypercall)
+ pushl $0
+ pushl $T_ASTFLT
+ INTRENTRY
+ movl CPUVAR(ILEVEL),%ebx
+ cmpl $IPL_NET,%ebx
+ jae 2f
+ jmp 1f
+IDTVEC_END(intr_hyperv_hypercall)
+IDTVEC(resume_hyperv_hypercall)
+1:
+ pushl %ebx
+ IDEPTH_INCR
+ movl $IPL_NET,CPUVAR(ILEVEL)
Home |
Main Index |
Thread Index |
Old Index