summaryrefslogtreecommitdiff
path: root/kvm_vmx.c
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2011-06-07 11:43:42 -0700
committerRobert Mustacchi <rm@joyent.com>2011-06-07 11:45:57 -0700
commitef2418c2fea033a74c4529eaf395f5fd1ada2393 (patch)
tree2915fa2e9f75bf706453e2e7486604004f104568 /kvm_vmx.c
parent15e76b055f98feb7f40d56bed2b78c6340a3270c (diff)
downloadillumos-kvm-ef2418c2fea033a74c4529eaf395f5fd1ada2393.tar.gz
HVM-316 kvm_vcpu_cache should live in kvm_vmx.c
Diffstat (limited to 'kvm_vmx.c')
-rw-r--r--kvm_vmx.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/kvm_vmx.c b/kvm_vmx.c
index c3f4836..fc8034b 100644
--- a/kvm_vmx.c
+++ b/kvm_vmx.c
@@ -35,7 +35,6 @@
#include "kvm_mmu.h"
#include "kvm_vmx.h"
-/* XXX These should be static */
#define VMX_NR_VPIDS (1 << 16)
static kmutex_t vmx_vpid_lock;
static ulong_t *vmx_vpid_bitmap;
@@ -46,6 +45,7 @@ static int flexpriority_enabled = 1;
static int enable_ept = 1;
static int enable_unrestricted_guest = 1;
static int emulate_invalid_guest_state = 0;
+static kmem_cache_t *kvm_vcpu_cache;
/*
* In linux, there is a separate vmx kernel module from the kvm driver.
@@ -4621,6 +4621,21 @@ vmx_init(void)
XXX_KVM_PROBE;
#endif
+ /* A kmem cache lets us meet the alignment requirements of fx_save. */
+ kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", sizeof (struct vcpu_vmx),
+#ifdef XXX_KVM_DECLARATION
+ (size_t)__alignof__(struct kvm_vcpu),
+#else
+ (size_t)PAGESIZE,
+#endif
+ zero_constructor, NULL, NULL, (void *)(sizeof (struct vcpu_vmx)),
+ NULL, 0);
+
+ if (kvm_vcpu_cache == NULL) {
+ r = ENOMEM;
+ goto out3;
+ }
+
/*
* Allow direct access to the PC debug port (it is often used for I/O
* delays, but the vmexits simply slow things down).
@@ -4635,10 +4650,10 @@ vmx_init(void)
set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */
- r = kvm_init(&vmx_x86_ops, sizeof (struct vcpu_vmx));
+ r = kvm_init(&vmx_x86_ops);
if (r)
- goto out3;
+ goto out4;
vmx_disable_intercept_for_msr(MSR_FS_BASE, 0);
vmx_disable_intercept_for_msr(MSR_GS_BASE, 0);
@@ -4662,6 +4677,9 @@ vmx_init(void)
return (0);
+
+out4:
+ kmem_cache_destroy(kvm_vcpu_cache);
out3:
kmem_free(vmx_msr_bitmap_longmode, PAGESIZE);
out2:
@@ -4683,4 +4701,5 @@ vmx_fini(void)
kmem_free(vmx_vpid_bitmap, sizeof (ulong_t) *
vpid_bitmap_words);
}
+ kmem_cache_destroy(kvm_vcpu_cache);
}