Re: kernel mmap() and friends.

2005-03-08 Thread Robert Hancock
linux-os wrote:
> If one uses x = __get_dma_pages(GFP_KERNEL, nr), finds the physical
> address with b = virt_to_bus(x), then attempts to mmap(,,b,,,) the result
> _does_not_fail_, yet the user ends up with memory ...somewhere
> that is R/W able and WRONG.
I don't think virt_to_bus is the correct function to be using for this 
translation (or pretty much anything, these days). What is this memory 
that you are attempting to do an mmap on, and where is this code going? 
Unless this is an ISA device and you need physical memory for DMA, 
__get_dma_pages is not correct either.

>
> Yet, if the code executes SetPageReserved(virt_to_page(x)), the
> mmap() works and the user gets the CORRECT page(s).
>
> I think that if mmap() needs a physical buffer to be reserved
> then that's fine. However, silently returning some different
> buffer is a BUG.
>
> Is anyone aware of this BUG? Does anybody else care?
The kernel isn't responsible for checking that the memory ranges you 
attempt to remap are what you intended - if you get this wrong, things 
can blow up, that's just the way it is.

I would suggest following some similar driver/code in the kernel as an 
example if possible..

--
Robert Hancock  Saskatoon, SK, Canada
Home Page: http://www.roberthancock.com/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


kernel mmap() and friends.

2005-03-08 Thread linux-os
Hello mem-map gurus,
If one uses x = __get_dma_pages(GFP_KERNEL, nr), finds the physical
address with b = virt_to_bus(x), then attempts to mmap(,,b,,,) the result
_does_not_fail_, yet the user ends up with memory ...somewhere
that is R/W able and WRONG.
Yet, if the code executes SetPageReserved(virt_to_page(x)), the
mmap() works and the user gets the CORRECT page(s).
I think that if mmap() needs a physical buffer to be reserved
then that's fine. However, silently returning some different
buffer is a BUG.
Is anyone aware of this BUG? Does anybody else care?
Cheers,
Dick Johnson
Penguin : Linux version 2.6.10 on an i686 machine (5537.79 BogoMips).
 Notice : All mail here is now cached for review by Dictator Bush.
 98.36% of all statistics are fiction.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


kernel mmap() and friends.

2005-03-08 Thread linux-os
Hello mem-map gurus,
If one uses x = __get_dma_pages(GFP_KERNEL, nr), finds the physical
address with b = virt_to_bus(x), then attempts to mmap(,,b,,,) the result
_does_not_fail_, yet the user ends up with memory ...somewhere
that is R/W able and WRONG.
Yet, if the code executes SetPageReserved(virt_to_page(x)), the
mmap() works and the user gets the CORRECT page(s).
I think that if mmap() needs a physical buffer to be reserved
then that's fine. However, silently returning some different
buffer is a BUG.
Is anyone aware of this BUG? Does anybody else care?
Cheers,
Dick Johnson
Penguin : Linux version 2.6.10 on an i686 machine (5537.79 BogoMips).
 Notice : All mail here is now cached for review by Dictator Bush.
 98.36% of all statistics are fiction.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel mmap() and friends.

2005-03-08 Thread Robert Hancock
linux-os wrote:
 If one uses x = __get_dma_pages(GFP_KERNEL, nr), finds the physical
 address with b = virt_to_bus(x), then attempts to mmap(,,b,,,) the result
 _does_not_fail_, yet the user ends up with memory ...somewhere
 that is R/W able and WRONG.
I don't think virt_to_bus is the correct function to be using for this 
translation (or pretty much anything, these days). What is this memory 
that you are attempting to do an mmap on, and where is this code going? 
Unless this is an ISA device and you need physical memory for DMA, 
__get_dma_pages is not correct either.


 Yet, if the code executes SetPageReserved(virt_to_page(x)), the
 mmap() works and the user gets the CORRECT page(s).

 I think that if mmap() needs a physical buffer to be reserved
 then that's fine. However, silently returning some different
 buffer is a BUG.

 Is anyone aware of this BUG? Does anybody else care?
The kernel isn't responsible for checking that the memory ranges you 
attempt to remap are what you intended - if you get this wrong, things 
can blow up, that's just the way it is.

I would suggest following some similar driver/code in the kernel as an 
example if possible..

--
Robert Hancock  Saskatoon, SK, Canada
Home Page: http://www.roberthancock.com/

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/