Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Feb 2003 02:56:44 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        David Schultz <das@FreeBSD.ORG>
Cc:        Byunghyun Oh <octphial@postech.ac.kr>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Replacement for get_user_pages() of Linux
Message-ID:  <3E59FA6C.CF8CB852@mindspring.com>
References:  <20030223163746.A19421@shell.postech.ac.kr> <20030224100346.GA6374@HAL9000.homeunix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
David Schultz wrote:
> Thus spake Byunghyun Oh <octphial@postech.ac.kr>:
> > I'm porting Plex86 x86 VM, which uses get_user_pages() function at
> > Linux-version kernel module to find and pin physical pages of memory
> > in user space (according to its documentation). I tried many
> > candidates as its replacement (PHYS_TO_VM_PAGE() macro in vm/vm_page.h
> > seems most useful now), but they haven't worked at all.
> >
> > Any experience about porting VM-related things in Linux will be
> > appreciated. :)
> 
> Glancing at the Linux source, it looks like you want vm_map_wire().
> BTW, in the future, it helps if you can describe what you're
> looking for, since we're not all Linux experts.


I'm pretty sure this isn't what he really wants, it's just what
he thinks he wants, and he's wrong about it, but he hasn't told
us what problem he's trying to solve, so that we can correct his
misconception.

In general, FreeBSD drivers DMA to pages for which there is an
established kernel mapping, period.

With specific exceptions, kernel pages are not pageable, and so
they do not need to be wired (you have to go way out of your way
to get pageable kernel memory; most people don't do it, and I'm
not even sure UMA allows you to get this type of memory any more).

No FreeBSD driver DMA's into user space address space directly,
bypassing kernel space address space; either there is a kernel
mapping AND a user mapping, or there is ONLY a kernel mapping.

The closest FreeBSD ever comes to this is to map a set of kernel
space allocated pages into a user process address space, by the
process opening a device node, and calling mmap() on it.  In a
pinch, you can force this on the process from kernel space, so
you don't have to rewrite your code (e.g. the code is running
under Linux or other emulation), but this is really frowned upon.

In this case, the memory is usually allocated directly to the
device at the time the device is attached, e.g. the video memory
in a VGA card, or the memory window onto the AGP in the agpart
device.  Then it is mapped into the user process address space
(e.g. the XFree86 server process), and DMAs into that memory are
implicitly DMAs into the user process address space.


Again, it would be really, really nice to know what problem he
is trying to solve, so that people who know FreeBSD can tell him
the FreeBSD way of solving the problem.


I suspect that he wants to use bus_dmamem_alloc(), bus_dmamap_create(),
bus_dma_tag_create(), etc., and write a standard FreeBSD device driver
for his device, so that it will work on things like Alpha, SPARC64,
IA64, PPC, and other platforms which care about memory windows onto
main memory via "bus space".

Without knowing the problem he's trying to solve though... you get
the point...

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E59FA6C.CF8CB852>