From owner-freebsd-hackers@FreeBSD.ORG Sat Dec 3 09:06:17 2011 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 0C0E5106564A for ; Sat, 3 Dec 2011 09:06:17 +0000 (UTC) (envelope-from filippo.sironi@gmail.com) Received: from mail-ee0-f54.google.com (mail-ee0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 8CCBA8FC08 for ; Sat, 3 Dec 2011 09:06:16 +0000 (UTC) Received: by eekc13 with SMTP id c13so2847777eek.13 for ; Sat, 03 Dec 2011 01:06:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version:x-mailer; bh=LndU+Wd85oQh5x0UhoOWwAPSPBCBn/l0UiqreQQFtag=; b=c2UDduKCbWK/glj80Y8hKsr2oRQJ0T4EWjOEdgCvHtty8y8bIz/CUuFVazMPuWfM2f tVTDpJvkNpYOlplojqYxyMK02Yz9QHuksjoAp3jmHXIgVTI5DrwaBQQ80YBEjEQBYsBB Bmpd9tO0gnFiwB6t+oKV4N7jQ1gOZnNUgzw1g= Received: by 10.14.9.84 with SMTP id 60mr122846ees.60.1322901837884; Sat, 03 Dec 2011 00:43:57 -0800 (PST) Received: from filippo.sironi.dynamic.micro.elet.polimi.it (micro.elet.polimi.it. [131.175.127.118]) by mx.google.com with ESMTPS id z54sm35429315eeh.5.2011.12.03.00.43.56 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 03 Dec 2011 00:43:56 -0800 (PST) From: Filippo Sironi Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Sat, 3 Dec 2011 09:42:44 +0100 Message-Id: To: freebsd-hackers@freebsd.org Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) Cc: Sironi Filippo Subject: mmap implementation for cdev 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: Sat, 03 Dec 2011 09:06:17 -0000 Dear all, I've a strange problem I cannot understand... I implemented a piece of code within the FreeBSD 7.2 kernel that = basically allocate a per-thread memory page to store a certain amount of = information that must be read and written without crossing user to = kernel and kernel to user boundaries. To read and write the memory page I decided to allocate it in kernel = space and then mmap'ing it to user space using a "virtual cdev" as an = entry point for user space threads. The implementation of the mmap I = came up with is really trivial, I basically do: *paddr =3D vtophys(curthread->private_info); Now for the problem. I enter the mmap and private_info is the correct kernel space virtual = address, each thread as its own address and the physical address - = returned by vtophys - is different too. The problem is that when I come = back to user space all the threads write in memory page mapped by the = first thread that called the mmap leaving their memory pages untouched. This problem bugs me but I cannot find a solution. I don't really = understand the behavior. Any ideas? Thanks a lot, Filippo