Subject: Re: UVM - Kernel & User access question
To: Eric Circlaeys <eric.c@MAC.COM>
From: Stephan Uphoff <ups@stups.com>
List: tech-kern
Date: 10/25/2003 17:19:19
Eric Circlaeys wrote:
> 
> void		*nm_core_uvm_allocate(struct proc *p, int size,
> 				      struct uvm_object **object)
> {
....
>    handler = round_page((vaddr_t)p->p_vmspace->vm_taddr + MAXTSIZ + 
> MAXDSIZ);

Wrong space ... just set it to vm_map_min(kernel_map);
( Should be harmless since it is just a preference )

> .....
> Using this API in my kernel module I can now allocate and deallocate 
> pageable kernel memory.
> I use right now kcopy for all my needs.
> 
> BUT BUT BUT after deallocating such memory,
> 
> sometimes, my NetBSD 1.6.1, or other applications running raised an 
> uvm_page_fault, or other uvm_* errors and cause a kernel panic.
> 
> Did I forget something to do when deallocating memory or usage of 
> virtual / physical pages???

Looks ok - maybe you have a bug somewhere else ?

	Stephan

PS:  You might want to try
  addr = uvm_km_valloc(kernel_map,size); 
  uvm_km_free(kernel_map,addr,size);
to allocate/deallocate your memory since you are not 
doing anything tricky with it.