All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kamil Rytarowski <n54@gmx.com>
To: rth@twiddle.net, ehabkost@redhat.com, slp@redhat.com,
	pbonzini@redhat.com, peter.maydell@linaro.org, philmd@redhat.com,
	max@m00nbsd.net, jmcneill@invisible.ca
Cc: Kamil Rytarowski <n54@gmx.com>, qemu-devel@nongnu.org
Subject: [PATCH v5 4/4] Add the NVMM acceleration enlightenments
Date: Tue, 11 Aug 2020 15:01:53 +0200	[thread overview]
Message-ID: <20200811130153.4948-4-n54@gmx.com> (raw)
In-Reply-To: <20200811130153.4948-1-n54@gmx.com>

From: Maxime Villard <max@m00nbsd.net>

Implements the NVMM accelerator cpu enlightenments to actually use the nvmm-all
accelerator on NetBSD platforms.

Signed-off-by: Maxime Villard <max@m00nbsd.net>
Signed-off-by: Kamil Rytarowski <n54@gmx.com>
Reviewed-by: Sergio Lopez <slp@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Jared McNeill <jmcneill@invisible.ca>
---
 include/sysemu/hw_accel.h | 14 ++++++++++
 softmmu/cpus.c            | 58 +++++++++++++++++++++++++++++++++++++++
 target/i386/helper.c      |  2 +-
 3 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/include/sysemu/hw_accel.h b/include/sysemu/hw_accel.h
index e128f8b06b..9e19f5794c 100644
--- a/include/sysemu/hw_accel.h
+++ b/include/sysemu/hw_accel.h
@@ -16,6 +16,7 @@
 #include "sysemu/kvm.h"
 #include "sysemu/hvf.h"
 #include "sysemu/whpx.h"
+#include "sysemu/nvmm.h"

 static inline void cpu_synchronize_state(CPUState *cpu)
 {
@@ -31,6 +32,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)
@@ -47,6 +51,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)
@@ -63,6 +71,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)
@@ -79,6 +90,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 */
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index a802e899ab..3b44b92830 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -43,6 +43,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"
@@ -1621,6 +1622,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)
 {
@@ -1998,6 +2041,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];
@@ -2038,6 +2094,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);
     }
