Subject: Re: uvm_map ?
To: None <tech-kern@netbsd.org>
From: Nalin Gupta <nalingupta2000@gmail.com>
List: tech-kern
Date: 04/13/2007 20:04:42
All,
After some looking here and there, I modified my code, but still no
success in mapping kernel wired memory to user vm space. I do not get
any error, but user process in "user mode" do not see, what I write at
allocated space.
If some one could point my mistakes, I shall be very greatful.
rgds,
- nalin
Steps at module load time and user process (open/ioctl) time are:
=========== At Module Load time ================
logPoolSize = (logPoolSize + PGOFSET) & ~PGOFSET;
/* for char dev, this seems to be api, though not in man page */
alfLogMgr.uvmObject = udv_attach( &dev, VM_PROT_WRITE|VM_PROT_READ,
0, logPoolSize);
allocFlags = UVM_KMF_NOWAIT ;
alfLogMgr.wiredMemory = uvm_km_kmemalloc1(kernel_map, alfLogMgr.uvmObject,
logPoolSize, 1, 0,
allocFlags);
/* alfLogMgr.uvmObject is not kernel object, so we need to wire forcibly */
/* wire the pages */
TAILQ_FOREACH(pg, &alfLogMgr.uvmObject->memq, listq) {
uvm_lock_pageq();
uvm_pagewire(pg);
uvm_unlock_pageq();
}
p = (void*)alfLogMgr.wiredMemory;
*p = 0x0a0b0c0d; // <<< this I wish to see from user
process in user mode
=========== [snip] =============================
Here, if I dump using uvm_object_printit and uvm_page_printit, I see:
OBJECT 0xc0b01800: locked=0, pgops=0xc03cffe8, npages=1, refs=1
PAGES <pg,offset>:
<0xc0816500,0x70ef000>
PAGE 0xc0816500:
flags=4c<TABLED,CLEAN,FAKE>, pqflags=0, wire_count=1, pa=0x465f000
uobject=0xc0b01800, uanon=0x0, offset=0x70ef000 loan_count=0
[page ownership tracking disabled]
checking object list
page found on object list
=========== At User Process accessing module (open/ioctl) ================
uao_reference(alfLogMgr.uvmObject);
attach_va = 0; // <<< this should have addr usable from user mode.
/* this should attach phy pages to user virtual addr */
error = uvm_map( &p->p_vmspace->vm_map, &attach_va, logPoolSize,
alfLogMgr.uvmObject, 0, 0,
UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW,
UVM_INH_NONE, UVM_ADV_RANDOM, 0)
) ;
=========== [snip] =============================
I dumped uvm_map_printit for userp process and could see uvm_object
as below:
MAP 0xc6fee294: [0x0->0xbfc00000]
#ent=13, sz=34385920, ref=1, version=35, flags=0x1
pmap=0xc6fef0e4(resident=111)
[...]
- 0xc702e68c: 0x1410f000->0x14110000: obj=0xc0b01800/0x0, amap=0x0/0
submap=F, cow=F, nc=F, prot(max)=3/3, inh=2, wc=0, adv=1
[...]
---------------------------------------------------------------------------------------------
So when I pass attach_va value to user process in user mode, and
try to deference it as interger pointer, I read value: 0xf000ff7f