Skip to contentSkip to conversation

Update NVMM support to recent changes

PATCH Applied Reinoud Zandijk 5 participants 12 messages Jul 18, 2021 – Sep 10, 2021

lore
Share & tools
lore
#0 lore raw

cover Update NVMM support to recent changes

This patchset fixes small NVMM accelerator compilation issues due to changes made in the rest of Qemu since its import.

---

Reinoud Zandijk (2):
Only check CONFIG_NVMM when NEED_CPU_H is defined Fix nvmm_ram_block_added() function arguments

 include/sysemu/nvmm.h       | 7 ++++---
 target/i386/nvmm/nvmm-all.c | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/2 Only check CONFIG_NVMM when NEED_CPU_H is defined

Userland targers will otherwise use a poisoned CONFIG_NVMM

---
 include/sysemu/nvmm.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
include/sysemu/nvmm.h +4 -3
index 6d216599b0..833670fccb 100644
@@ -10,8 +10,7 @@
 #ifndef QEMU_NVMM_H
 #define QEMU_NVMM_H
 
-#include "config-host.h"
-#include "qemu-common.h"
+#ifdef NEED_CPU_H
 
 #ifdef CONFIG_NVMM
 
@@ -23,4 +22,6 @@ int nvmm_enabled(void);
 
 #endif /* CONFIG_NVMM */
 
-#endif /* CONFIG_NVMM */
+#endif /* NEED_CPU_H */
+
+#endif /* QEMU_NVMM_H */
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH v1 1/2] Only check CONFIG_NVMM when NEED_CPU_H is defined

Quoted 1 line · Reinoud Zandijk

Userland targers will otherwise use a poisoned CONFIG_NVMM

Typo "targets", but do you mean bsd-user or linux-user?

But what is the error you get here?

cpu_report_tpr_access() is protected for !CONFIG_USER_ONLY, target/i386/nvmm/ is only build on system emulation.

So when can this happen? Last candidate is "sysemu/hw_accel.h"; does it really need to include "sysemu/nvmm.h"?

Quoted 28 lines
---
 include/sysemu/nvmm.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
include/sysemu/nvmm.h +4 -3
index 6d216599b0..833670fccb 100644
@@ -10,8 +10,7 @@
 #ifndef QEMU_NVMM_H
 #define QEMU_NVMM_H
 
-#include "config-host.h"
-#include "qemu-common.h"
+#ifdef NEED_CPU_H
 
 #ifdef CONFIG_NVMM
 
@@ -23,4 +22,6 @@ int nvmm_enabled(void);
 
 #endif /* CONFIG_NVMM */
 
-#endif /* CONFIG_NVMM */
+#endif /* NEED_CPU_H */
+
+#endif /* QEMU_NVMM_H */
#3 lore raw

Re: [PATCH v1 1/2] Only check CONFIG_NVMM when NEED_CPU_H is defined

Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 1 line · Reinoud Zandijk

Userland targers will otherwise use a poisoned CONFIG_NVMM

Typo "targets", but do you mean bsd-user or linux-user?

Since its on NetBSD, I guess its bsd-user :)

Quoted 7 lines

But what is the error you get here?

cpu_report_tpr_access() is protected for !CONFIG_USER_ONLY, target/i386/nvmm/ is only build on system emulation.

So when can this happen? Last candidate is "sysemu/hw_accel.h"; does it really need to include "sysemu/nvmm.h"?

