Subject: Re: port-mips/15965: NEW_PIPE broken on port-mips
To: Takao Shinohara <shin@sm.sony.co.jp>
From: Chuck Silvers <chuq@chuq.com>
List: netbsd-bugs
Date: 03/23/2002 20:34:39
hi,

the problem with using pmap_enter() instead of pmap_kenter_pa()
for pages that are loaned to the kernel is that we need to make
sure that the loan mappings for these pages are not removed by
pmap_page_protect(VM_PROT_NONE).  if the page loaned to the kernel
is owned by a vnode object and the file is truncated such that the
page is now past the end of the file, we need to be able to leave
the loan mappings alone while removing all other mappings.
the way to do this is to use pmap_kenter_pa() for loan mappings
and pmap_enter() for non-loan mappings, then pmap_page_protect()
removes exactly the mappings we want.

-Chuck


On Sun, Mar 24, 2002 at 12:01:31PM +0900, Takao Shinohara wrote:
> Chuck Silvers <chuq@chuq.com> writes:
> > On Tue, Mar 19, 2002 at 09:47:00PM +0100, Manuel Bouyer wrote:
> > > Maybe a missing cache flush ?
> > 
> > indeed it was.  it's fixed now, get the latest mips/pmap.c.
> 
> I think this fix (pmap.c rev. 1.142) is not correct. Virtual alias
> should be handled via pmap_enter()/pmap_remove().
> 
> How about this patch? (and backout 1.142 of pmap.c?)
> 
> --- Takao Shinohara
> 
> Index: sys_pipe.c
> ===================================================================
> RCS file: /cvsroot/syssrc/sys/kern/sys_pipe.c,v
> retrieving revision 1.25
> diff -u -r1.25 sys_pipe.c
> --- sys_pipe.c	2002/03/17 19:41:07	1.25
> +++ sys_pipe.c	2002/03/24 02:53:51
> @@ -1149,7 +1149,8 @@
>  	/* Enter the loaned pages to kva */
>  	kva = wpipe->pipe_map.kva;
>  	for (j = 0; j < npages; j++, kva += PAGE_SIZE) {
> -		pmap_kenter_pa(kva, VM_PAGE_TO_PHYS(pgs[j]), VM_PROT_READ);
> +		pmap_enter(pmap_kernel(), kva, VM_PAGE_TO_PHYS(pgs[j]),
> +		    VM_PROT_READ, PMAP_WIRED);
>  	}
>  	pmap_update(pmap_kernel());
>  
> @@ -1173,7 +1174,8 @@
>  cleanup:
>  	pipelock(wpipe, 0);
>  	if (pgs != NULL) {
> -		pmap_kremove(wpipe->pipe_map.kva, blen);
> +		pmap_remove(pmap_kernel(), wpipe->pipe_map.kva,
> +		    wpipe->pipe_map.kva + blen);
>  		uvm_unloan(pgs, npages, UVM_LOAN_TOPAGE);
>  	}
>  	if (error || amountpipekva > maxpipekva)