meson.build | 4 +--- target/i386/nvmm/nvmm-all.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-)
NVMM user version 1 is the version being shipped with netbsd-9,
which is the most recent stable branch of NetBSD. This makes it
possible to use the NVMM accelerator on the most recent NetBSD
release, 9.2, which lacks nvmm_cpu_stop.
(CC'ing maintainers)
Signed-off-by: Nia Alarie <nia@NetBSD.org>
---
meson.build | 4 +---
target/i386/nvmm/nvmm-all.c | 10 ++++++++++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index 15ef4d3c41..6e4d9b919a 100644
--- a/meson.build
+++ b/meson.build
@@ -244,9 +244,7 @@ if not get_option('hax').disabled()
endif
endif
if targetos == 'netbsd'
- if cc.has_header_symbol('nvmm.h', 'nvmm_cpu_stop', required: get_option('nvmm'))
- nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
- endif
+ nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
if nvmm.found()
accelerators += 'CONFIG_NVMM'
endif
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index a488b00e90..4a10412427 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -750,7 +750,11 @@ nvmm_vcpu_loop(CPUState *cpu)
nvmm_vcpu_pre_run(cpu);
if (qatomic_read(&cpu->exit_request)) {
+#if NVMM_USER_VERSION >= 2
nvmm_vcpu_stop(vcpu);
+#else
+ qemu_cpu_kick_self();
+#endif
}
/* Read exit_request before the kernel reads the immediate exit flag */
@@ -767,6 +771,7 @@ nvmm_vcpu_loop(CPUState *cpu)
switch (exit->reason) {
case NVMM_VCPU_EXIT_NONE:
break;
+#if NVMM_USER_VERSION >= 2
case NVMM_VCPU_EXIT_STOPPED:
/*
* The kernel cleared the immediate exit flag; cpu->exit_request
@@ -775,6 +780,7 @@ nvmm_vcpu_loop(CPUState *cpu)
smp_wmb();
qcpu->stop = true;
break;
+#endif
case NVMM_VCPU_EXIT_MEMORY:
ret = nvmm_handle_mem(mach, vcpu);
break;
@@ -888,8 +894,12 @@ nvmm_ipi_signal(int sigcpu)
{
if (current_cpu) {
struct qemu_vcpu *qcpu = get_qemu_vcpu(current_cpu);
+#if NVMM_USER_VERSION >= 2
struct nvmm_vcpu *vcpu = &qcpu->vcpu;
nvmm_vcpu_stop(vcpu);
+#else
+ qcpu->stop = true;
+#endif
}
}
--
2.33.0
Reviewed-by: Kamil Rytarowski <kamil@netbsd.org> Paolo, could you please merge it? On 13.10.2021 15:54, nia wrote: > NVMM user version 1 is the version being shipped with netbsd-9, > which is the most recent stable branch of NetBSD. This makes it > possible to use the NVMM accelerator on the most recent NetBSD > release, 9.2, which lacks nvmm_cpu_stop. > > (CC'ing maintainers) > > Signed-off-by: Nia Alarie <nia@NetBSD.org> > --- > meson.build | 4 +--- > target/i386/nvmm/nvmm-all.c | 10 ++++++++++ > 2 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/meson.build b/meson.build > index 15ef4d3c41..6e4d9b919a 100644 > --- a/meson.build > +++ b/meson.build > @@ -244,9 +244,7 @@ if not get_option('hax').disabled() > endif > endif > if targetos == 'netbsd' > - if cc.has_header_symbol('nvmm.h', 'nvmm_cpu_stop', required: get_option('nvmm')) > - nvmm = cc.find_library('nvmm', required: get_option('nvmm')) > - endif > + nvmm = cc.find_library('nvmm', required: get_option('nvmm')) > if nvmm.found() > accelerators += 'CONFIG_NVMM' > endif > diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c > index a488b00e90..4a10412427 100644 > --- a/target/i386/nvmm/nvmm-all.c > +++ b/target/i386/nvmm/nvmm-all.c > @@ -750,7 +750,11 @@ nvmm_vcpu_loop(CPUState *cpu) > nvmm_vcpu_pre_run(cpu); > > if (qatomic_read(&cpu->exit_request)) { > +#if NVMM_USER_VERSION >= 2 > nvmm_vcpu_stop(vcpu); > +#else > + qemu_cpu_kick_self(); > +#endif > } > > /* Read exit_request before the kernel reads the immediate exit flag */ > @@ -767,6 +771,7 @@ nvmm_vcpu_loop(CPUState *cpu) > switch (exit->reason) { > case NVMM_VCPU_EXIT_NONE: > break; > +#if NVMM_USER_VERSION >= 2 > case NVMM_VCPU_EXIT_STOPPED: > /* > * The kernel cleared the immediate exit flag; cpu->exit_request > @@ -775,6 +780,7 @@ nvmm_vcpu_loop(CPUState *cpu) > smp_wmb(); > qcpu->stop = true; > break; > +#endif > case NVMM_VCPU_EXIT_MEMORY: > ret = nvmm_handle_mem(mach, vcpu); > break; > @@ -888,8 +894,12 @@ nvmm_ipi_signal(int sigcpu) > { > if (current_cpu) { > struct qemu_vcpu *qcpu = get_qemu_vcpu(current_cpu); > +#if NVMM_USER_VERSION >= 2 > struct nvmm_vcpu *vcpu = &qcpu->vcpu; > nvmm_vcpu_stop(vcpu); > +#else > + qcpu->stop = true; > +#endif > } > } > >
Ping? It would be very nice if this could make it into 6.2 so we don't have to continue patching around this. On Tue, Nov 02, 2021 at 10:12:28AM +0100, Kamil Rytarowski wrote: > Reviewed-by: Kamil Rytarowski <kamil@netbsd.org> > > Paolo, could you please merge it? > > On 13.10.2021 15:54, nia wrote: > > NVMM user version 1 is the version being shipped with netbsd-9, > > which is the most recent stable branch of NetBSD. This makes it > > possible to use the NVMM accelerator on the most recent NetBSD > > release, 9.2, which lacks nvmm_cpu_stop. > > > > (CC'ing maintainers) > > > > Signed-off-by: Nia Alarie <nia@NetBSD.org> > > --- > > meson.build | 4 +--- > > target/i386/nvmm/nvmm-all.c | 10 ++++++++++ > > 2 files changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/meson.build b/meson.build > > index 15ef4d3c41..6e4d9b919a 100644 > > --- a/meson.build > > +++ b/meson.build > > @@ -244,9 +244,7 @@ if not get_option('hax').disabled() > > endif > > endif > > if targetos == 'netbsd' > > - if cc.has_header_symbol('nvmm.h', 'nvmm_cpu_stop', required: get_option('nvmm')) > > - nvmm = cc.find_library('nvmm', required: get_option('nvmm')) > > - endif > > + nvmm = cc.find_library('nvmm', required: get_option('nvmm')) > > if nvmm.found() > > accelerators += 'CONFIG_NVMM' > > endif > > diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c > > index a488b00e90..4a10412427 100644 > > --- a/target/i386/nvmm/nvmm-all.c > > +++ b/target/i386/nvmm/nvmm-all.c > > @@ -750,7 +750,11 @@ nvmm_vcpu_loop(CPUState *cpu) > > nvmm_vcpu_pre_run(cpu); > > > > if (qatomic_read(&cpu->exit_request)) { > > +#if NVMM_USER_VERSION >= 2 > > nvmm_vcpu_stop(vcpu); > > +#else > > + qemu_cpu_kick_self(); > > +#endif > > } > > > > /* Read exit_request before the kernel reads the immediate exit flag */ > > @@ -767,6 +771,7 @@ nvmm_vcpu_loop(CPUState *cpu) > > switch (exit->reason) { > > case NVMM_VCPU_EXIT_NONE: > > break; > > +#if NVMM_USER_VERSION >= 2 > > case NVMM_VCPU_EXIT_STOPPED: > > /* > > * The kernel cleared the immediate exit flag; cpu->exit_request > > @@ -775,6 +780,7 @@ nvmm_vcpu_loop(CPUState *cpu) > > smp_wmb(); > > qcpu->stop = true; > > break; > > +#endif > > case NVMM_VCPU_EXIT_MEMORY: > > ret = nvmm_handle_mem(mach, vcpu); > > break; > > @@ -888,8 +894,12 @@ nvmm_ipi_signal(int sigcpu) > > { > > if (current_cpu) { > > struct qemu_vcpu *qcpu = get_qemu_vcpu(current_cpu); > > +#if NVMM_USER_VERSION >= 2 > > struct nvmm_vcpu *vcpu = &qcpu->vcpu; > > nvmm_vcpu_stop(vcpu); > > +#else > > + qcpu->stop = true; > > +#endif > > } > > } > > > > >
© 2016 - 2024 Red Hat, Inc.