Module Name:    src
Committed By:   reinoud
Date:           Tue Apr  6 08:40:17 UTC 2021

Modified Files:
        src/lib/libnvmm: libnvmm.c nvmm.h

Log Message:
Implement nvmm_vcpu::stop, a race-free exit from nvmm_vcpu_run() without
signals. This introduces a new kernel and userland NVMM version indicating
this support.

Patch by Kamil Rytarowski <[email protected]> and committed on his request.

This is the missing libnvmm part I forgot to include in the origional commit.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libnvmm/libnvmm.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libnvmm/nvmm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libnvmm/libnvmm.c
diff -u src/lib/libnvmm/libnvmm.c:1.19 src/lib/libnvmm/libnvmm.c:1.20
--- src/lib/libnvmm/libnvmm.c:1.19	Sat Sep  5 07:22:25 2020
+++ src/lib/libnvmm/libnvmm.c	Tue Apr  6 08:40:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: libnvmm.c,v 1.19 2020/09/05 07:22:25 maxv Exp $	*/
+/*	$NetBSD: libnvmm.c,v 1.20 2021/04/06 08:40:17 reinoud Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -310,6 +310,7 @@ nvmm_vcpu_create(struct nvmm_machine *ma
 	vcpu->cpuid = cpuid;
 	vcpu->state = &comm->state;
 	vcpu->event = &comm->event;
+	vcpu->stop = &comm->stop;
 	vcpu->exit = malloc(sizeof(*vcpu->exit));
 
 	return 0;
@@ -561,3 +562,12 @@ nvmm_ctl(int op, void *data, size_t size
 
 	return 0;
 }
+
+int
+nvmm_vcpu_stop(struct nvmm_vcpu *vcpu)
+{
+
+	*vcpu->stop = 1;
+
+	return 0;
+}

Index: src/lib/libnvmm/nvmm.h
diff -u src/lib/libnvmm/nvmm.h:1.18 src/lib/libnvmm/nvmm.h:1.19
--- src/lib/libnvmm/nvmm.h:1.18	Sat Sep  5 07:22:25 2020
+++ src/lib/libnvmm/nvmm.h	Tue Apr  6 08:40:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm.h,v 1.18 2020/09/05 07:22:25 maxv Exp $	*/
+/*	$NetBSD: nvmm.h,v 1.19 2021/04/06 08:40:17 reinoud Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -37,7 +37,12 @@
 #include <dev/nvmm/nvmm.h>
 #include <dev/nvmm/nvmm_ioctl.h>
 
-#define NVMM_USER_VERSION	1
+#define NVMM_USER_VERSION	2
+
+/*
+ * Version 1 - Initial release in NetBSD 9.0.
+ * Version 2 - Added nvmm_vcpu::stop.
+ */
 
 struct nvmm_io;
 struct nvmm_mem;
@@ -59,6 +64,7 @@ struct nvmm_vcpu {
 	struct nvmm_vcpu_state *state;
 	struct nvmm_vcpu_event *event;
 	struct nvmm_vcpu_exit *exit;
+	volatile int *stop;
 };
 
 struct nvmm_io {
@@ -123,4 +129,6 @@ int nvmm_ctl(int, void *, size_t);
 
 int nvmm_vcpu_dump(struct nvmm_machine *, struct nvmm_vcpu *);
 
+int nvmm_vcpu_stop(struct nvmm_vcpu *);
+
 #endif /* _LIBNVMM_H_ */

Reply via email to