From owner-freebsd-current@FreeBSD.ORG Sun Sep 14 17:48:09 2008 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CEC81065677; Sun, 14 Sep 2008 17:48:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id E76E88FC23; Sun, 14 Sep 2008 17:48:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtp (Exim 4.63 (FreeBSD)) (envelope-from ) id 1Kevhd-000KGb-Hb; Sun, 14 Sep 2008 20:48:05 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m8EHm2Aq085543 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 14 Sep 2008 20:48:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m8EHm2iE053634; Sun, 14 Sep 2008 20:48:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id m8EHm1mY053632; Sun, 14 Sep 2008 20:48:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 14 Sep 2008 20:48:01 +0300 From: Kostik Belousov To: current@freebsd.org Message-ID: <20080914174801.GC39652@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="hgy5D1otryeNPdmY" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1Kevhd-000KGb-Hb cfa83b32e99b5ed9fd09b5d658c75ba4 X-Terabit: YES Cc: "Yair K." , rnoland@freebsd.org, vehemens Subject: cdevpriv and mmap(2) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Sep 2008 17:48:09 -0000 --hgy5D1otryeNPdmY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable When implementing cdevpriv, I completeley missed the support for d_mmap() driver method. This method is called by the kernel (at least) twice: one time to validate the mmaped region and protection mode (see vm/device_pager.c:dev_pager_alloc()), and second time to obtain the physical address when serving page fault (see dev_pager_getpages()). Support for cdevpriv for the first call(s) is trivial, and is implemented by the patch below. Second calls are much harder and essentially require attaching cdevpriv bookkeeping data to the struct vm_map_entry. In fact, I am not sure whether this support for the second time calls is needed at all in real usage. I Cc:ed people that pointed me to the issue, please evaluate the patch against your needs. I think I will commit it shortly after your feedback. On the other hand, I would think about implementing full support for d_mmap only if actually needed. Thanks ! diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 7e6b04f..c3f08b0 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -391,8 +391,10 @@ map: goto done; } =20 + td->td_fpop =3D fp; error =3D vm_mmap(&vms->vm_map, &addr, size, prot, maxprot, flags, handle_type, handle, pos); + td->td_fpop =3D NULL; #ifdef HWPMC_HOOKS /* inform hwpmc(4) if an executable is being mapped */ if (error =3D=3D 0 && handle_type =3D=3D OBJT_VNODE && --hgy5D1otryeNPdmY Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkjNTlEACgkQC3+MBN1Mb4ht9ACg3aJ2J8zEFMECoo7bQeamCL1h /1EAoJf8PxWzTDHsUH8Mzv5zpOGTtBpZ =CjiN -----END PGP SIGNATURE----- --hgy5D1otryeNPdmY--