summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Rosenfeld <hans.rosenfeld@joyent.com>2018-05-09 13:03:03 +0000
committerHans Rosenfeld <hans.rosenfeld@joyent.com>2018-05-09 13:56:50 +0000
commit2139ceaceb15b2ac9e5998c2fbd0601416fa233b (patch)
tree39e8702b172647f6acc41b5e925df3a520ccdef6
parentc94fcb2b120b468bb7758d8d85fbc65b925ca6f5 (diff)
downloadillumos-joyent-2139ceaceb15b2ac9e5998c2fbd0601416fa233b.tar.gz
OS-6907 vmm_stat initialization not run, causing 0-length allocation
Reviewed by: John Levon <john.levon@joyent.com> Reviewed by: Mike Gerdts <mike.gerdts@joyent.com> Approved by: John Levon <john.levon@joyent.com>
-rw-r--r--usr/contrib/freebsd/sys/linker_set.h2
-rw-r--r--usr/src/compat/freebsd/sys/kernel.h19
-rw-r--r--usr/src/uts/i86pc/io/vmm/vmm_sol_dev.c4
-rw-r--r--usr/src/uts/i86pc/io/vmm/vmm_sol_glue.c11
-rw-r--r--usr/src/uts/i86pc/io/vmm/vmm_stat.h10
-rw-r--r--usr/src/uts/i86pc/sys/vmm_dev.h7
-rw-r--r--usr/src/uts/i86pc/vmm/Makefile7
7 files changed, 54 insertions, 6 deletions
diff --git a/usr/contrib/freebsd/sys/linker_set.h b/usr/contrib/freebsd/sys/linker_set.h
index 393dfbc131..d766c5e2db 100644
--- a/usr/contrib/freebsd/sys/linker_set.h
+++ b/usr/contrib/freebsd/sys/linker_set.h
@@ -80,7 +80,7 @@
/*
* Initialize before referring to a given linker set.
*/
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(_KERNEL)
#define SET_DECLARE(set, ptype) \
extern ptype *__CONCAT(__start_set_,set); \
extern ptype *__CONCAT(__stop_set_,set)
diff --git a/usr/src/compat/freebsd/sys/kernel.h b/usr/src/compat/freebsd/sys/kernel.h
index 1de3418efa..adf96f40fc 100644
--- a/usr/src/compat/freebsd/sys/kernel.h
+++ b/usr/src/compat/freebsd/sys/kernel.h
@@ -11,17 +11,32 @@
/*
* Copyright 2013 Pluribus Networks Inc.
- * Copyright 2017 Joyent, Inc.
+ * Copyright 2018 Joyent, Inc.
*/
#ifndef _COMPAT_FREEBSD_SYS_KERNEL_H_
#define _COMPAT_FREEBSD_SYS_KERNEL_H_
-#define SYSINIT(uniquifier, subsystem, order, func, ident)
#define TUNABLE_INT_FETCH(path, var)
#include <sys/linker_set.h>
+typedef void (*sysinit_func_t)(const void *);
+
+struct sysinit {
+ const sysinit_func_t func;
+ const void *data;
+};
+
+#define SYSINIT(uniquifier, subsystem, order, func, ident) \
+ static struct sysinit uniquifier ## _sys_init = { \
+ (const sysinit_func_t)func, \
+ (const void *)&(ident) \
+ }; \
+ DATA_SET(sysinit_set, uniquifier ## _sys_init);
+
+extern void sysinit(void);
+
#define ticks ddi_get_lbolt()
#endif /* _COMPAT_FREEBSD_SYS_KERNEL_H_ */
diff --git a/usr/src/uts/i86pc/io/vmm/vmm_sol_dev.c b/usr/src/uts/i86pc/io/vmm/vmm_sol_dev.c
index b4ce5b93b6..66d5ce3b5d 100644
--- a/usr/src/uts/i86pc/io/vmm/vmm_sol_dev.c
+++ b/usr/src/uts/i86pc/io/vmm/vmm_sol_dev.c
@@ -29,6 +29,8 @@
#include <sys/id_space.h>
#include <sys/fs/sdev_plugin.h>
+#include <sys/kernel.h>
+
#include <sys/vmm.h>
#include <sys/vmm_instruction_emul.h>
#include <sys/vmm_dev.h>
@@ -1971,6 +1973,8 @@ _init(void)
{
int error;
+ sysinit();
+
mutex_init(&vmmdev_mtx, NULL, MUTEX_DRIVER, NULL);
mutex_init(&vmm_mtx, NULL, MUTEX_DRIVER, NULL);
list_create(&vmmdev_list, sizeof (vmm_softc_t),
diff --git a/usr/src/uts/i86pc/io/vmm/vmm_sol_glue.c b/usr/src/uts/i86pc/io/vmm/vmm_sol_glue.c
index a58e77bb02..59e811ed20 100644
--- a/usr/src/uts/i86pc/io/vmm/vmm_sol_glue.c
+++ b/usr/src/uts/i86pc/io/vmm/vmm_sol_glue.c
@@ -61,10 +61,21 @@
#include <machine/specialreg.h>
#include <machine/vmm.h>
#include <sys/vmm_impl.h>
+#include <sys/kernel.h>
#include <vm/as.h>
#include <vm/seg_kmem.h>
+SET_DECLARE(sysinit_set, struct sysinit);
+
+void
+sysinit(void)
+{
+ struct sysinit **si;
+
+ SET_FOREACH(si, sysinit_set)
+ (*si)->func((*si)->data);
+}
u_char const bin2bcd_data[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
diff --git a/usr/src/uts/i86pc/io/vmm/vmm_stat.h b/usr/src/uts/i86pc/io/vmm/vmm_stat.h
index 0ea1b49280..1193cea368 100644
--- a/usr/src/uts/i86pc/io/vmm/vmm_stat.h
+++ b/usr/src/uts/i86pc/io/vmm/vmm_stat.h
@@ -31,15 +31,21 @@
* $FreeBSD$
*/
/*
- * Copyright 2017 Joyent, Inc.
+ * Copyright 2018 Joyent, Inc.
*/
#ifndef _VMM_STAT_H_
#define _VMM_STAT_H_
+#include <machine/vmm.h>
+
struct vm;
-#define MAX_VMM_STAT_ELEMS 64 /* arbitrary */
+#ifdef __FreeBSD__
+#define MAX_VMM_STAT_ELEMS 64 /* arbitrary */
+#else
+#define MAX_VMM_STAT_ELEMS (64 + VM_MAXCPU) /* arbitrary */
+#endif
enum vmm_stat_scope {
VMM_STAT_SCOPE_ANY,
diff --git a/usr/src/uts/i86pc/sys/vmm_dev.h b/usr/src/uts/i86pc/sys/vmm_dev.h
index 79b6d4b505..a737ab1ad5 100644
--- a/usr/src/uts/i86pc/sys/vmm_dev.h
+++ b/usr/src/uts/i86pc/sys/vmm_dev.h
@@ -44,6 +44,8 @@
#ifndef _VMM_DEV_H_
#define _VMM_DEV_H_
+#include <machine/vmm.h>
+
struct vm_memmap {
vm_paddr_t gpa;
int segid; /* memory segment */
@@ -209,7 +211,12 @@ struct vm_nmi {
int cpuid;
};
+#ifdef __FreeBSD__
#define MAX_VM_STATS 64
+#else
+#define MAX_VM_STATS (64 + VM_MAXCPU)
+#endif
+
struct vm_stats {
int cpuid; /* in */
int num_entries; /* out */
diff --git a/usr/src/uts/i86pc/vmm/Makefile b/usr/src/uts/i86pc/vmm/Makefile
index f6ffbbeeb7..97633d9abb 100644
--- a/usr/src/uts/i86pc/vmm/Makefile
+++ b/usr/src/uts/i86pc/vmm/Makefile
@@ -11,7 +11,7 @@
#
# Copyright 2013 Pluribus Networks Inc.
-# Copyright 2017 Joyent, Inc.
+# Copyright 2018 Joyent, Inc.
#
#
@@ -91,6 +91,8 @@ AS_INC_PATH += -I$(UTSBASE)/i86pc/io/vmm -I$(OBJS_DIR)
CFLAGS += -_gcc=-Wimplicit-function-declaration
# The FreeBSD %# notation makes gcc gripe
CFLAGS += -_gcc=-Wno-format
+# enable collection of VMM statistics
+CFLAGS += -DVMM_KEEP_STATS
$(OBJS_DIR)/vmm.o := CERRWARN += -_gcc=-Wno-pointer-sign -_gcc=-Wno-type-limits
$(OBJS_DIR)/svm.o := CERRWARN += -_gcc=-Wno-pointer-sign -_gcc=-Wno-type-limits
@@ -107,6 +109,9 @@ ASSYM_H = $(ASSYM_VMX) $(ASSYM_SVM)
CLEANFILES += $(ASSYM_H)
+# create linker set start/stop symbols, needed by VMM stats
+POST_PROCESS += ; $(GENSETDEFS) $@
+
#
# Default build targets.
#