summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2011-06-07 10:32:00 -0700
committerRobert Mustacchi <rm@joyent.com>2011-06-07 10:32:00 -0700
commit2364bf7d769a49bcbd609f713f33ec89c68f1443 (patch)
tree7054dd4100463e525e2c34e118c387a018b36a56
parentf0083bc5a917fa0ebb63e296c158d7b1543eb8f3 (diff)
downloadillumos-kvm-2364bf7d769a49bcbd609f713f33ec89c68f1443.tar.gz
HVM-313 vpid related pieces should all be in kvm_vmx.c
-rw-r--r--kvm.c32
-rw-r--r--kvm_vmx.c32
-rw-r--r--kvm_vmx.h3
3 files changed, 29 insertions, 38 deletions
diff --git a/kvm.c b/kvm.c
index 5ef3c78..968c26d 100644
--- a/kvm.c
+++ b/kvm.c
@@ -156,7 +156,6 @@ static int hardware_enable_all(void);
static void hardware_disable_all(void);
static void kvm_destroy_vm(struct kvm *);
static int kvm_avlmmucmp(const void *, const void *);
-extern int enable_vpid;
extern struct kvm_x86_ops vmx_x86_ops;
extern struct kvm_shared_msrs **shared_msrs;
extern int make_all_cpus_request(struct kvm *, unsigned int);
@@ -170,7 +169,6 @@ kmem_cache_t *kvm_vcpu_cache;
struct kvm_x86_ops *kvm_x86_ops;
-#define VMX_NR_VPIDS (1 << 16)
ulong_t *vmx_vpid_bitmap;
size_t vpid_bitmap_words;
kmutex_t vmx_vpid_lock;
@@ -682,41 +680,21 @@ kvm_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
return (DDI_FAILURE);
}
- if (enable_vpid) {
- vpid_bitmap_words = howmany(VMX_NR_VPIDS, 64);
- vmx_vpid_bitmap = kmem_zalloc(sizeof (ulong_t) *
- vpid_bitmap_words, KM_SLEEP);
- mutex_init(&vmx_vpid_lock, NULL, MUTEX_DRIVER, NULL);
- }
-
mutex_init(&kvm_lock, NULL, MUTEX_DRIVER, 0);
kvm_x86_ops = &vmx_x86_ops;
if (vmx_init() != DDI_SUCCESS) {
ddi_soft_state_fini(&kvm_state);
ddi_remove_minor_node(dip, NULL);
mutex_destroy(&kvm_lock);
- if (enable_vpid && vmx_vpid_bitmap != NULL) {
- kmem_free(vmx_vpid_bitmap,
- sizeof (ulong_t) * vpid_bitmap_words);
- mutex_destroy(&vmx_vpid_lock);
- }
-
return (DDI_FAILURE);
}
if (hardware_enable_all() != 0) {
- /* XXX Missing vmx_fini */
ddi_soft_state_fini(&kvm_state);
ddi_remove_minor_node(dip, NULL);
mutex_destroy(&kvm_lock);
- if (enable_vpid && vmx_vpid_bitmap != NULL) {
- kmem_free(vmx_vpid_bitmap,
- sizeof (ulong_t) * vpid_bitmap_words);
- mutex_destroy(&vmx_vpid_lock);
- }
-
+ vmx_fini();
return (DDI_FAILURE);
-
}
kvm_dip = dip;
@@ -750,15 +728,9 @@ kvm_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
kvm_dip = NULL;
hardware_disable_all();
- if (enable_vpid && vmx_vpid_bitmap != NULL) {
- kmem_free(vmx_vpid_bitmap,
- sizeof (ulong_t) * vpid_bitmap_words);
- mutex_destroy(&vmx_vpid_lock);
- }
mutex_destroy(&kvm_lock);
ddi_soft_state_fini(&kvm_state);
-
- /* XXX Mising vmx_fini */
+ vmx_fini();
return (DDI_SUCCESS);
}
diff --git a/kvm_vmx.c b/kvm_vmx.c
index abce161..c3f4836 100644
--- a/kvm_vmx.c
+++ b/kvm_vmx.c
@@ -17,6 +17,7 @@
*
*/
+#include <sys/sysmacros.h>
#include <sys/types.h>
#include <sys/mach_mmu.h>
#include <asm/cpu.h>
@@ -34,14 +35,13 @@
#include "kvm_mmu.h"
#include "kvm_vmx.h"
-/* XXX These shouldn't need to be static */
-extern kmutex_t vmx_vpid_lock;
-extern ulong_t *vmx_vpid_bitmap;
-extern size_t vpid_bitmap_words;
-
+/* XXX These should be static */
+#define VMX_NR_VPIDS (1 << 16)
+static kmutex_t vmx_vpid_lock;
+static ulong_t *vmx_vpid_bitmap;
+static size_t vpid_bitmap_words;
static int bypass_guest_pf = 1;
-/* XXX This should be static */
-int enable_vpid = 1;
+static int enable_vpid = 1;
static int flexpriority_enabled = 1;
static int enable_ept = 1;
static int enable_unrestricted_guest = 1;
@@ -4605,6 +4605,13 @@ vmx_init(void)
for (i = 0; i < NR_VMX_MSR; ++i)
kvm_define_shared_msr(i, vmx_msr_index[i]);
+ if (enable_vpid) {
+ vpid_bitmap_words = howmany(VMX_NR_VPIDS, 64);
+ vmx_vpid_bitmap = kmem_zalloc(sizeof (ulong_t) *
+ vpid_bitmap_words, KM_SLEEP);
+ mutex_init(&vmx_vpid_lock, NULL, MUTEX_DRIVER, NULL);
+ }
+
#ifdef XXX
vmx_io_bitmap_a = kmem_zalloc(PAGESIZE, KM_SLEEP);
vmx_io_bitmap_b = kmem_zalloc(PAGESIZE, KM_SLEEP);
@@ -4666,3 +4673,14 @@ out:
return (r);
}
+
+void
+vmx_fini(void)
+{
+ XXX_KVM_PROBE;
+ if (enable_vpid) {
+ mutex_destroy(&vmx_vpid_lock);
+ kmem_free(vmx_vpid_bitmap, sizeof (ulong_t) *
+ vpid_bitmap_words);
+ }
+}
diff --git a/kvm_vmx.h b/kvm_vmx.h
index d2dd057..9d49a54 100644
--- a/kvm_vmx.h
+++ b/kvm_vmx.h
@@ -27,9 +27,10 @@
/*
* Currently we use one kernel module for all of kvm. This is the entry point
- * for initializing the VMX subsystem.
+ * for initializing and tearing down the VMX subsystem.
*/
extern int vmx_init(void);
+extern void vmx_fini(void);
/*
* Definitions of Primary Processor-Based VM-Execution Controls.