Re: user malloc from kernel
From: Terry Lambert (tlambert2_at_mindspring.com)
Date: 09/30/03
- Previous message: Terry Lambert: "Re: has anyone installed 5.1 from a SCSI CD?"
- In reply to: earthman: "user malloc from kernel"
- Next in thread: David Gilbert: "Re: USB keyboard thoughts."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 30 Sep 2003 01:13:35 -0700 To: earthman <earthman@inbox.ru>
earthman wrote:
> how to allocate some memory chunk
> in user space memory from kernel code?
> how to do it correctly?
If your intent is to allocate a chunk of memory which is shared
between your kernel and a single process in user space, the
normal way of doing this is to allocate the memory to a device
driver in the kernel, and then support mmap() on it to establish
a user space mapping for the kernel allocated memory. In general,
you must do this so that the memory is wired down in the kernel
address space, so that if you attempt to access it in the kernel
while the process you are interested in sharing with is swapped
out, you do not segfault and trap-12 ("page not present") panic
your kernel.
If your intent is to share memory with every process in user
space (e.g. similar to what some OS's use to implement zero
system call gettimeofday() functions, etc.), then you want to
allocate the memory in kernel space (still), make sure it's on
a page boundary, and set the PG_G and PG_U bits on the page(s)
in question.
-- Terry
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
- Previous message: Terry Lambert: "Re: has anyone installed 5.1 from a SCSI CD?"
- In reply to: earthman: "user malloc from kernel"
- Next in thread: David Gilbert: "Re: USB keyboard thoughts."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- Re: Sharing memory between kernelspace and userspace
... deallocate, on a totally dynamic basis, userspace ... Let userspace allocate
shared memory visible to multiple ... and pass that into the kernel for it to write
to. ... (Linux-Kernel) - Re: size_t or int for malloc-type functions?
... Some go as high as 3GB with special boot ... RedHat has a special Linux kernel
that gives just under 4GB of user address space; a bit of kernel space is still required to keep syscalls
working, ... It's mainly used by database folks, who should be moving to AMD64 now anyways (with
its 2^51 bytes of user space, currently). ... of like the old extended/expanded memory
hacks in the DOS days. ... (comp.lang.c) - Re: [swsusp] separate snapshot functionality to separate file
... >> Split does not prevent you from doing the cleanups. ... Kernel needs
to use get_user, ... > memory directly from the used space. ... > not be visible
to the user space at all. ... (Linux-Kernel) - Re: Virtual memory - user space kernel space
... It depends upon the total size of kernel code and static data. ... 1G/3G division
in virutal memory is nothing but a set of pointers to ... User space pointers has
to go via MMU to get the location in physical ... you bumble virtual and physical memory.
... (comp.os.linux.development.system) - Re: kernel memory
... Kernel virtual address space is used for a number of things. ... Pat of this
are the memory pools, from which you can allocate memory for your drivers. ... You can
allocate physical memory using a DDI like MmAllocatePagesForMdl and then map those into the system
address space. ... That's probably the easiest way to explain why you cannot allocate 1GB of non-paged
pool for yourself:) ... (microsoft.public.development.device.drivers)