Index: sys/dev/iscsi/iscsi_ioctl.c =================================================================== RCS file: /cvsroot/src/sys/dev/iscsi/iscsi_ioctl.c,v retrieving revision 1.30 diff -u -r1.30 iscsi_ioctl.c --- sys/dev/iscsi/iscsi_ioctl.c 7 Dec 2018 14:59:19 -0000 1.30 +++ sys/dev/iscsi/iscsi_ioctl.c 15 May 2020 16:31:15 -0000 @@ -1308,7 +1308,7 @@ if ((p->p_sflag & PS_WEXIT) || (p->p_vmspace->vm_refcnt < 1)) { return ISCSI_STATUS_NO_RESOURCES; } - p->p_vmspace->vm_refcnt++; + uvmspace_addref(p->p_vmspace); /* this is lifted from uvm_io */ error = uvm_map_extract(&p->p_vmspace->vm_map, databuf, datalen, Index: sys/kern/kern_proc.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_proc.c,v retrieving revision 1.251 diff -u -r1.251 kern_proc.c --- sys/kern/kern_proc.c 29 Apr 2020 01:52:26 -0000 1.251 +++ sys/kern/kern_proc.c 15 May 2020 16:31:27 -0000 @@ -1719,7 +1719,7 @@ /* curproc exception is for coredump. */ if ((p != curproc && (p->p_sflag & PS_WEXIT) != 0) || - (p->p_vmspace->vm_refcnt < 1)) { /* XXX */ + (p->p_vmspace->vm_refcnt < 1)) { return EFAULT; } Index: sys/kern/sys_process.c =================================================================== RCS file: /cvsroot/src/sys/kern/sys_process.c,v retrieving revision 1.179 diff -u -r1.179 sys_process.c --- sys/kern/sys_process.c 13 Apr 2017 07:58:45 -0000 1.179 +++ sys/kern/sys_process.c 15 May 2020 16:31:27 -0000 @@ -168,12 +168,10 @@ vm = p->p_vmspace; - mutex_enter(&vm->vm_map.misc_lock); if ((l->l_flag & LW_WEXIT) || vm->vm_refcnt < 1) error = EFAULT; if (error == 0) - p->p_vmspace->vm_refcnt++; /* XXX */ - mutex_exit(&vm->vm_map.misc_lock); + uvmspace_addref(p->p_vmspace); if (error != 0) return error; error = uvm_io(&vm->vm_map, uio, pax_mprotect_prot(l)); Index: sys/uvm/uvm_extern.h =================================================================== RCS file: /cvsroot/src/sys/uvm/uvm_extern.h,v retrieving revision 1.226 diff -u -r1.226 uvm_extern.h --- sys/uvm/uvm_extern.h 9 May 2020 15:13:19 -0000 1.226 +++ sys/uvm/uvm_extern.h 15 May 2020 16:31:41 -0000 @@ -566,8 +566,7 @@ */ struct vmspace { struct vm_map vm_map; /* VM address map */ - int vm_refcnt; /* number of references * - * note: protected by vm_map.misc_lock */ + volatile int vm_refcnt; /* number of references */ void * vm_shm; /* SYS5 shared memory private data XXX */ /* we copy from vm_startcopy to the end of the structure on fork */ #define vm_startcopy vm_rssize Index: sys/uvm/uvm_map.h =================================================================== RCS file: /cvsroot/src/sys/uvm/uvm_map.h,v retrieving revision 1.79 diff -u -r1.79 uvm_map.h --- sys/uvm/uvm_map.h 14 Mar 2020 14:15:43 -0000 1.79 +++ sys/uvm/uvm_map.h 15 May 2020 16:31:41 -0000 @@ -220,7 +220,7 @@ struct vm_map_entry header; /* List of entries */ int nentries; /* Number of entries */ vsize_t size; /* virtual size */ - int ref_count; /* Reference count */ + volatile int ref_count; /* Reference count */ struct vm_map_entry * hint; /* hint for quick lookups */ struct vm_map_entry * first_free; /* First free space hint */ unsigned int timestamp; /* Version number */