Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Aug 1996 16:43:58 +0200 (MET DST)
From:      Tor Egge <tegge@idt.ntnu.no>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/1514: mlock fails on readonly regions
Message-ID:  <199608191443.QAA01466@ikke.idt.unit.no>
Resent-Message-ID: <199608191450.HAA21341@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         1514
>Category:       kern
>Synopsis:       mlock fails on readonly regions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 19 07:50:02 PDT 1996
>Last-Modified:
>Originator:     Tor Egge
>Organization:
Norwegian University of Science and Technology, Trondheim, Norway
>Release:        FreeBSD 2.2-CURRENT i386
>Environment:
FreeBSD ikke.idt.unit.no 2.2-CURRENT FreeBSD 2.2-CURRENT #5: Mon Aug 19 16:14:50 MET DST 1996     root@ikke.idt.unit.no:/usr/src/sys/compile/TEGGE  i386

>Description:

	When a memory region is readonly and mlock is called, vm_fault_wire
	tries to fault in the region with (VM_PROT_READ|VM_PROT_WRITE) as 
	flags to vm_fault. This fails, since the memory region is not
	writable.

>How-To-Repeat:

	mmap a region readonly, and try mlocking it.

Here is the pach I use to enable mlock for normal users (Added one line 
from /usr/src/sys/arch/pmax/include/pmap.h in NetBSD-current).
------
*** /usr/snapshot-src/sys/i386/include/pmap.h   Tue Jul 30 05:08:57 1996
--- ./pmap.h    Mon Aug 19 14:45:28 1996
***************
*** 212,217 ****
--- 212,218 ----
  struct pcb;
  
  void  pmap_bootstrap __P(( vm_offset_t, vm_offset_t));
+ #define pmap_wired_count(pmap)        ((pmap)->pm_stats.wired_count)
  pmap_t        pmap_kernel __P((void));
  void  *pmap_mapdev __P((vm_offset_t, vm_size_t));
  unsigned * __pure pmap_pte __P((pmap_t, vm_offset_t)) __pure2;
----
	
>Fix:
Here is a patch that solved the problem for me.
------ 
diff -c /usr/snapshot-src/sys/vm/vm_fault.c ./vm_fault.c
*** /usr/snapshot-src/sys/vm/vm_fault.c	Tue Jul 30 05:08:07 1996
--- ./vm_fault.c	Mon Aug 19 16:12:23 1996
***************
*** 840,846 ****
  	 */
  
  	for (va = start; va < end; va += PAGE_SIZE) {
! 		rv = vm_fault(map, va, VM_PROT_READ|VM_PROT_WRITE, TRUE);
  		if (rv) {
  			if (va != start)
  				vm_fault_unwire(map, start, va);
--- 840,846 ----
  	 */
  
  	for (va = start; va < end; va += PAGE_SIZE) {
! 		rv = vm_fault(map, va, VM_PROT_READ, TRUE);
  		if (rv) {
  			if (va != start)
  				vm_fault_unwire(map, start, va);
------------
>Audit-Trail:
>Unformatted:



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