[ros-kernel] PCI device memory mapping into usermode - Page at
address 0xXxx not usable
blight at blight.eu.org
Wed Aug 18 15:53:48 CEST 2004
On Wednesday 18 August 2004 07:36, James Tabor wrote:
> Royce Mitchell III wrote:
> > This question seems to have gone unanswered. Does anybody have any ideas
> > to share with Gregor?
> > Gregor Anich wrote:
> >> Hi!
> >> From time to time I am working to get the NVIDIA OpenGL driver running
> >> a bit... It is trying to map it's framebuffer into user-mode using
> >> VideoPortMapMemory() (reactos/drivers/video/videoprt/resource.c) which
> >> does not handle usermode at the moment, but I am trying to fix it.
> >> People told me to map a view of \Device\PhysicalMemory into usermode.
> >> If I do this (given the physical address from
> >> HalTranslateBusAddress()) all the calls succeed and I return a
> >> user-mode pointer. On the first access to this area a not-present
> >> fault happens and the mm is trying to create the mapping now. It fails
> >> in ntoskrnl/mm/i386/page.c, line 1212 (MmCreateVirtualMapping()) -
> >> Page at address 0xf0043000 not usable - bugcheck. This happens because
> >> the physical address is only checked against physical ram by
> >> MmIsUsablePage() I guess.
> >> In windows 2k on my machine when I look at the memory ranges of my GF2
> >> GTS there is one which covers 0xf0000000-0xf7ffffff so I think
> >> 0xf0043000 should be usable and MmIsUsablePage() is wrong.
> >> When looking at MmIsUsablePage() (ntoskrnl/mm/freelist.c, line 746) I
> >> wonder why it doesn't check if the calculated Start is >=
> >> MmPageArraySize - isnt that a bug for any physical address checked >=
> >> MmPageArraySize * PAGE_SIZE?
> >> When I uncomment the call to MmIsUsablePage() and the following
> >> bugcheck the NVIDIA driver does neither crash nor display any kind of
> >> output.
> >> Thanks,
> >> blight
> I'm having the same problem with map view. I can map a region to view and
> try to access it through read virtual, I get a exception fault and
> sometimes a page fault. We need to map I/O memory as Kernel mode user can
> read only or map it to user mode r/w once the PCI device is id with memory
> We need to implement memory boundary checking with the virtual kernel
I hope i understood you right, James...
I do not see any reason why user mode should not be able to access PCI device
memory as all that's needed is to make the processor translate some virtual
addresses into physical ones within the PCI memory. After translating to PCI
memory it does not care if it's user or kernel-mode - this is checked when
translating the virtual into the physical address and it will only fault if
the access rights of the mapping are higher than the current processor mode.
The problem is that at some point the physical address is checked for
validity, and this check fails because it does not check if it's inside some
PCI device's memory, it only checks if it's inside the main RAM. This check
is done when you map a view of a section which is how I try to map video
memory into user mode (the VideoPortMapMemory() function) (mapping a view of
\Device\PhysicalMemory) - all other places mapping PCI memory use different
functions which do not fail I think.
More information about the Ros-kernel