Date: Sun, 19 Feb 2017 15:59:24 -0800 From: Chuck Tuffli <ctuffli@gmail.com> To: freebsd-hackers@freebsd.org Subject: how to map kernel memory to user space Message-ID: <CAKAYmML%2B%2BPHotoQ-uupQUJUevKFPH6SZ-KEUwC_idL3TZp7p7A@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
I'm trying to work around a problem by mapping the data from a kernel allocated buffer into a user space application. There was a post some time back with a possible way to do this [1], but while this creates a valid buffer in the user space application, the contents is all zeros instead of containing the expected data. Is this approach not possible? Does anything obviously stick out below? TIA. --chuck rc = vm_map_lookup(&kernel_map, kaddr, VM_PROT_ALL, &entry, &obj, &pindex, &prot, &is_wired); vm_map_lookup_done(kernel_map, entry); if (rc) printf("%s: vm_map_lookup() = %d\n", __func__, rc); PROC_LOCK(p); uaddr = round_page((vm_offset_t)vms->vm_daddr + lim_max(td, RLIMIT_DATA)); PROC_UNLOCK(p); objoff = kaddr - (entry->start + entry->offset); vm_object_reference(obj); rc = vm_map_find(map, obj, objoff, &uaddr, sizeof(struct nvme_controller_data), 0, VMFS_OPTIMAL_SPACE, VM_PROT_RW, VM_PROT_RW, MAP_INHERIT_SHARE); [1] http://markmail.org/message/ph5yuonevqjhhbig
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAKAYmML%2B%2BPHotoQ-uupQUJUevKFPH6SZ-KEUwC_idL3TZp7p7A>