Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Oct 2019 07:04:01 +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-12@freebsd.org
Subject:   svn commit: r353620 - stable/12/sys/vm
Message-ID:  <201910160704.x9G741LC000919@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Oct 16 07:04:01 2019
New Revision: 353620
URL: https://svnweb.freebsd.org/changeset/base/353620

Log:
  MFC r353463:
  Restore nofaulting operations after r352807.

Modified:
  stable/12/sys/vm/vm_fault.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/vm/vm_fault.c
==============================================================================
--- stable/12/sys/vm/vm_fault.c	Wed Oct 16 07:02:02 2019	(r353619)
+++ stable/12/sys/vm/vm_fault.c	Wed Oct 16 07:04:01 2019	(r353620)
@@ -562,15 +562,11 @@ int
 vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
     int fault_flags, int *signo, int *ucode)
 {
-	struct thread *td;
 	int result;
 
 	MPASS(signo == NULL || ucode != NULL);
-	td = curthread;
-	if ((td->td_pflags & TDP_NOFAULTING) != 0)
-		return (KERN_PROTECTION_FAILURE);
 #ifdef KTRACE
-	if (map != kernel_map && KTRPOINT(td, KTR_FAULT))
+	if (map != kernel_map && KTRPOINT(curthread, KTR_FAULT))
 		ktrfault(vaddr, fault_type);
 #endif
 	result = vm_fault(map, trunc_page(vaddr), fault_type, fault_flags,
@@ -582,7 +578,7 @@ vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot
 	    result == KERN_OUT_OF_BOUNDS,
 	    ("Unexpected Mach error %d from vm_fault()", result));
 #ifdef KTRACE
-	if (map != kernel_map && KTRPOINT(td, KTR_FAULTEND))
+	if (map != kernel_map && KTRPOINT(curthread, KTR_FAULTEND))
 		ktrfaultend(result);
 #endif
 	if (result != KERN_SUCCESS && signo != NULL) {
@@ -652,6 +648,10 @@ vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fa
 	bool dead, hardfault, is_first_object_locked;
 
 	VM_CNT_INC(v_vm_faults);
+
+	if ((curthread->td_pflags & TDP_NOFAULTING) != 0)
+		return (KERN_PROTECTION_FAILURE);
+
 	fs.vp = NULL;
 	faultcount = 0;
 	nera = -1;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910160704.x9G741LC000919>