summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@joyent.com>2011-08-02 15:55:47 -0700
committerBryan Cantrill <bryan@joyent.com>2011-08-02 15:55:47 -0700
commit62b8ef8a4aa3e8654c348075846de8cdbefcb7f2 (patch)
tree7da2e51353c69e48787b6007ace08e2cf92a3f24
parent42706f289f82a54242eeb1116c945b223bf5bfad (diff)
downloadillumos-kvm-62b8ef8a4aa3e8654c348075846de8cdbefcb7f2.tar.gz
HVM-206 need to eliminate "mm" field from kvm structure
-rw-r--r--kvm.c55
-rw-r--r--kvm_host.h1
-rw-r--r--kvm_x86.c30
3 files changed, 2 insertions, 84 deletions
diff --git a/kvm.c b/kvm.c
index 571567c..0c7f1c0 100644
--- a/kvm.c
+++ b/kvm.c
@@ -627,7 +627,6 @@ kvm_destroy_vm(struct kvm *kvmp)
mutex_destroy(&kvmp->lock);
mutex_destroy(&kvmp->requests_lock);
mutex_destroy(&kvmp->mmu_lock);
- kvmp->mm = NULL;
kvm_fini_mmu_notifier(kvmp);
for (ii = 0; ii < KVM_NR_BUSES; ii++)
@@ -678,11 +677,6 @@ kvm_create_vm(void)
return (NULL);
}
- /*
- * XXX note that the as struct does not contain a refcnt, may
- * have to go lower
- */
- kvmp->mm = curproc->p_as;
mutex_init(&kvmp->mmu_lock, NULL, MUTEX_DRIVER, NULL);
mutex_init(&kvmp->requests_lock, NULL, MUTEX_DRIVER, NULL);
mutex_init(&kvmp->lock, NULL, MUTEX_DRIVER, NULL);
@@ -1090,30 +1084,7 @@ kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn)
unsigned long
kvm_host_page_size(struct kvm *kvm, gfn_t gfn)
{
- struct vm_area_struct *vma;
- unsigned long addr, size;
-
- size = PAGESIZE;
-
- addr = gfn_to_hva(kvm, gfn);
- if (kvm_is_error_hva(addr))
- return (PAGESIZE);
-
-#ifdef XXX
- down_read(&current->mm->mmap_sem);
- vma = find_vma(current->mm, addr);
- if (!vma)
- goto out;
-
- size = vma_kernel_pagesize(vma);
-
-out:
- up_read(&current->mm->mmap_sem);
- return (size);
-#else
- XXX_KVM_PROBE;
return (PAGESIZE);
-#endif
}
int
@@ -1161,35 +1132,11 @@ hva_to_pfn(struct kvm *kvm, unsigned long addr)
proc_t *procp = ttoproc(curthread);
struct as *as = procp->p_as;
-#ifdef XXX
-
- npages = get_user_pages_fast(addr, 1, 1, page);
-
- if (unlikely(npages != 1)) {
- struct vm_area_struct *vma;
-
- down_read(&current->mm->mmap_sem);
- vma = find_vma(current->mm, addr);
-
- if (vma == NULL || addr < vma->vm_start ||
- !(vma->vm_flags & VM_PFNMAP)) {
- up_read(&current->mm->mmap_sem);
- get_page(bad_page);
- return (page_to_pfn(bad_page));
- }
-
- pfn = ((addr - vma->vm_start) >> PAGESHIFT) + vma->vm_pgoff;
- up_read(&current->mm->mmap_sem);
- BUG_ON(!kvm_is_mmio_pfn(pfn));
- } else
- pfn = page_to_pfn(page[0]);
-#else
- XXX_KVM_PROBE;
if (addr < kernelbase)
pfn = hat_getpfnum(as->a_hat, (caddr_t)addr);
else
pfn = hat_getpfnum(kas.a_hat, (caddr_t)addr);
-#endif
+
return (pfn);
}
diff --git a/kvm_host.h b/kvm_host.h
index 3b16e4c..d285866 100644
--- a/kvm_host.h
+++ b/kvm_host.h
@@ -182,7 +182,6 @@ typedef struct kvm {
kmutex_t mmu_lock;
kmutex_t requests_lock;
kmutex_t slots_lock;
- struct as *mm; /* userspace tied to this vm */
struct kvm_memslots *memslots;
kmutex_t memslots_lock; /* linux uses rcu for this */
/* the following was a read-copy update mechanism */
diff --git a/kvm_x86.c b/kvm_x86.c
index eda5a2f..abf376b 100644
--- a/kvm_x86.c
+++ b/kvm_x86.c
@@ -4994,23 +4994,8 @@ kvm_arch_prepare_memory_region(struct kvm *kvm,
*/
if (!user_alloc) {
if (npages && !old.rmap) {
-#ifdef XXX
- unsigned long userspace_addr;
-
- down_write(&current->mm->mmap_sem);
- userspace_addr = do_mmap(NULL, 0, npages * PAGESIZE,
- PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
- 0);
- up_write(&current->mm->mmap_sem);
-
- if (IS_ERR((void *)userspace_addr))
- return (PTR_ERR((void *)userspace_addr));
-#else
- int rval;
caddr_t userspace_addr = NULL;
- XXX_KVM_PROBE;
-
userspace_addr = smmap64(NULL,
(size_t)(npages * PAGESIZE),
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON,
@@ -5030,7 +5015,6 @@ kvm_arch_prepare_memory_region(struct kvm *kvm,
"mmap page\n");
}
}
-#endif
memslot->userspace_addr =
(unsigned long)userspace_addr;
@@ -5051,21 +5035,9 @@ kvm_arch_commit_memory_region(struct kvm *kvm,
if (!user_alloc && !old.user_alloc && old.rmap && !npages) {
int ret = 0;
-#ifdef XXX
- down_write(&current->mm->mmap_sem);
- ret = munmap(old.userspace_addr,
- old.npages * PAGESIZE);
- up_write(&current->mm->mmap_sem);
-#else
- XXX_KVM_PROBE;
/* see comment in kvm_arch_prepare_memory_region */
- /*
- * XXX this needs to be here, but I'm getting kernel heap
- * corruption panics with someone writing to a buffer after it
- * is freed
- */
kmem_free((caddr_t)old.userspace_addr, old.npages * PAGESIZE);
-#endif
+
if (ret < 0) {
cmn_err(CE_WARN, "kvm_vm_ioctl_set_memory_region: "
"failed to munmap memory\n");