[5560/6718] Compiling C object libcommon.fa.p/hw_core_cpu-common.c.o
FAILED: libcommon.fa.p/hw_core_cpu-common.c.o
gcc -Ilibcommon.fa.p -I../slirp -I../slirp/src -I../dtc/libfdt
-I../capstone/include/capstone -I. -Iqapi -Itrace -Iui -Iui/shader
-I/usr/pkg/include -I/usr/pkg/include/glib-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/gio-unix-2.0 -I/usr/X11R7/include
-I/usr/pkg/include/spice-1 -I/usr/pkg/include/spice-server
-I/usr/X11R7/include/pixman-1 -I/usr/pkg/include/libpng16
-I/usr/pkg/include/SDL2 -I/usr/pkg/include/ncursesw
-I/usr/X11R7/include/libdrm -I/usr/include -I/usr/pkg/include/ncurses
-I/usr/pkg/include/python3.8 -I/usr/include/krb5 -fdiagnostics-color=auto
-pipe -Wall -Winvalid-pch -std=gnu11 -O2 -iquote . -iquote /tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b
-iquote /tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b/include -iquote /tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b/disas/libvixl -iquote /tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b/tcg/i386 -pthread -U_FORTIFY_SOURCE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef
-Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv
-Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security
-Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs
-Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2
-Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi
-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE_EXTENDED=1
-fPIC -D_NETBSD_SOURCE -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -D_REENTRANT
-D_THREAD_SAFE -Wno-undef -MD -MQ libcommon.fa.p/hw_core_cpu-common.c.o -MF libcommon.fa.p/hw_core_cpu-common.c.o.d -o
libcommon.fa.p/hw_core_cpu-common.c.o -c ../hw/core/cpu-common.c
In file included from /tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b/include/sysemu/hw_accel.h:19:0,

                 from ../hw/core/cpu-common.c:24:
/tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b/include/sysemu/nvmm.h:16:8:
error: attempt to use poisoned "CONFIG_NVMM"
 #ifdef CONFIG_NVMM
        ^

[5589/6718] Compiling C object libcommon.fa.p/hw_net_e1000e_core.c.o
ninja: build stopped: subcommand failed.

With the patch it works fine.

With regards,
Reinoud

Quoted 28 lines
Quoted 28 lines
---
 include/sysemu/nvmm.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
include/sysemu/nvmm.h +4 -3
index 6d216599b0..833670fccb 100644
@@ -10,8 +10,7 @@
 #ifndef QEMU_NVMM_H
 #define QEMU_NVMM_H
 
-#include "config-host.h"
-#include "qemu-common.h"
+#ifdef NEED_CPU_H
 
 #ifdef CONFIG_NVMM
 
@@ -23,4 +22,6 @@ int nvmm_enabled(void);
 
 #endif /* CONFIG_NVMM */
 
-#endif /* CONFIG_NVMM */
+#endif /* NEED_CPU_H */
+
+#endif /* QEMU_NVMM_H */
#4 lore raw

Re: [PATCH v1 1/2] Only check CONFIG_NVMM when NEED_CPU_H is defined

+Thomas

Quoted 92 lines · Reinoud Zandijk
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 1 line · Reinoud Zandijk

Userland targers will otherwise use a poisoned CONFIG_NVMM

Typo "targets", but do you mean bsd-user or linux-user?

Since its on NetBSD, I guess its bsd-user :)

Quoted 7 lines

But what is the error you get here?

cpu_report_tpr_access() is protected for !CONFIG_USER_ONLY, target/i386/nvmm/ is only build on system emulation.

So when can this happen? Last candidate is "sysemu/hw_accel.h"; does it really need to include "sysemu/nvmm.h"?

[5560/6718] Compiling C object libcommon.fa.p/hw_core_cpu-common.c.o
FAILED: libcommon.fa.p/hw_core_cpu-common.c.o
gcc -Ilibcommon.fa.p -I../slirp -I../slirp/src -I../dtc/libfdt

(quoted diff) +0 -9
-I../capstone/include/capstone -I. -Iqapi -Itrace -Iui -Iui/shader
-I/usr/pkg/include -I/usr/pkg/include/glib-2.0 -I/usr/pkg/lib/glib-2.0/include
-I/usr/pkg/include/gio-unix-2.0 -I/usr/X11R7/include
-I/usr/pkg/include/spice-1 -I/usr/pkg/include/spice-server
-I/usr/X11R7/include/pixman-1 -I/usr/pkg/include/libpng16
-I/usr/pkg/include/SDL2 -I/usr/pkg/include/ncursesw
-I/usr/X11R7/include/libdrm -I/usr/include -I/usr/pkg/include/ncurses
-I/usr/pkg/include/python3.8 -I/usr/include/krb5 -fdiagnostics-color=auto
-pipe -Wall -Winvalid-pch -std=gnu11 -O2 -iquote . -iquote

/tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b -iquote /tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b/include -iquote /tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b/disas/libvixl -iquote /tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b/tcg/i386

(quoted diff) +0 -10
-pthread -U_FORTIFY_SOURCE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef
-Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv
-Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security
-Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs
-Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2
-Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi
-fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE_EXTENDED=1
-fPIC -D_NETBSD_SOURCE -D_XOPEN_SOURCE=600 -DNCURSES_WIDECHAR -D_REENTRANT
-D_THREAD_SAFE -Wno-undef -MD -MQ libcommon.fa.p/hw_core_cpu-common.c.o -MF

libcommon.fa.p/hw_core_cpu-common.c.o.d -o
libcommon.fa.p/hw_core_cpu-common.c.o -c ../hw/core/cpu-common.c
In file included from /tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b/include/sysemu/hw_accel.h:19:0,

                 from ../hw/core/cpu-common.c:24:
/tmp/pkgsrc-gorilla/emulators/qemu-walking/work/qemu-9ad4c7c9b63f89c308fd988d509bed1389953c8b/include/sysemu/nvmm.h:16:8:
error: attempt to use poisoned "CONFIG_NVMM"
 #ifdef CONFIG_NVMM
        ^

[5589/6718] Compiling C object libcommon.fa.p/hw_net_e1000e_core.c.o
ninja: build stopped: subcommand failed.

With the patch it works fine.

With regards,
Reinoud

Quoted 28 lines
Quoted 28 lines
---
 include/sysemu/nvmm.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
include/sysemu/nvmm.h +4 -3
index 6d216599b0..833670fccb 100644
@@ -10,8 +10,7 @@
 #ifndef QEMU_NVMM_H
 #define QEMU_NVMM_H
 
-#include "config-host.h"
-#include "qemu-common.h"
+#ifdef NEED_CPU_H
 
 #ifdef CONFIG_NVMM
 
@@ -23,4 +22,6 @@ int nvmm_enabled(void);
 
 #endif /* CONFIG_NVMM */
 
-#endif /* CONFIG_NVMM */
+#endif /* NEED_CPU_H */
+
+#endif /* QEMU_NVMM_H */
#5 lore raw

PATCH 2/2 Fix nvmm_ram_block_added() function arguments

In reply to Reinoud Zandijk

A parameter max_size was added to the RAMBlockNotifier ram_block_added function. Use the max_size for pre allocation of hva space.

---
 target/i386/nvmm/nvmm-all.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/i386/nvmm/nvmm-all.c +3 -2
index dfa690d65d..fdcd37ed3e 100644
@@ -1134,13 +1134,14 @@ static MemoryListener nvmm_memory_listener = {
 };
 
 static void
