From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 22 17:54:41 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DAC771065672 for ; Wed, 22 Feb 2012 17:54:41 +0000 (UTC) (envelope-from svetlin.manavski@itrinegy.com) Received: from eu1sys200aog116.obsmtp.com (eu1sys200aog116.obsmtp.com [207.126.144.141]) by mx1.freebsd.org (Postfix) with SMTP id ED7988FC1A for ; Wed, 22 Feb 2012 17:54:40 +0000 (UTC) Received: from mail-iy0-f172.google.com ([209.85.210.172]) (using TLSv1) by eu1sys200aob116.postini.com ([207.126.147.11]) with SMTP ID DSNKT0Ur32lRh6bWa1c5rcNINGRqihD3Gy1h@postini.com; Wed, 22 Feb 2012 17:54:41 UTC Received: by mail-iy0-f172.google.com with SMTP id f6so331683iag.3 for ; Wed, 22 Feb 2012 09:54:39 -0800 (PST) Received-SPF: pass (google.com: domain of svetlin.manavski@itrinegy.com designates 10.50.140.101 as permitted sender) client-ip=10.50.140.101; Authentication-Results: mr.google.com; spf=pass (google.com: domain of svetlin.manavski@itrinegy.com designates 10.50.140.101 as permitted sender) smtp.mail=svetlin.manavski@itrinegy.com Received: from mr.google.com ([10.50.140.101]) by 10.50.140.101 with SMTP id rf5mr28097851igb.27.1329933279581 (num_hops = 1); Wed, 22 Feb 2012 09:54:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.140.101 with SMTP id rf5mr22628656igb.27.1329931457970; Wed, 22 Feb 2012 09:24:17 -0800 (PST) Received: by 10.50.156.232 with HTTP; Wed, 22 Feb 2012 09:24:17 -0800 (PST) Date: Wed, 22 Feb 2012 17:24:17 +0000 Message-ID: From: Svetlin Manavski To: freebsd-hackers@freebsd.org X-Gm-Message-State: ALoCoQl7FYcSkR6ki1Ow7Pk5KsHvyuUh6vlKLmrwWrPLPfnJx51qHKTASMTmBjj7aOvHjpVu/JnP Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: How to access kernel memory from user space X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Feb 2012 17:54:41 -0000 Hi all, I have a very similar problem as described in this thread back in 2009: http://lists.freebsd.org/pipermail/freebsd-hackers/2009-January/027367.html I have a kernel module producing networking stats which I need to frequently read from the user space. A copy of the data structure would be too expensive so I need to access the kernel data directly from the user space. Unfortunately Alexej's code crashes in the following area: vm_map_lookup(&kmem_map, addr, VM_PROT_ALL, &myentry, &myobject, &mypindex, &myprot, &mywired); /* OUT */ vm_map_lookup_done(kmem_map, myentry); I am using 64bit FreeBSD 8.2 on Intel Xeon hardware. Any idea how to make a stable implementation on my platform? Thank you, Svetlin