Date: Tue, 3 Apr 2018 09:38:54 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331921 - stable/11/sys/vm Message-ID: <201804030938.w339csmV062318@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Tue Apr 3 09:38:53 2018 New Revision: 331921 URL: https://svnweb.freebsd.org/changeset/base/331921 Log: MFC r331557: Allow to specify for vm_fault_quick_hold_pages() that nofault mode should be honored. Modified: stable/11/sys/vm/vm.h stable/11/sys/vm/vm_fault.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm.h ============================================================================== --- stable/11/sys/vm/vm.h Tue Apr 3 09:34:16 2018 (r331920) +++ stable/11/sys/vm/vm.h Tue Apr 3 09:38:53 2018 (r331921) @@ -78,7 +78,9 @@ typedef u_char vm_prot_t; /* protection codes */ #define VM_PROT_WRITE ((vm_prot_t) 0x02) #define VM_PROT_EXECUTE ((vm_prot_t) 0x04) #define VM_PROT_COPY ((vm_prot_t) 0x08) /* copy-on-read */ -#define VM_PROT_FAULT_LOOKUP ((vm_prot_t) 0x010) +#define VM_PROT_PRIV_FLAG ((vm_prot_t) 0x10) +#define VM_PROT_FAULT_LOOKUP VM_PROT_PRIV_FLAG +#define VM_PROT_QUICK_NOFAULT VM_PROT_PRIV_FLAG /* same to save bits */ #define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) #define VM_PROT_RW (VM_PROT_READ|VM_PROT_WRITE) Modified: stable/11/sys/vm/vm_fault.c ============================================================================== --- stable/11/sys/vm/vm_fault.c Tue Apr 3 09:34:16 2018 (r331920) +++ stable/11/sys/vm/vm_fault.c Tue Apr 3 09:38:53 2018 (r331921) @@ -1523,7 +1523,18 @@ vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t ad * page was mapped at the specified virtual address or that * mapping had insufficient permissions. Attempt to fault in * and hold these pages. + * + * If vm_fault_disable_pagefaults() was called, + * i.e., TDP_NOFAULTING is set, we must not sleep nor + * acquire MD VM locks, which means we must not call + * vm_fault_hold(). Some (out of tree) callers mark + * too wide a code area with vm_fault_disable_pagefaults() + * already, use the VM_PROT_QUICK_NOFAULT flag to request + * the proper behaviour explicitly. */ + if ((prot & VM_PROT_QUICK_NOFAULT) != 0 && + (curthread->td_pflags & TDP_NOFAULTING) != 0) + goto error; for (mp = ma, va = addr; va < end; mp++, va += PAGE_SIZE) if (*mp == NULL && vm_fault_hold(map, va, prot, VM_FAULT_NORMAL, mp) != KERN_SUCCESS)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804030938.w339csmV062318>