Date: Tue, 25 Feb 2003 01:10:31 +0900 From: Byunghyun Oh <octphial@shell.postech.ac.kr> To: freebsd-hackers@freebsd.org Subject: Re: Replacement for get_user_pages() of Linux Message-ID: <20030225011031.A18917@shell.postech.ac.kr>
next in thread | raw e-mail | index | archive | help
I am so sorry that I couldn't (and maybe can't) explain what I want, because I don't know it exactly due to my poor knowledge of VM system and Plex86 itself (http://plex86.sourceforge.net/). But I'll try to explain here. Plex86 is a kind of VMWare or so, but it limits its focus to userland operation (many things had been said, but I only remember 'ring 3' and blah). Anyway, Plex86 originally allocated some memory places for some logging and VM guest's CPU info, and this allocation occured in kernel module. However, it changed to allocate in host application part, and kernel module just find user pages from their addresses (I'm not sure whether they are virtual or they are physical) and pin them (someone here already explained what pinning is). Of course, here is an un-pinning function also. I'm neither Linux expert nor FreeBSD expert, so I sought Linux-2.4.20 source, FreeBSD VM things, vmmon (VMWare kernel module part) for FreeBSD, and Google. However, I couldn't find no clear document and usage. Fortunately, many arguments from my question helped me so much, and I think its solution is so close. For now, thanks for answering my silly question. :) Byunghyun Oh octphial _at_ postech.ac.kr ps. Is DMA means just 'Direct Memory Access', and shall I understand it literally? On Mon, Feb 24, 2003 at 02:56:44AM -0800, Terry Lambert wrote: > 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?20030225011031.A18917>