diff --git a/target/i386/helper.c b/target/i386/helper.c
index 70be53e2c3..c2f1aef65c 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -983,7 +983,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.28.0



  parent reply	other threads:[~2020-08-11 13:31 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200107124903.16505-1-n54@gmx.com>
2020-01-28 14:09 ` [PATCH v2 0/4] Implements the NetBSD Virtual Machine Monitor accelerator Kamil Rytarowski
2020-01-28 14:09   ` [PATCH v2 1/4] Add the NVMM vcpu API Kamil Rytarowski
2020-02-03 11:42     ` Philippe Mathieu-Daudé
2020-01-28 14:09   ` [PATCH v2 2/4] Add the NetBSD Virtual Machine Monitor accelerator Kamil Rytarowski
2020-02-03 11:41     ` Philippe Mathieu-Daudé
2020-02-03 11:56       ` Kamil Rytarowski
2020-02-03 12:10         ` Philippe Mathieu-Daudé
2020-03-02 17:12         ` Paolo Bonzini
2020-03-02 18:05           ` Kamil Rytarowski
2020-03-02 19:14             ` Maxime Villard
2020-03-02 19:40               ` Paolo Bonzini
2020-03-02 21:10                 ` Kamil Rytarowski
2020-03-02 22:45                   ` Paolo Bonzini
2020-03-02 17:11       ` Paolo Bonzini
2020-03-02 18:09         ` Kamil Rytarowski
2020-01-28 14:09   ` [PATCH v2 3/4] Introduce the NVMM impl Kamil Rytarowski
2020-02-03 11:51     ` Philippe Mathieu-Daudé
2020-02-05 17:22       ` Kamil Rytarowski
2020-02-05 17:47       ` Maxime Villard
2020-01-28 14:09   ` [PATCH v2 4/4] Add the NVMM acceleration enlightenments Kamil Rytarowski
2020-02-03 11:54     ` Philippe Mathieu-Daudé
2020-02-06 10:24       ` Kamil Rytarowski
2020-02-06 12:18         ` Philippe Mathieu-Daudé
2020-02-06 13:06         ` Markus Armbruster
2020-02-06 13:09           ` Philippe Mathieu-Daudé
2020-02-06 13:31             ` Kamil Rytarowski
2020-02-06 14:13               ` Markus Armbruster
2020-02-06 15:38                 ` Kamil Rytarowski
2020-02-06 16:07                   ` Philippe Mathieu-Daudé
2020-02-06 16:59                     ` Kamil Rytarowski
2020-02-03  9:52   ` [PATCH v2 0/4] Implements the NetBSD Virtual Machine Monitor accelerator Kamil Rytarowski
2020-02-06 11:57   ` [PATCH v3 " Kamil Rytarowski
2020-02-06 11:57     ` [PATCH v3 1/4] Add the NVMM vcpu API Kamil Rytarowski
2020-02-06 21:06       ` Jared McNeill
2020-02-06 11:57     ` [PATCH v3 2/4] Add the NetBSD Virtual Machine Monitor accelerator Kamil Rytarowski
2020-02-06 21:06       ` Jared McNeill
2020-02-06 11:57     ` [PATCH v3 3/4] Introduce the NVMM impl Kamil Rytarowski
2020-02-06 21:07       ` Jared McNeill
2020-02-06 11:57     ` [PATCH v3 4/4] Add the NVMM acceleration enlightenments Kamil Rytarowski
2020-02-06 21:07       ` Jared McNeill
2020-02-06 13:13     ` [PATCH v3 0/4] Implements the NetBSD Virtual Machine Monitor accelerator no-reply
2020-02-06 13:21       ` Kamil Rytarowski
2020-02-06 16:01         ` Philippe Mathieu-Daudé
2020-02-06 21:32     ` [PATCH v4 " Kamil Rytarowski
2020-02-06 21:32       ` [PATCH v4 1/4] Add the NVMM vcpu API Kamil Rytarowski
2020-08-11 12:47         ` [PATCH v5 " Kamil Rytarowski
2020-08-11 12:47           ` [PATCH v5 2/4] Add the NetBSD Virtual Machine Monitor accelerator Kamil Rytarowski
2020-08-11 12:47           ` [PATCH v5 3/4] Introduce the NVMM impl Kamil Rytarowski
2020-08-11 12:47           ` [PATCH v5 4/4] Add the NVMM acceleration enlightenments Kamil Rytarowski
2020-08-11 13:01         ` [PATCH v5 1/4] Add the NVMM vcpu API Kamil Rytarowski
2020-08-11 13:01           ` [PATCH v5 2/4] Add the NetBSD Virtual Machine Monitor accelerator Kamil Rytarowski
2020-08-11 13:01           ` [PATCH v5 3/4] Introduce the NVMM impl Kamil Rytarowski
2020-08-11 13:01           ` Kamil Rytarowski [this message]
2020-09-04 23:28           ` [PATCH v5 1/4] Add the NVMM vcpu API Kamil Rytarowski
2020-02-06 21:32       ` [PATCH v4 2/4] Add the NetBSD Virtual Machine Monitor accelerator Kamil Rytarowski
2020-02-06 21:32       ` [PATCH v4 3/4] Introduce the NVMM impl Kamil Rytarowski
2020-02-06 23:28         ` [PATCH v4 3/4 FIXUP] " Kamil Rytarowski
2020-03-02 18:13         ` [PATCH v4 3/4] " Paolo Bonzini
2020-03-02 19:28           ` Maxime Villard
2020-03-02 19:35             ` Paolo Bonzini
2020-03-10  6:45               ` Maxime Villard
2020-03-10 10:15                 ` Kamil Rytarowski
2020-03-10 10:58                 ` Paolo Bonzini
2020-03-10 19:14                   ` Maxime Villard
2020-03-11 18:03                     ` Paolo Bonzini
2020-03-11 20:14                       ` Maxime Villard
2020-03-11 20:42                         ` Paolo Bonzini
2020-03-11 21:21                           ` Maxime Villard
2020-03-11 21:22                             ` Kamil Rytarowski
2020-03-11 21:44                             ` Paolo Bonzini
2020-03-12  7:08                               ` Maxime Villard
2020-07-21 13:42                 ` Kamil Rytarowski
2020-02-06 21:32       ` [PATCH v4 4/4] Add the NVMM acceleration enlightenments Kamil Rytarowski
2020-02-17  9:07       ` [PATCH v4 0/4] Implements the NetBSD Virtual Machine Monitor accelerator Kamil Rytarowski
2020-02-24 15:17         ` Kamil Rytarowski
2020-03-02 17:02           ` Kamil Rytarowski
2020-03-02 17:10             ` Eduardo Habkost
2020-03-02 17:10               ` Kamil Rytarowski
2020-03-02 17:22                 ` Eduardo Habkost
2020-08-11 14:10 [PATCH v5 1/4] Add the NVMM vcpu API Kamil Rytarowski
2020-08-11 14:10 ` [PATCH v5 4/4] Add the NVMM acceleration enlightenments Kamil Rytarowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200811130153.4948-4-n54@gmx.com \
    --to=n54@gmx.com \
    --cc=ehabkost@redhat.com \
    --cc=jmcneill@invisible.ca \
    --cc=max@m00nbsd.net \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=slp@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.