Fix locking in vmmemctl

Submitted by:	kan
This commit is contained in:
Martin Blapp 2009-04-09 21:19:03 +00:00
parent 99e917a2c8
commit d2ae6a2f47
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=231954
2 changed files with 43 additions and 0 deletions

View file

@ -7,6 +7,7 @@
PORTNAME= open-vm-tools
PORTVERSION= ${BUILD_VER}
PORTREVISION= 1
CATEGORIES= emulators kld
MASTER_SITES= SF
DISTNAME= open-vm-tools-${RELEASE_DATE}-${BUILD_VER}

View file

@ -0,0 +1,42 @@
--- modules/freebsd/vmmemctl/os.c.orig 2009-04-09 15:18:08.000000000 -0400
+++ modules/freebsd/vmmemctl/os.c 2009-04-09 15:34:06.000000000 -0400
@@ -260,12 +260,14 @@
os_state *state = &global_state;
os_pmap *pmap = &state->pmap;
- if ( !vm_page_lookup(state->vmobject, page->pindex) ) {
- return;
+ VM_OBJECT_LOCK(state->vmobject);
+ if ( vm_page_lookup(state->vmobject, page->pindex) ) {
+ os_pmap_putindex(pmap, page->pindex);
+ vm_page_lock_queues();
+ vm_page_free(page);
+ vm_page_unlock_queues();
}
-
- os_pmap_putindex(pmap, page->pindex);
- vm_page_free(page);
+ VM_OBJECT_UNLOCK(state->vmobject);
}
static vm_page_t os_kmem_alloc(int alloc_normal_failed)
@@ -275,8 +277,11 @@
os_state *state = &global_state;
os_pmap *pmap = &state->pmap;
+ VM_OBJECT_LOCK(state->vmobject);
+
pindex = os_pmap_getindex(pmap);
if (pindex == (vm_pindex_t)-1) {
+ VM_OBJECT_UNLOCK(state->vmobject);
return NULL;
}
@@ -297,6 +302,7 @@
if (!page) {
os_pmap_putindex(pmap, pindex);
}
+ VM_OBJECT_UNLOCK(state->vmobject);
return page;
}