Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Oct 2011 07:55:19 -0500
From:      Mark Tinguely <marktinguely@gmail.com>
To:        Daniel Grech <dgre090@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Kernel Space Memory Allocation
Message-ID:  <4EA954B7.7070205@gmail.com>
In-Reply-To: <CAG167sYaz3=Qvv0YYP7YvSkgm2HKkdP-XDu=HBUMv8TV1QUd5A@mail.gmail.com>
References:  <CAG167sYaz3=Qvv0YYP7YvSkgm2HKkdP-XDu=HBUMv8TV1QUd5A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 10/27/2011 3:31 AM, Daniel Grech wrote:
> Hi,
>
> I am allocating memory from a device driver in the kernel and passing it on
> to another driver. In the other driver it is neccessary for me to determine
> whether the address passed is from user space or kernel space as this driver
> can also be called from user space. I am currently using the following check
> to determine if the address is in kernel space or userspace :
>
> if ( ( (char *) VM_MIN_KERNEL_ADDRESS<= address)&&   (address<= (char *)
> VM_MAX_KERNEL_ADDRESS) )
> {
>          KERNEL SPACE
> }
> else
> {
>         USER SPACE
> }
>
> However, this does not always work. Sometimes although I allocate memory in
> the kernel using the malloc macro, this returns an address which is not in
> the above range. Is there any workaround for this problem?
>
> Thanks in advance for your help.
>
> Daniel
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
>

Be careful if using user virtual addresses in DMA POST commands, because 
the interrupt handler may not have the the same address space as the 
caller. For example: BUS_DMASYNC_POSTREAD copying a bounce buffer to a 
user VA.

--Mark Tinguely



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