From owner-freebsd-current@FreeBSD.ORG Tue Sep 16 01:05:34 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 0CEE71065670 for ; Tue, 16 Sep 2008 01:05:34 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from gizmo.2hip.net (gizmo.2hip.net [64.74.207.195]) by mx1.freebsd.org (Postfix) with ESMTP id C685E8FC13 for ; Tue, 16 Sep 2008 01:05:33 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from [192.168.2.189] (c-71-56-39-94.hsd1.ga.comcast.net [71.56.39.94]) (authenticated bits=0) by gizmo.2hip.net (8.14.3/8.14.3) with ESMTP id m8G0q1Nj006532 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 15 Sep 2008 20:52:02 -0400 (EDT) (envelope-from rnoland@FreeBSD.org) From: Robert Noland To: Kostik Belousov In-Reply-To: <20080914174801.GC39652@deviant.kiev.zoral.com.ua> References: <20080914174801.GC39652@deviant.kiev.zoral.com.ua> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-2QtV01B86GwgnfjI9CNd" Organization: FreeBSD Date: Mon, 15 Sep 2008 20:51:55 -0400 Message-Id: <1221526316.1848.1.camel@wombat.2hip.net> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 FreeBSD GNOME Team Port X-Spam-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RDNS_DYNAMIC autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on gizmo.2hip.net Cc: current@freebsd.org, "Yair K." , vehemens Subject: Re: 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: Tue, 16 Sep 2008 01:05:34 -0000 --=-2QtV01B86GwgnfjI9CNd Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sun, 2008-09-14 at 20:48 +0300, Kostik Belousov wrote: > 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()). >=20 > 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. >=20 > 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. The needs of drm in this case are very minor, but after talking with rwatson the other night, I was going to work around this issue. But it would be great if this works, so I'll try it as soon as I get caught up on mail... robert. > Thanks ! >=20 > 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 && --=-2QtV01B86GwgnfjI9CNd Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEABECAAYFAkjPAysACgkQM4TrQ4qfROOumACePYop9EbPnY7aUh5NeHlHy5sO 6nQAn3I40H0hAqLWJJDKXzcvmHhm4XNk =LOuX -----END PGP SIGNATURE----- --=-2QtV01B86GwgnfjI9CNd--