-nvmm_ram_block_added(RAMBlockNotifier *n, void *host, size_t size)
+nvmm_ram_block_added(RAMBlockNotifier *n, void *host, size_t size,
+                     size_t max_size)
 {
     struct nvmm_machine *mach = get_nvmm_mach();
     uintptr_t hva = (uintptr_t)host;
     int ret;
 
-    ret = nvmm_hva_map(mach, hva, size);
+    ret = nvmm_hva_map(mach, hva, max_size);
 
     if (ret == -1) {
         error_report("NVMM: Failed to map HVA, HostVA:%p "
Signature · 1 line
2.31.1
#6 lore raw

Re: [PATCH v1 2/2] Fix nvmm_ram_block_added() function arguments

Quoted 21 lines · Reinoud Zandijk

A parameter max_size was added to the RAMBlockNotifier ram_block_added function. Use the max_size for pre allocation of hva space.

---
 target/i386/nvmm/nvmm-all.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/i386/nvmm/nvmm-all.c +2 -1
index dfa690d65d..fdcd37ed3e 100644
@@ -1134,13 +1134,14 @@ static MemoryListener nvmm_memory_listener = {
 };
 
 static void
-nvmm_ram_block_added(RAMBlockNotifier *n, void *host, size_t size)
+nvmm_ram_block_added(RAMBlockNotifier *n, void *host, size_t size,
+                     size_t max_size)

target/i386/nvmm/nvmm-all.c static MemoryListener nvmm_memory_listener = { · line 1147

Quoted 10 lines
target/i386/nvmm/nvmm-all.c +1 -1
 {
     struct nvmm_machine *mach = get_nvmm_mach();
     uintptr_t hva = (uintptr_t)host;
     int ret;
 
-    ret = nvmm_hva_map(mach, hva, size);
+    ret = nvmm_hva_map(mach, hva, max_size);
 
     if (ret == -1) {
         error_report("NVMM: Failed to map HVA, HostVA:%p "

This suggests that this code isn't being covered by our CI. Is there something we can do to get it tested?

-- PMM

#7 lore raw

Re: [PATCH v1 2/2] Fix nvmm_ram_block_added() function arguments

Hi,

Quoted 26 lines · Peter Maydell
Quoted 25 lines · Reinoud Zandijk

A parameter max_size was added to the RAMBlockNotifier ram_block_added function. Use the max_size for pre allocation of hva space.

---
 target/i386/nvmm/nvmm-all.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/i386/nvmm/nvmm-all.c +2 -1
index dfa690d65d..fdcd37ed3e 100644
@@ -1134,13 +1134,14 @@ static MemoryListener nvmm_memory_listener = {
 };
 
 static void
-nvmm_ram_block_added(RAMBlockNotifier *n, void *host, size_t size)
+nvmm_ram_block_added(RAMBlockNotifier *n, void *host, size_t size,
+                     size_t max_size)
 {
     struct nvmm_machine *mach = get_nvmm_mach();
     uintptr_t hva = (uintptr_t)host;
     int ret;
 
Quoted 8 lines

target/i386/nvmm/nvmm-all.c static MemoryListener nvmm_memory_listener = { · line 1147

Quoted 5 lines
target/i386/nvmm/nvmm-all.c +1 -1
-    ret = nvmm_hva_map(mach, hva, size);
+    ret = nvmm_hva_map(mach, hva, max_size);
 
     if (ret == -1) {
         error_report("NVMM: Failed to map HVA, HostVA:%p "

This suggests that this code isn't being covered by our CI. Is there something we can do to get it tested?

NVMM acceleration is currently NetBSD host only so can only be tested on NetBSD hosts. Unless Qemu is smart enough to allow a guest NetBSD to run NetBSD to test NVMM in a nested Qemu I don't think its possible to otherwise automatically test on Linux.

Is there a README or documentation on how to modify and run the tests?

With regard,
Reinoud

#8 lore raw

applied? Re: [PATCH v1 0/2] Update NVMM support to recent changes, [PATCH v1 1/2] Only check CONFIG_NVMM when NEED_CPU_H is defined, [PATCH v1 2/2] Fix nvmm_ram_block_added() function arguments

In reply to Reinoud Zandijk

Hi :)

Have these patches been applied? How can I easily check it without manually checking if they are there in a git pullup? Am I notified normally when patches are applied?

With regards,
Reinoud

Quoted 16 lines · Reinoud Zandijk

This patchset fixes small NVMM accelerator compilation issues due to changes made in the rest of Qemu since its import.

---

Reinoud Zandijk (2):
Only check CONFIG_NVMM when NEED_CPU_H is defined Fix nvmm_ram_block_added() function arguments

 include/sysemu/nvmm.h       | 7 ++++---
 target/i386/nvmm/nvmm-all.c | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.31.1
Quoted 31 lines · Reinoud Zandijk

Userland targers will otherwise use a poisoned CONFIG_NVMM

---
 include/sysemu/nvmm.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
include/sysemu/nvmm.h +4 -3
index 6d216599b0..833670fccb 100644
@@ -10,8 +10,7 @@
 #ifndef QEMU_NVMM_H
 #define QEMU_NVMM_H
 
-#include "config-host.h"
-#include "qemu-common.h"
+#ifdef NEED_CPU_H
 
 #ifdef CONFIG_NVMM
 
@@ -23,4 +22,6 @@ int nvmm_enabled(void);
 
 #endif /* CONFIG_NVMM */
 
-#endif /* CONFIG_NVMM */
+#endif /* NEED_CPU_H */
+
+#endif /* QEMU_NVMM_H */
Signature · 1 line
2.31.1
Quoted 32 lines · Reinoud Zandijk

A parameter max_size was added to the RAMBlockNotifier ram_block_added function. Use the max_size for pre allocation of hva space.

---
 target/i386/nvmm/nvmm-all.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/i386/nvmm/nvmm-all.c +3 -2
index dfa690d65d..fdcd37ed3e 100644
@@ -1134,13 +1134,14 @@ static MemoryListener nvmm_memory_listener = {
 };
 
 static void
-nvmm_ram_block_added(RAMBlockNotifier *n, void *host, size_t size)
+nvmm_ram_block_added(RAMBlockNotifier *n, void *host, size_t size,
+                     size_t max_size)
 {
     struct nvmm_machine *mach = get_nvmm_mach();
     uintptr_t hva = (uintptr_t)host;
     int ret;
 
-    ret = nvmm_hva_map(mach, hva, size);
+    ret = nvmm_hva_map(mach, hva, max_size);
 
     if (ret == -1) {
         error_report("NVMM: Failed to map HVA, HostVA:%p "
Signature · 1 line
2.31.1
#9 lore raw

Re: applied? Re: [PATCH v1 0/2] Update NVMM support to recent changes, [PATCH v1 1/2] Only check CONFIG_NVMM when NEED_CPU_H is defined, [PATCH v1 2/2] Fix nvmm_ram_block_added() function arguments

Quoted 6 lines · Reinoud Zandijk

Hi :)

Have these patches been applied? How can I easily check it without manually checking if they are there in a git pullup? Am I notified normally when patches are applied?

Generally when a submaintainer picks up a patchset they'll send an email reply to the patch cover letter to say they've done so. At that point it should get into upstream git eventually. Until that happens it's the initial submitter's responsibility to 'ping' the patch after a few weeks if nobody's replied to it or reviewed it.

Ccing Paolo who seems to have taken the initial nvmm patches through his tree.

thanks
-- PMM

#10 lore raw

Re: applied? Re: [PATCH v1 0/2] Update NVMM support to recent changes, [PATCH v1 1/2] Only check CONFIG_NVMM when NEED_CPU_H is defined, [PATCH v1 2/2] Fix nvmm_ram_block_added() function arguments

ping?

Quoted 20 lines · Peter Maydell
Quoted 6 lines · Reinoud Zandijk

Hi :)

Have these patches been applied? How can I easily check it without manually checking if they are there in a git pullup? Am I notified normally when patches are applied?

Generally when a submaintainer picks up a patchset they'll send an email reply to the patch cover letter to say they've done so. At that point it should get into upstream git eventually. Until that happens it's the initial submitter's responsibility to 'ping' the patch after a few weeks if nobody's replied to it or reviewed it.

Ccing Paolo who seems to have taken the initial nvmm patches through his tree.

thanks
-- PMM

#11 lore raw

Re: applied? Re: [PATCH v1 0/2] Update NVMM support to recent changes, [PATCH v1 1/2] Only check CONFIG_NVMM when NEED_CPU_H is defined, [PATCH v1 2/2] Fix nvmm_ram_block_added() function arguments

Quoted 1 line · Reinoud Zandijk

ping?

Queued, thanks.

Paolo

Quoted 22 lines · Peter Maydell
Quoted 20 lines · Reinoud Zandijk
Quoted 6 lines

Hi :)

Have these patches been applied? How can I easily check it without manually checking if they are there in a git pullup? Am I notified normally when patches are applied?

Generally when a submaintainer picks up a patchset they'll send an email reply to the patch cover letter to say they've done so. At that point it should get into upstream git eventually. Until that happens it's the initial submitter's responsibility to 'ping' the patch after a few weeks if nobody's replied to it or reviewed it.

Ccing Paolo who seems to have taken the initial nvmm patches through his tree.

thanks
-- PMM