Subject: pmap_enter(9) flags in vmapbuf()
To: None <chuq@chuq.com>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: port-mips
Date: 03/26/2005 19:39:48
In article <20050320191346.GA27918@spathi.chuq.com>
chuq@chuq.com wrote:
> > if (pmap_extract(upmap, uva, &pa) == FALSE)
> > panic("vmapbuf: null page frame");
> > pmap_enter(vm_map_pmap(phys_map), kva, pa,
> > - VM_PROT_READ | VM_PROT_WRITE, PMAP_WIRED);
> > + VM_PROT_READ | VM_PROT_WRITE,
> > + VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED);
:
> we shouldn't pass VM_PROT_WRITE in the pmap_enter() flags (the last arg)
> if the user memory isn't going to be modified. the buffer's read/write flags
> are from the perspective of the device, so the user memory is only modified
> if B_READ is set.
How about this one? (taken from powerpc/vm_machdep.c)
Precisely, is it worth to pass VM_PROT_READ (and VM_PROT_WRITE on B_READ)
to pmap_enter(9) flags in vmapbuf() on mips?
And should we pass VM_PROT_WRITE in pmap_enter() prot arg only
on B_READ too?
---
Izumi Tsutsui
Index: mips/vm_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/vm_machdep.c,v
retrieving revision 1.105
diff -u -r1.105 vm_machdep.c
--- mips/vm_machdep.c 1 Jan 2005 03:25:46 -0000 1.105
+++ mips/vm_machdep.c 26 Mar 2005 02:40:27 -0000
@@ -318,6 +306,7 @@
vaddr_t kva; /* Kernel VA (new to) */
paddr_t pa; /* physical address */
vsize_t off;
+ int prot;
if ((bp->b_flags & B_PHYS) == 0)
panic("vmapbuf");
@@ -329,11 +318,12 @@
bp->b_data = (caddr_t)(kva + off);
upmap = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map);
+ prot = VM_PROT_READ | ((bp->b_flags & B_READ) ? VM_PROT_WRITE : 0);
do {
if (pmap_extract(upmap, uva, &pa) == FALSE)
panic("vmapbuf: null page frame");
pmap_enter(vm_map_pmap(phys_map), kva, pa,
- VM_PROT_READ | VM_PROT_WRITE, PMAP_WIRED);
+ prot, prot | PMAP_WIRED);
uva += PAGE_SIZE;
kva += PAGE_SIZE;
len -= PAGE_SIZE;