[ros-kernel] PCI device memory mapping into usermode - Page
ataddress 0xXxx not usable
Hartmut Birr
hartmut.birr at gmx.de
Thu Aug 19 01:27:04 CEST 2004
Hi,
I think we should have two sets of mapping function. The first one which
maps normal ram pages to section views (except \Device\PhysicalMemory), pool
memory, stacks and so on. This functions must always check for map, lock and
reference counters of the pages. Currently this functions are
MmCreateVirtualMapping and MmDeleteVirtualMapping. The second one is used
for mapping of device memory from pci or agp buses and for mapping from
\Device\PhysicalMemory. The hard way for the implementation is to make a
difference between the two mapping types for mdl functions like
MmProbeAndLockPages/MmUnlockPages.
- Hartmut
> -----Original Message-----
> From: ros-kernel-bounces at reactos.com
> [mailto:ros-kernel-bounces at reactos.com] On Behalf Of Anich Gregor
> Sent: Wednesday, August 18, 2004 2:54 PM
> To: ReactOS Kernel List
> Subject: Re: [ros-kernel] PCI device memory mapping into
> usermode - Page ataddress 0xXxx not usable
>
>
> On Wednesday 18 August 2004 07:36, James Tabor wrote:
> > Hi,
> >
> > 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
> > I/O.
> >
> > We need to implement memory boundary checking with the
> virtual kernel
> > functions.
> > James
> >
>
> 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.
>
> --blight
> _______________________________________________
> Ros-kernel mailing list
> Ros-kernel at reactos.com
> http://reactos.com/mailman/listinfo/ros-kernel
>
More information about the Ros-kernel
mailing list