Implements the NetBSD Virtual Machine Monitor accelerator
cover Implements the NetBSD Virtual Machine Monitor accelerator
Hello QEMU Community!
Over the past year the NetBSD team has been working hard on a new user-mode API for our hypervisor that will be released as part of the upcoming NetBSD 9.0. This new API adds user-mode capabilities to create and manage virtual machines, configure memory mappings for guest machines, and create and control execution of virtual processors.
With this new API we are now able to bring our hypervisor to the QEMU community! The following patches implement the NetBSD Virtual Machine Monitor accelerator (NVMM) for QEMU on NetBSD 9.0 and newer hosts.
When compiling QEMU for x86_64 passing the --enable-nvmm flag will compile the accelerator for use. At runtime using the '-accel nvmm' should see a significant performance improvement over emulation, much like when using 'hax' on NetBSD.
The documentation for this new API is visible at https://man.netbsd.org under the libnvmm(3) and nvmm(4) pages.
NVMM was designed and implemented by Maxime Villard.
Thank you for your feedback.
Maxime Villard (4):
Add the NVMM vcpu API
Add the NetBSD Virtual Machine Monitor accelerator. Introduce the NVMM impl
Add the NVMM acceleration enlightenments
accel/stubs/Makefile.objs | 1 + accel/stubs/nvmm-stub.c | 43 ++ configure | 36 ++ cpus.c | 58 ++ include/sysemu/hw_accel.h | 14 + include/sysemu/nvmm.h | 35 ++ qemu-options.hx | 4 +- target/i386/Makefile.objs | 1 + target/i386/helper.c | 2 +- target/i386/nvmm-all.c | 1222 +++++++++++++++++++++++++++++++++++++ 10 files changed, 1413 insertions(+), 3 deletions(-) create mode 100644 accel/stubs/nvmm-stub.c create mode 100644 include/sysemu/nvmm.h create mode 100644 target/i386/nvmm-all.c
--
2.24.0
PATCH 1/4 Add the NVMM vcpu API
From: Maxime Villard <[email protected]>
Adds support for the NetBSD Virtual Machine Monitor (NVMM) stubs and introduces the nvmm.h sysemu API for managing the vcpu scheduling and management.
--- accel/stubs/Makefile.objs | 1 + accel/stubs/nvmm-stub.c | 43 +++++++++++++++++++++++++++++++++++++++ include/sysemu/nvmm.h | 35 +++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 accel/stubs/nvmm-stub.c create mode 100644 include/sysemu/nvmm.h
accel/stubs/Makefile.objs +1 -0
@@ -1,5 +1,6 @@ obj-$(call lnot,$(CONFIG_HAX)) += hax-stub.o obj-$(call lnot,$(CONFIG_HVF)) += hvf-stub.o obj-$(call lnot,$(CONFIG_WHPX)) += whpx-stub.o +obj-$(call lnot,$(CONFIG_NVMM)) += nvmm-stub.o obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o obj-$(call lnot,$(CONFIG_TCG)) += tcg-stub.o
accel/stubs/nvmm-stub.c new file +43 -0
43 lines not on this page · raw message
include/sysemu/nvmm.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (c) 2018-2019 Maxime Villard, All rights reserved. +* +* NetBSD Virtual Machine Monitor (NVMM) accelerator support. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef QEMU_NVMM_H +#define QEMU_NVMM_H + +#include "config-host.h" +#include "qemu-common.h" + +int nvmm_init_vcpu (CPUState *); +int nvmm_vcpu_exec (CPUState *); +void nvmm_destroy_vcpu (CPUState *); + +void nvmm_cpu_synchronize_state (CPUState *); +void nvmm_cpu_synchronize_post_reset (CPUState *); +void nvmm_cpu_synchronize_post_init (CPUState *); +void nvmm_cpu_synchronize_pre_loadvm (CPUState *); + +#ifdef CONFIG_NVMM + +int nvmm_enabled (void ); + +#else /* CONFIG_NVMM */ + +#define nvmm_enabled () (0) + +#endif /* CONFIG_NVMM */ + +#endif /* CONFIG_NVMM */
--
2.24.0
Re: [PATCH 1/4] Add the NVMM vcpu API
Quoted 8 lines · Kamil Rytarowski
From: Maxime Villard <[email protected]>
Adds support for the NetBSD Virtual Machine Monitor (NVMM) stubs and introduces the
nvmm.hsysemu API for managing the vcpu scheduling and management.Signed-off-by Maxime Villard <[email protected]>Signed-off-by Kamil Rytarowski <[email protected]>
Quoted 7 lines
--- accel/stubs/Makefile.objs | 1 + accel/stubs/nvmm-stub.c | 43 +++++++++++++++++++++++++++++++++++++++ include/sysemu/nvmm.h | 35 +++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 accel/stubs/nvmm-stub.c create mode 100644 include/sysemu/nvmm.h
PATCH 2/4 Add the NetBSD Virtual Machine Monitor accelerator.
In reply to Kamil RytarowskiFrom: Maxime Villard <[email protected]>
Introduces the configure support for the new NetBSD Virtual Machine Monitor that allows for hypervisor acceleration from usermode components on the NetBSD platform.
--- configure | 36 ++++++++++++++++++++++++++++++++++++ qemu-options.hx | 4 ++-- 2 files changed, 38 insertions(+), 2 deletions(-)
configure +36 -0
@@ -241,6 +241,17 @@ supported_whpx_target() { return 1 } +supported_nvmm_target() { + test "$nvmm" = "yes" || return 1 + glob "$1" "*-softmmu" || return 1 + case "${1%-softmmu}" in + i386|x86_64) + return 0 + ;; + esac + return 1 +} + supported_target() { case "$1" in *-softmmu)
@@ -268,6 +279,7 @@ supported_target() { supported_hax_target "$1" && return 0 supported_hvf_target "$1" && return 0 supported_whpx_target "$1" && return 0 + supported_nvmm_target "$1" && return 0 print_error "TCG disabled, but hardware accelerator not available for '$target'" return 1 }
@@ -387,6 +399,7 @@ kvm="no" hax="no" hvf="no" whpx="no" +nvmm="no" rdma="" pvrdma="" gprof="no"
@@ -1168,6 +1181,10 @@ for opt do ;; --enable-whpx) whpx="yes" ;; + --disable-nvmm) nvmm="no" + ;; + --enable-nvmm) nvmm="yes" + ;; --disable-tcg-interpreter) tcg_interpreter="no" ;; --enable-tcg-interpreter) tcg_interpreter="yes"
@@ -1768,6 +1785,7 @@ disabled with --disable-FEATURE, default is enabled if available: hax HAX acceleration support hvf Hypervisor.framework acceleration support whpx Windows Hypervisor Platform acceleration support + nvmm NetBSD Virtual Machine Monitor acceleration support rdma Enable RDMA-based migration pvrdma Enable PVRDMA support vde support for vde network
@@ -2757,6 +2775,20 @@ if test "$whpx" != "no" ; then fi fi +########################################## +# NetBSD Virtual Machine Monitor (NVMM) accelerator check +if test "$nvmm" != "no" ; then + if check_include "nvmm.h" ; then + nvmm="yes" + LIBS="-lnvmm $LIBS" + else + if test "$nvmm" = "yes"; then + feature_not_found "NVMM" "NVMM is not available" + fi + nvmm="no" + fi +fi + ########################################## # Sparse probe if test "$sparse" != "no" ; then
@@ -6495,6 +6527,7 @@ echo "KVM support $kvm" echo "HAX support $hax" echo "HVF support $hvf" echo "WHPX support $whpx" +echo "NVMM support $nvmm" echo "TCG support $tcg" if test "$tcg" = "yes" ; then echo "TCG debug enabled $debug_tcg"
@@ -7771,6 +7804,9 @@ fi if test "$target_aligned_only" = "yes" ; then echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak fi +if supported_nvmm_target $target; then + echo "CONFIG_NVMM=y" >> $config_target_mak +fi if test "$target_bigendian" = "yes" ; then echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak fi
qemu-options.hx +2 -2
@@ -31,7 +31,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ "-machine [type=]name[,prop[=value][,...]]\n" " selects emulated machine ('-machine help' for list)\n" " property accel=accel1[:accel2[:...]] selects accelerator\n" - " supported accelerators are kvm, xen, hax, hvf, whpx or tcg (default: tcg)\n" + " supported accelerators are kvm, xen, hax, hvf, nvmm, whpx or tcg (default: tcg)\n" " vmport=on|off|auto controls emulation of vmport (default: auto)\n" " dump-guest-core=on|off include guest memory in a core dump (default=on)\n" " mem-merge=on|off controls memory merge support (default: on)\n"
@@ -63,7 +63,7 @@ Supported machine properties are: @table @option @item accel=@var{accels1}[:@var{accels2}[:...]] This is used to enable an accelerator. Depending on the target architecture, -kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used. If there is +kvm, xen, hax, hvf, nvmm, whpx or tcg can be available. By default, tcg is used. If there is more than one accelerator specified, the next one is used if the previous one fails to initialize. @item vmport=on|off|auto
--
2.24.0
Re: [PATCH 2/4] Add the NetBSD Virtual Machine Monitor accelerator.
Quoted 123 lines · Kamil Rytarowski
From: Maxime Villard <[email protected]>
Introduces the configure support for the new NetBSD Virtual Machine Monitor that allows for hypervisor acceleration from usermode components on the NetBSD platform.
Signed-off-by Maxime Villard <[email protected]>Signed-off-by Kamil Rytarowski <[email protected]>--- configure | 36 ++++++++++++++++++++++++++++++++++++ qemu-options.hx | 4 ++-- 2 files changed, 38 insertions(+), 2 deletions(-)configure +36
-0@@ -241,6 +241,17 @@ supported_whpx_target() { return 1 } +supported_nvmm_target() { + test "$nvmm" = "yes" || return 1 + glob "$1" "*-softmmu" || return 1 + case "${1%-softmmu}" in + i386|x86_64) + return 0 + ;; + esac + return 1 +} + supported_target() { case "$1" in *-softmmu)@@ -268,6 +279,7 @@ supported_target() { supported_hax_target "$1" && return 0 supported_hvf_target "$1" && return 0 supported_whpx_target "$1" && return 0 + supported_nvmm_target "$1" && return 0 print_error "TCG disabled, but hardware accelerator not available for '$target'" return 1 }@@ -387,6 +399,7 @@ kvm="no" hax="no" hvf="no" whpx="no" +nvmm="no" rdma="" pvrdma="" gprof="no"@@ -1168,6 +1181,10 @@ for opt do ;; --enable-whpx) whpx="yes" ;; + --disable-nvmm) nvmm="no" + ;; + --enable-nvmm) nvmm="yes" + ;; --disable-tcg-interpreter) tcg_interpreter="no" ;; --enable-tcg-interpreter) tcg_interpreter="yes"@@ -1768,6 +1785,7 @@ disabled with --disable-FEATURE, default is enabled if available: hax HAX acceleration support hvf Hypervisor.framework acceleration support whpx Windows Hypervisor Platform acceleration support + nvmm NetBSD Virtual Machine Monitor acceleration support rdma Enable RDMA-based migration pvrdma Enable PVRDMA support vde support for vde network@@ -2757,6 +2775,20 @@ if test "$whpx" != "no" ; then fi fi +########################################## +# NetBSD Virtual Machine Monitor (NVMM) accelerator check +if test "$nvmm" != "no" ; then + if check_include "nvmm.h" ; then + nvmm="yes" + LIBS="-lnvmm $LIBS" + else + if test "$nvmm" = "yes"; then + feature_not_found "NVMM" "NVMM is not available" + fi + nvmm="no" + fi +fi + ########################################## # Sparse probe if test "$sparse" != "no" ; then@@ -6495,6 +6527,7 @@ echo "KVM support $kvm" echo "HAX support $hax" echo "HVF support $hvf" echo "WHPX support $whpx" +echo "NVMM support $nvmm" echo "TCG support $tcg" if test "$tcg" = "yes" ; then echo "TCG debug enabled $debug_tcg"@@ -7771,6 +7804,9 @@ fi if test "$target_aligned_only" = "yes" ; then echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak fi +if supported_nvmm_target $target; then + echo "CONFIG_NVMM=y" >> $config_target_mak +fi if test "$target_bigendian" = "yes" ; then echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak fiqemu-options.hx +1
-1@@ -31,7 +31,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ "-machine [type=]name[,prop[=value][,...]]\n" " selects emulated machine ('-machine help' for list)\n" " property accel=accel1[:accel2[:...]] selects accelerator\n" - " supported accelerators are kvm, xen, hax, hvf, whpx or tcg (default: tcg)\n" + " supported accelerators are kvm, xen, hax, hvf, nvmm, whpx or tcg (default: tcg)\n" " vmport=on|off|auto controls emulation of vmport (default: auto)\n" " dump-guest-core=on|off include guest memory in a core dump (default=on)\n" " mem-merge=on|off controls memory merge support (default: on)\n"
qemu-options.hx Supported machine properties are: · line 66
Quoted 5 lines
qemu-options.hx +1
-1@@ -63,7 +63,7 @@ Supported machine properties are: @table @option @item accel=@var{accels1}[:@var{accels2}[:...]] This is used to enable an accelerator. Depending on the target architecture, -kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used. If there is +kvm, xen, hax, hvf, nvmm, whpx or tcg can be available. By default, tcg is used. If there is
Nitpick, but I think it'd be better to end the line at "tcg is used." and rearrange the paragraph, to avoid such a long line.
qemu-options.hx Supported machine properties are: · line 69
Quoted 3 lines
qemu-options.hx +0
-0more than one accelerator specified, the next one is used if the previous one fails to initialize. @item vmport=on|off|auto
Please update the section for "accel" option too.
Sergio.
PATCH v2 2/4 Add the NetBSD Virtual Machine Monitor accelerator.
From: Maxime Villard <[email protected]>
Introduces the configure support for the new NetBSD Virtual Machine Monitor that allows for hypervisor acceleration from usermode components on the NetBSD platform.
--- configure | 36 ++++++++++++++++++++++++++++++++++++ qemu-options.hx | 16 ++++++++-------- 2 files changed, 44 insertions(+), 8 deletions(-)
configure +36 -0
@@ -241,6 +241,17 @@ supported_whpx_target() { return 1 } +supported_nvmm_target() { + test "$nvmm" = "yes" || return 1 + glob "$1" "*-softmmu" || return 1 + case "${1%-softmmu}" in + i386|x86_64) + return 0 + ;; + esac + return 1 +} + supported_target() { case "$1" in *-softmmu)
@@ -268,6 +279,7 @@ supported_target() { supported_hax_target "$1" && return 0 supported_hvf_target "$1" && return 0 supported_whpx_target "$1" && return 0 + supported_nvmm_target "$1" && return 0 print_error "TCG disabled, but hardware accelerator not available for '$target'" return 1 }
@@ -387,6 +399,7 @@ kvm="no" hax="no" hvf="no" whpx="no" +nvmm="no" rdma="" pvrdma="" gprof="no"
@@ -1168,6 +1181,10 @@ for opt do ;; --enable-whpx) whpx="yes" ;; + --disable-nvmm) nvmm="no" + ;; + --enable-nvmm) nvmm="yes" + ;; --disable-tcg-interpreter) tcg_interpreter="no" ;; --enable-tcg-interpreter) tcg_interpreter="yes"
@@ -1768,6 +1785,7 @@ disabled with --disable-FEATURE, default is enabled if available: hax HAX acceleration support hvf Hypervisor.framework acceleration support whpx Windows Hypervisor Platform acceleration support + nvmm NetBSD Virtual Machine Monitor acceleration support rdma Enable RDMA-based migration pvrdma Enable PVRDMA support vde support for vde network
@@ -2757,6 +2775,20 @@ if test "$whpx" != "no" ; then fi fi +########################################## +# NetBSD Virtual Machine Monitor (NVMM) accelerator check +if test "$nvmm" != "no" ; then + if check_include "nvmm.h" ; then + nvmm="yes" + LIBS="-lnvmm $LIBS" + else + if test "$nvmm" = "yes"; then + feature_not_found "NVMM" "NVMM is not available" + fi + nvmm="no" + fi +fi + ########################################## # Sparse probe if test "$sparse" != "no" ; then
@@ -6495,6 +6527,7 @@ echo "KVM support $kvm" echo "HAX support $hax" echo "HVF support $hvf" echo "WHPX support $whpx" +echo "NVMM support $nvmm" echo "TCG support $tcg" if test "$tcg" = "yes" ; then echo "TCG debug enabled $debug_tcg"
@@ -7771,6 +7804,9 @@ fi if test "$target_aligned_only" = "yes" ; then echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak fi +if supported_nvmm_target $target; then + echo "CONFIG_NVMM=y" >> $config_target_mak +fi if test "$target_bigendian" = "yes" ; then echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak fi
qemu-options.hx +8 -8
@@ -31,7 +31,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ "-machine [type=]name[,prop[=value][,...]]\n" " selects emulated machine ('-machine help' for list)\n" " property accel=accel1[:accel2[:...]] selects accelerator\n" - " supported accelerators are kvm, xen, hax, hvf, whpx or tcg (default: tcg)\n" + " supported accelerators are kvm, xen, hax, hvf, nvmm, whpx or tcg (default: tcg)\n" " vmport=on|off|auto controls emulation of vmport (default: auto)\n" " dump-guest-core=on|off include guest memory in a core dump (default=on)\n" " mem-merge=on|off controls memory merge support (default: on)\n"
@@ -63,9 +63,9 @@ Supported machine properties are: @table @option @item accel=@var{accels1}[:@var{accels2}[:...]] This is used to enable an accelerator. Depending on the target architecture, -kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used. If there is -more than one accelerator specified, the next one is used if the previous one -fails to initialize. +kvm, xen, hax, hvf, nvmm, whpx or tcg can be available. By default, tcg is used. +If there is more than one accelerator specified, the next one is used if the +previous one fails to initialize. @item vmport=on|off|auto Enables emulation of VMWare IO port, for vmmouse etc. auto says to select the value based on accel. For accel=xen the default is off otherwise the default
@@ -110,7 +110,7 @@ ETEXI DEF("accel", HAS_ARG, QEMU_OPTION_accel, "-accel [accel=]accelerator[,prop[=value][,...]]\n" - " select accelerator (kvm, xen, hax, hvf, whpx or tcg; use 'help' for a list)\n" + " select accelerator (kvm, xen, hax, hvf, nvmm, whpx or tcg; use 'help' for a list)\n" " igd-passthru=on|off (enable Xen integrated Intel graphics passthrough, default=off)\n" " kernel-irqchip=on|off|split controls accelerated irqchip support (default=on)\n" " kvm-shadow-mem=size of KVM shadow MMU in bytes\n"
@@ -120,9 +120,9 @@ STEXI @item -accel @var{name}[,prop=@var{value}[,...]] @findex -accel This is used to enable an accelerator. Depending on the target architecture, -kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used. If there is -more than one accelerator specified, the next one is used if the previous one -fails to initialize. +kvm, xen, hax, hvf, nvmm, whpx or tcg can be available. By default, tcg is used. +If there is more than one accelerator specified, the next one is used if the +previous one fails to initialize. @table @option @item igd-passthru=on|off When Xen is in use, this option controls whether Intel integrated graphics
--
2.24.1
Re: [PATCH v2 2/4] Add the NetBSD Virtual Machine Monitor accelerator.
Quoted 6 lines · Kamil Rytarowski
From: Maxime Villard <[email protected]>
Introduces the configure support for the new NetBSD Virtual Machine Monitor that allows for hypervisor acceleration from usermode components on the NetBSD platform.
Quoted 6 lines
Signed-off-by Maxime Villard <[email protected]>Signed-off-by Kamil Rytarowski <[email protected]>--- configure | 36 ++++++++++++++++++++++++++++++++++++ qemu-options.hx | 16 ++++++++-------- 2 files changed, 44 insertions(+), 8 deletions(-)
Thanks!
PATCH 3/4 Introduce the NVMM impl
In reply to Kamil RytarowskiFrom: Maxime Villard <[email protected]>
Implements the NetBSD Virtual Machine Monitor (NVMM) target. Which acts as a hypervisor accelerator for QEMU on the NetBSD platform. This enables QEMU much greater speed over the emulated x86_64 path's that are taken on NetBSD today.
--- target/i386/Makefile.objs | 1 + target/i386/nvmm-all.c | 1222 +++++++++++++++++++++++++++++++++++++ 2 files changed, 1223 insertions(+) create mode 100644 target/i386/nvmm-all.c
target/i386/Makefile.objs +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_HAX) += hax-all.o hax-mem.o hax-posix.o endif obj-$(CONFIG_HVF) += hvf/ obj-$(CONFIG_WHPX) += whpx-all.o +obj-$(CONFIG_NVMM) += nvmm-all.o endif obj-$(CONFIG_SEV) += sev.o obj-$(call lnot,$(CONFIG_SEV)) += sev-stub.o
target/i386/nvmm-all.c new file +1222 -0
1,222 lines not on this page · raw message
--
2.24.0
Re: [PATCH 3/4] Introduce the NVMM impl
Quoted 7 lines · Kamil Rytarowski
From: Maxime Villard <[email protected]>
Implements the NetBSD Virtual Machine Monitor (NVMM) target. Which acts as a hypervisor accelerator for QEMU on the NetBSD platform. This enables QEMU much greater speed over the emulated
x86_64path's that are taken on NetBSD today.
Quoted 7 lines
Signed-off-by Maxime Villard <[email protected]>Signed-off-by Kamil Rytarowski <[email protected]>--- target/i386/Makefile.objs | 1 + target/i386/nvmm-all.c | 1222 +++++++++++++++++++++++++++++++++++++ 2 files changed, 1223 insertions(+) create mode 100644 target/i386/nvmm-all.c
PATCH 4/4 Add the NVMM acceleration enlightenments
In reply to Kamil RytarowskiFrom: Maxime Villard <[email protected]>
Implements the NVMM accelerator cpu enlightenments to actually use the nvmm-all accelerator on NetBSD platforms.
--- cpus.c | 58 +++++++++++++++++++++++++++++++++++++++ include/sysemu/hw_accel.h | 14 ++++++++++ target/i386/helper.c | 2 +- 3 files changed, 73 insertions(+), 1 deletion(-)
cpus.c +58 -0
@@ -42,6 +42,7 @@#include "sysemu/hax.h" #include "sysemu/hvf.h" #include "sysemu/whpx.h" +#include "sysemu/nvmm.h" #include "exec/exec-all.h" #include "qemu/thread.h"
@@ -1666,6 +1667,48 @@ static void *qemu_whpx_cpu_thread_fn(void *arg)return NULL ; } +static void *qemu_nvmm_cpu_thread_fn (void *arg) +{ +CPUState *cpu = arg; +int r; + +assert (nvmm_enabled ()); + +rcu_register_thread (); + +qemu_mutex_lock_iothread (); +qemu_thread_get_self (cpu->thread); + cpu->thread_id =qemu_get_thread_id (); + current_cpu = cpu; + + r =nvmm_init_vcpu (cpu); +if (r <0 ) { +fprintf (stderr,"nvmm_init_vcpu failed: %s\n" ,strerror (-r)); +exit (1 ); + } + +/* signal CPU creation */ + cpu->created = true; +qemu_cond_signal (&qemu_cpu_cond); + +do { +if (cpu_can_run (cpu)) { + r =nvmm_vcpu_exec (cpu); +if (r ==EXCP_DEBUG ) { +cpu_handle_guest_debug (cpu); + } + } +qemu_wait_io_event (cpu); + }while (!cpu->unplug ||cpu_can_run (cpu)); + +nvmm_destroy_vcpu (cpu); + cpu->created = false; +qemu_cond_signal (&qemu_cpu_cond); +qemu_mutex_unlock_iothread (); +rcu_unregister_thread (); +return NULL ; +} +#ifdef _WIN32 static void CALLBACK dummy_apc_func(ULONG_PTR unused) {
@@ -2029,6 +2072,19 @@ static void qemu_whpx_start_vcpu(CPUState *cpu)#endif } +static void qemu_nvmm_start_vcpu (CPUState *cpu) +{ +char thread_name[VCPU_THREAD_NAME_SIZE ]; + + cpu->thread =g_malloc0 (sizeof (QemuThread)); + cpu->halt_cond =g_malloc0 (sizeof (QemuCond)); +qemu_cond_init (cpu->halt_cond); +snprintf (thread_name,VCPU_THREAD_NAME_SIZE ,"CPU %d/NVMM" , + cpu->cpu_index); +qemu_thread_create (cpu->thread, thread_name, qemu_nvmm_cpu_thread_fn, + cpu,QEMU_THREAD_JOINABLE ); +} +static void qemu_dummy_start_vcpu (CPUState *cpu) {char thread_name[VCPU_THREAD_NAME_SIZE ];
@@ -2069,6 +2125,8 @@ void qemu_init_vcpu(CPUState *cpu)qemu_tcg_init_vcpu (cpu); }else if (whpx_enabled ()) {qemu_whpx_start_vcpu (cpu); + }else if (nvmm_enabled ()) { +qemu_nvmm_start_vcpu (cpu); }else {qemu_dummy_start_vcpu (cpu); }
include/sysemu/hw_accel.h +14 -0
@@ -15,6 +15,7 @@#include "sysemu/hax.h" #include "sysemu/kvm.h" #include "sysemu/whpx.h" +#include "sysemu/nvmm.h" static inline void cpu_synchronize_state (CPUState *cpu) {
@@ -27,6 +28,9 @@ static inline void cpu_synchronize_state(CPUState *cpu)if (whpx_enabled ()) {whpx_cpu_synchronize_state (cpu); } +if (nvmm_enabled ()) { +nvmm_cpu_synchronize_state (cpu); + } }static inline void cpu_synchronize_post_reset (CPUState *cpu)
@@ -40,6 +44,10 @@ static inline void cpu_synchronize_post_reset(CPUState *cpu)if (whpx_enabled ()) {whpx_cpu_synchronize_post_reset (cpu); } +if (nvmm_enabled ()) { +nvmm_cpu_synchronize_post_reset (cpu); + } + }static inline void cpu_synchronize_post_init (CPUState *cpu)
@@ -53,6 +61,9 @@ static inline void cpu_synchronize_post_init(CPUState *cpu)if (whpx_enabled ()) {whpx_cpu_synchronize_post_init (cpu); } +if (nvmm_enabled ()) { +nvmm_cpu_synchronize_post_init (cpu); + } }static inline void cpu_synchronize_pre_loadvm (CPUState *cpu)
@@ -66,6 +77,9 @@ static inline void cpu_synchronize_pre_loadvm(CPUState *cpu)if (whpx_enabled ()) {whpx_cpu_synchronize_pre_loadvm (cpu); } +if (nvmm_enabled ()) { +nvmm_cpu_synchronize_pre_loadvm (cpu); + } }#endif /* QEMU_HW_ACCEL_H */
target/i386/helper.c +1 -1
@@ -981,7 +981,7 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access)X86CPU *cpu =env_archcpu (env);CPUState *cs =env_cpu (env); -if (kvm_enabled () ||whpx_enabled ()) { +if (kvm_enabled () ||whpx_enabled () ||nvmm_enabled ()) { env->tpr_access_type = access;cpu_interrupt (cs,CPU_INTERRUPT_TPR );
--
2.24.0
Re: [PATCH 4/4] Add the NVMM acceleration enlightenments
Quoted 5 lines · Kamil Rytarowski
From: Maxime Villard <[email protected]>
Implements the NVMM accelerator cpu enlightenments to actually use the nvmm-all accelerator on NetBSD platforms.
Quoted 7 lines
Signed-off-by Maxime Villard <[email protected]>Signed-off-by Kamil Rytarowski <[email protected]>--- cpus.c | 58 +++++++++++++++++++++++++++++++++++++++ include/sysemu/hw_accel.h | 14 ++++++++++ target/i386/helper.c | 2 +- 3 files changed, 73 insertions(+), 1 deletion(-)
Ping?
Quoted 48 lines · Kamil Rytarowski
Hello QEMU Community!
Over the past year the NetBSD team has been working hard on a new user-mode API for our hypervisor that will be released as part of the upcoming NetBSD 9.0. This new API adds user-mode capabilities to create and manage virtual machines, configure memory mappings for guest machines, and create and control execution of virtual processors.
With this new API we are now able to bring our hypervisor to the QEMU community! The following patches implement the NetBSD Virtual Machine Monitor accelerator (NVMM) for QEMU on NetBSD 9.0 and newer hosts.
When compiling QEMU for
x86_64passing the --enable-nvmm flag will compile the accelerator for use. At runtime using the '-accel nvmm' should see a significant performance improvement over emulation, much like when using 'hax' on NetBSD.The documentation for this new API is visible at https://man.netbsd.org under the libnvmm(3) and nvmm(4) pages.
NVMM was designed and implemented by Maxime Villard.
Thank you for your feedback.
Maxime Villard (4):
Add the NVMM vcpu API
Add the NetBSD Virtual Machine Monitor accelerator. Introduce the NVMM impl
Add the NVMM acceleration enlightenmentsaccel/stubs/Makefile.objs | 1 + accel/stubs/nvmm-stub.c | 43 ++ configure | 36 ++ cpus.c | 58 ++ include/sysemu/hw_accel.h | 14 + include/sysemu/nvmm.h | 35 ++ qemu-options.hx | 4 +- target/i386/Makefile.objs | 1 + target/i386/helper.c | 2 +- target/i386/nvmm-all.c | 1222 +++++++++++++++++++++++++++++++++++++ 10 files changed, 1413 insertions(+), 3 deletions(-) create mode 100644 accel/stubs/nvmm-stub.c create mode 100644 include/sysemu/nvmm.h create mode 100644 target/i386/nvmm-all.c--
2.24.0
Ping? 2x
Quoted 53 lines · Kamil Rytarowski
Ping?
Quoted 48 lines · Kamil Rytarowski
Hello QEMU Community!
Over the past year the NetBSD team has been working hard on a new user-mode API for our hypervisor that will be released as part of the upcoming NetBSD 9.0. This new API adds user-mode capabilities to create and manage virtual machines, configure memory mappings for guest machines, and create and control execution of virtual processors.
With this new API we are now able to bring our hypervisor to the QEMU community! The following patches implement the NetBSD Virtual Machine Monitor accelerator (NVMM) for QEMU on NetBSD 9.0 and newer hosts.
When compiling QEMU for
x86_64passing the --enable-nvmm flag will compile the accelerator for use. At runtime using the '-accel nvmm' should see a significant performance improvement over emulation, much like when using 'hax' on NetBSD.The documentation for this new API is visible at https://man.netbsd.org under the libnvmm(3) and nvmm(4) pages.
NVMM was designed and implemented by Maxime Villard.
Thank you for your feedback.
Maxime Villard (4):
Add the NVMM vcpu API
Add the NetBSD Virtual Machine Monitor accelerator. Introduce the NVMM impl
Add the NVMM acceleration enlightenmentsaccel/stubs/Makefile.objs | 1 + accel/stubs/nvmm-stub.c | 43 ++ configure | 36 ++ cpus.c | 58 ++ include/sysemu/hw_accel.h | 14 + include/sysemu/nvmm.h | 35 ++ qemu-options.hx | 4 +- target/i386/Makefile.objs | 1 + target/i386/helper.c | 2 +- target/i386/nvmm-all.c | 1222 +++++++++++++++++++++++++++++++++++++ 10 files changed, 1413 insertions(+), 3 deletions(-) create mode 100644 accel/stubs/nvmm-stub.c create mode 100644 include/sysemu/nvmm.h create mode 100644 target/i386/nvmm-all.c--
2.24.0
Quoted 17 lines · Kamil Rytarowski
Hello QEMU Community!
Over the past year the NetBSD team has been working hard on a new user-mode API for our hypervisor that will be released as part of the upcoming NetBSD 9.0. This new API adds user-mode capabilities to create and manage virtual machines, configure memory mappings for guest machines, and create and control execution of virtual processors.
With this new API we are now able to bring our hypervisor to the QEMU community! The following patches implement the NetBSD Virtual Machine Monitor accelerator (NVMM) for QEMU on NetBSD 9.0 and newer hosts.
When compiling QEMU for
x86_64passing the --enable-nvmm flag will compile the accelerator for use. At runtime using the '-accel nvmm' should see a significant performance improvement over emulation, much like when using 'hax' on NetBSD.
Quoted 6 lines
The documentation for this new API is visible at https://man.netbsd.org under the libnvmm(3) and nvmm(4) pages.
NVMM was designed and implemented by Maxime Villard.
Thank you for your feedback.
Thank you for working on this, it's nice to see that QEMU will gain HW-assisted acceleration on NetBSD 9.0. A couple things:
- Are you and/or Maxime willing to step up as maintainers for the NVMM support in QEMU?
- In the next version of the patch series, please use "scripts/get_maintainer.pl" to get the list of people you need to CC for the patch series.
Thanks,
Sergio.
Quoted 21 lines · Sergio Lopez
Quoted 20 lines · Kamil Rytarowski
Hello QEMU Community!
Over the past year the NetBSD team has been working hard on a new user-mode API for our hypervisor that will be released as part of the upcoming NetBSD 9.0. This new API adds user-mode capabilities to create and manage virtual machines, configure memory mappings for guest machines, and create and control execution of virtual processors.
With this new API we are now able to bring our hypervisor to the QEMU community! The following patches implement the NetBSD Virtual Machine Monitor accelerator (NVMM) for QEMU on NetBSD 9.0 and newer hosts.
When compiling QEMU for
x86_64passing the --enable-nvmm flag will compile the accelerator for use. At runtime using the '-accel nvmm' should see a significant performance improvement over emulation, much like when using 'hax' on NetBSD.The documentation for this new API is visible at https://man.netbsd.org under the libnvmm(3) and nvmm(4) pages.
Quoted 7 lines
Quoted 3 lines
NVMM was designed and implemented by Maxime Villard.
Thank you for your feedback.
Thank you for working on this, it's nice to see that QEMU will gain HW-assisted acceleration on NetBSD 9.0. A couple things:
Thank you for the review!
Quoted 3 lines
- Are you and/or Maxime willing to step up as maintainers for the NVMM support in QEMU?
NVMM (as of today) is part of the NetBSD support and I am the maintainer for the NetBSD code (noted in MAINTAINERS).
In case of non-trivial changes I will reach Maxime for his feedback.
Quoted 4 lines
- In the next version of the patch series, please use "
scripts/get_maintainer.pl" to get the list of people you need to CC for the patch series.
I've submitted a fixup patch '[PATCH v2 2/4] Add the NetBSD Virtual Machine Monitor accelerator.' instead of the full series.
I have rechecked the maintainers with the patch and I don't see anybody else as a candidate for review.
I don't maintain a merge queue on my own. Please put the reviewed patches on a merge queue yourself.
Thank you in advance,
Quoted 3 lines
Thanks,
Sergio.
Quoted 32 lines · Kamil Rytarowski
Quoted 21 lines · Sergio Lopez
Quoted 20 lines · Kamil Rytarowski
Hello QEMU Community!
Over the past year the NetBSD team has been working hard on a new user-mode API for our hypervisor that will be released as part of the upcoming NetBSD 9.0. This new API adds user-mode capabilities to create and manage virtual machines, configure memory mappings for guest machines, and create and control execution of virtual processors.
With this new API we are now able to bring our hypervisor to the QEMU community! The following patches implement the NetBSD Virtual Machine Monitor accelerator (NVMM) for QEMU on NetBSD 9.0 and newer hosts.
When compiling QEMU for
x86_64passing the --enable-nvmm flag will compile the accelerator for use. At runtime using the '-accel nvmm' should see a significant performance improvement over emulation, much like when using 'hax' on NetBSD.The documentation for this new API is visible at https://man.netbsd.org under the libnvmm(3) and nvmm(4) pages.
Quoted 7 lines
Quoted 3 lines
NVMM was designed and implemented by Maxime Villard.
Thank you for your feedback.
Thank you for working on this, it's nice to see that QEMU will gain HW-assisted acceleration on NetBSD 9.0. A couple things:
Thank you for the review!
Quoted 8 lines
Quoted 3 lines
- Are you and/or Maxime willing to step up as maintainers for the NVMM support in QEMU?
NVMM (as of today) is part of the NetBSD support and I am the maintainer for the NetBSD code (noted in
MAINTAINERS).In case of non-trivial changes I will reach Maxime for his feedback.
OK, sounds good to me.
Quoted 10 lines
Quoted 4 lines
- In the next version of the patch series, please use "
scripts/get_maintainer.pl" to get the list of people you need to CC for the patch series.I've submitted a fixup patch '[PATCH v2 2/4] Add the NetBSD Virtual Machine Monitor accelerator.' instead of the full series.
I have rechecked the maintainers with the patch and I don't see anybody else as a candidate for review.
$ ./scripts/get_maintainer.pl /tmp/0004.patch Paolo Bonzini <[email protected]> (maintainer:Main loop) Richard Henderson <[email protected]> (maintainer:Overall TCG CPUs) Eduardo Habkost <[email protected]> (maintainer:X86 TCG CPUs) [email protected] (open list:All patches CC here)
$ ./scripts/get_maintainer.pl /tmp/0002.patch get_maintainer.pl: No maintainers found, printing recent contributors. get_maintainer.pl: Do not blindly cc: them on patches! Use common sense.
"Philippe Mathieu-Daudé" <[email protected]> (commit_signer:31/112=28%) Paolo Bonzini <[email protected]> (commit_signer:31/112=28%)
Thomas Huth <[email protected]> (commit_signer:25/112=22%,commit_signer:14/53=26%) "Daniel P. Berrangé" <[email protected]> (commit_signer:24/112=21%) Laurent Vivier <[email protected]> (commit_signer:22/112=20%,commit_signer:10/53=19%) Gerd Hoffmann <[email protected]> (commit_signer:13/53=25%)
"Michael S. Tsirkin" <[email protected]> (commit_signer:9/53=17%)
Markus Armbruster <[email protected]> (commit_signer:9/53=17%) [email protected] (open list:All patches CC here)
I think you should resping the whole series as v2, adding Richard, Eduardo and Philippe to the CC list. That should help with the review process.
Thanks,
Sergio.
Quoted 11 lines
I don't maintain a merge queue on my own. Please put the reviewed patches on a merge queue yourself.
Thank you in advance,
Quoted 3 lines
Thanks,
Sergio.
Quoted 75 lines · Sergio Lopez
Quoted 32 lines · Kamil Rytarowski
Quoted 21 lines · Sergio Lopez
Quoted 20 lines · Kamil Rytarowski
Hello QEMU Community!
Over the past year the NetBSD team has been working hard on a new user-mode API for our hypervisor that will be released as part of the upcoming NetBSD 9.0. This new API adds user-mode capabilities to create and manage virtual machines, configure memory mappings for guest machines, and create and control execution of virtual processors.
With this new API we are now able to bring our hypervisor to the QEMU community! The following patches implement the NetBSD Virtual Machine Monitor accelerator (NVMM) for QEMU on NetBSD 9.0 and newer hosts.
When compiling QEMU for
x86_64passing the --enable-nvmm flag will compile the accelerator for use. At runtime using the '-accel nvmm' should see a significant performance improvement over emulation, much like when using 'hax' on NetBSD.The documentation for this new API is visible at https://man.netbsd.org under the libnvmm(3) and nvmm(4) pages.
Quoted 7 lines
Quoted 3 lines
NVMM was designed and implemented by Maxime Villard.
Thank you for your feedback.
Thank you for working on this, it's nice to see that QEMU will gain HW-assisted acceleration on NetBSD 9.0. A couple things:
Thank you for the review!
Quoted 8 lines
Quoted 3 lines
- Are you and/or Maxime willing to step up as maintainers for the NVMM support in QEMU?
NVMM (as of today) is part of the NetBSD support and I am the maintainer for the NetBSD code (noted in
MAINTAINERS).In case of non-trivial changes I will reach Maxime for his feedback.
OK, sounds good to me.
Quoted 10 lines
Quoted 4 lines
- In the next version of the patch series, please use "
scripts/get_maintainer.pl" to get the list of people you need to CC for the patch series.I've submitted a fixup patch '[PATCH v2 2/4] Add the NetBSD Virtual Machine Monitor accelerator.' instead of the full series.
I have rechecked the maintainers with the patch and I don't see anybody else as a candidate for review.
$ ./scripts/get_maintainer.pl /tmp/0004.patch Paolo Bonzini <[email protected]> (maintainer:Main loop) Richard Henderson <[email protected]> (maintainer:Overall TCG CPUs) Eduardo Habkost <[email protected]> (maintainer:X86 TCG CPUs) [email protected] (open list:All patches CC here)$ ./scripts/get_maintainer.pl /tmp/0002.patch get_maintainer.pl: No maintainers found, printing recent contributors. get_maintainer.pl: Do not blindly cc: them on patches! Use common sense."Philippe Mathieu-Daudé" <[email protected]> (commit_signer:31/112=28%) Paolo Bonzini <[email protected]> (commit_signer:31/112=28%)
Thomas Huth <[email protected]> (commit_signer:25/112=22%,commit_signer:14/53=26%) "Daniel P. Berrangé" <[email protected]> (commit_signer:24/112=21%) Laurent Vivier <[email protected]> (commit_signer:22/112=20%,commit_signer:10/53=19%) Gerd Hoffmann <[email protected]> (commit_signer:13/53=25%)
"Michael S. Tsirkin" <[email protected]> (commit_signer:9/53=17%)
Markus Armbruster <[email protected]> (commit_signer:9/53=17%) [email protected] (open list:All patches CC here)
Quoted 4 lines
I think you should resping the whole series as v2, adding Richard, Eduardo and Philippe to the CC list. That should help with the review process.
OK. I will do it.
Please have a look at v2 2/4, submit reviewed-by and I will submit the whole series again.
Quoted 17 lines
Thanks,
Sergio.Quoted 11 lines
I don't maintain a merge queue on my own. Please put the reviewed patches on a merge queue yourself.
Thank you in advance,
Quoted 3 lines
Thanks,
Sergio.