summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mooney <pmooney@pfmooney.com>2022-04-26 22:17:57 +0000
committerPatrick Mooney <pmooney@oxide.computer>2022-05-02 21:35:55 +0000
commit3466010b6f73e5cbeb612e538494c9d42c6d4a68 (patch)
treef8e7fc9ec946d74e49c8f6938bd8728918d6489e
parent2a22bccab8733d6de38ab1e1fbe8c810122a4427 (diff)
downloadillumos-joyent-3466010b6f73e5cbeb612e538494c9d42c6d4a68.tar.gz
14660 expose bhyve kernel interface version
Reviewed by: Andy Fiddaman <andy@omnios.org> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r--usr/src/pkg/manifests/system-bhyve-tests.p5m1
-rw-r--r--usr/src/test/bhyve-tests/runfiles/default.run1
-rw-r--r--usr/src/test/bhyve-tests/tests/vmm/Makefile3
-rw-r--r--usr/src/test/bhyve-tests/tests/vmm/interface_version.c48
-rw-r--r--usr/src/uts/intel/io/vmm/vmm_sol_dev.c3
-rw-r--r--usr/src/uts/intel/sys/vmm_dev.h19
6 files changed, 74 insertions, 1 deletions
diff --git a/usr/src/pkg/manifests/system-bhyve-tests.p5m b/usr/src/pkg/manifests/system-bhyve-tests.p5m
index 1a0ba140ce..d4c8be469f 100644
--- a/usr/src/pkg/manifests/system-bhyve-tests.p5m
+++ b/usr/src/pkg/manifests/system-bhyve-tests.p5m
@@ -50,6 +50,7 @@ file path=opt/bhyve-tests/tests/mevent/vnode_file mode=0555
file path=opt/bhyve-tests/tests/mevent/vnode_zvol mode=0555
dir path=opt/bhyve-tests/tests/vmm
file path=opt/bhyve-tests/tests/vmm/fpu_getset mode=0555
+file path=opt/bhyve-tests/tests/vmm/interface_version mode=0555
file path=opt/bhyve-tests/tests/vmm/mem_devmem mode=0555
file path=opt/bhyve-tests/tests/vmm/mem_partial mode=0555
file path=opt/bhyve-tests/tests/vmm/mem_seg_map mode=0555
diff --git a/usr/src/test/bhyve-tests/runfiles/default.run b/usr/src/test/bhyve-tests/runfiles/default.run
index 476fa5f839..9296a30852 100644
--- a/usr/src/test/bhyve-tests/runfiles/default.run
+++ b/usr/src/test/bhyve-tests/runfiles/default.run
@@ -23,6 +23,7 @@ outputdir = /var/tmp/test_results
user = root
tests = [
'fpu_getset',
+ 'interface_version',
'mem_devmem',
'mem_partial',
'mem_seg_map'
diff --git a/usr/src/test/bhyve-tests/tests/vmm/Makefile b/usr/src/test/bhyve-tests/tests/vmm/Makefile
index 1620706cb6..eeca882915 100644
--- a/usr/src/test/bhyve-tests/tests/vmm/Makefile
+++ b/usr/src/test/bhyve-tests/tests/vmm/Makefile
@@ -18,7 +18,8 @@ include $(SRC)/test/Makefile.com
PROG = mem_partial \
mem_seg_map \
mem_devmem \
- fpu_getset
+ fpu_getset \
+ interface_version
COMMON_OBJS = common.o
CLEAN_OBJS = $(PROG:%=%.o)
diff --git a/usr/src/test/bhyve-tests/tests/vmm/interface_version.c b/usr/src/test/bhyve-tests/tests/vmm/interface_version.c
new file mode 100644
index 0000000000..b3de2f4f4f
--- /dev/null
+++ b/usr/src/test/bhyve-tests/tests/vmm/interface_version.c
@@ -0,0 +1,48 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2022 Oxide Computer Company
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <libgen.h>
+
+#include <sys/vmm.h>
+#include <sys/vmm_dev.h>
+
+int
+main(int argc, char *argv[])
+{
+ const char *suite_name = basename(argv[0]);
+
+ int ctl_fd = open(VMM_CTL_DEV, O_EXCL | O_RDWR);
+ if (ctl_fd < 0) {
+ perror("could not open vmmctl device");
+ }
+
+ int version = ioctl(ctl_fd, VMM_INTERFACE_VERSION, 0);
+ if (version < 0) {
+ perror("VMM_INTERFACE_VERSION ioctl failed");
+ }
+ if (version != VMM_CURRENT_INTERFACE_VERSION) {
+ (void) fprintf(stderr, "kernel version %d != expected %d\n",
+ version, VMM_CURRENT_INTERFACE_VERSION);
+ return (EXIT_FAILURE);
+ }
+
+ (void) close(ctl_fd);
+ (void) printf("%s\tPASS\n", suite_name);
+ return (0);
+}
diff --git a/usr/src/uts/intel/io/vmm/vmm_sol_dev.c b/usr/src/uts/intel/io/vmm/vmm_sol_dev.c
index 3474ba905b..60a888e600 100644
--- a/usr/src/uts/intel/io/vmm/vmm_sol_dev.c
+++ b/usr/src/uts/intel/io/vmm/vmm_sol_dev.c
@@ -2489,6 +2489,9 @@ vmm_ctl_ioctl(int cmd, intptr_t arg, int md, cred_t *cr, int *rvalp)
}
case VMM_VM_SUPPORTED:
return (vmm_is_supported(arg));
+ case VMM_INTERFACE_VERSION:
+ *rvalp = VMM_CURRENT_INTERFACE_VERSION;
+ return (0);
case VMM_RESV_QUERY:
case VMM_RESV_ADD:
case VMM_RESV_REMOVE:
diff --git a/usr/src/uts/intel/sys/vmm_dev.h b/usr/src/uts/intel/sys/vmm_dev.h
index 027a7da214..0e883f21bb 100644
--- a/usr/src/uts/intel/sys/vmm_dev.h
+++ b/usr/src/uts/intel/sys/vmm_dev.h
@@ -350,6 +350,24 @@ struct vmm_dirty_tracker {
void *vdt_pfns; /* bit vector of dirty bits */
};
+/*
+ * VMM Interface Version
+ *
+ * Despite the fact that the kernel interface to bhyve is explicitly considered
+ * Private, there are out-of-gate consumers which utilize it. While they assume
+ * the risk of any breakage incurred by changes to bhyve, we can at least try to
+ * make it easier to detect changes by exposing a "version" of the interface.
+ * It can also be used by the in-gate userland to detect if packaging updates
+ * somehow result in the userland and kernel falling out of sync.
+ *
+ * There are no established criteria for the magnitude of change which requires
+ * this version to be incremented, and maintenance of it is considered a
+ * best-effort activity. Nothing is to be inferred about the magnitude of a
+ * change when the version is modified. It follows no rules like semver.
+ */
+#define VMM_CURRENT_INTERFACE_VERSION 1
+
+
#define VMMCTL_IOC_BASE (('V' << 16) | ('M' << 8))
#define VMM_IOC_BASE (('v' << 16) | ('m' << 8))
#define VMM_LOCK_IOC_BASE (('v' << 16) | ('l' << 8))
@@ -359,6 +377,7 @@ struct vmm_dirty_tracker {
#define VMM_CREATE_VM (VMMCTL_IOC_BASE | 0x01)
#define VMM_DESTROY_VM (VMMCTL_IOC_BASE | 0x02)
#define VMM_VM_SUPPORTED (VMMCTL_IOC_BASE | 0x03)
+#define VMM_INTERFACE_VERSION (VMMCTL_IOC_BASE | 0x04)
#define VMM_RESV_QUERY (VMMCTL_IOC_BASE | 0x10)
#define VMM_RESV_ADD (VMMCTL_IOC_BASE | 0x11)