Received: from eggs.gnu.org ([208.118.235.92]:33343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ug5Pc-0007Tq-KF for qemu-devel@nongnu.org; Fri, 24 May 2013 23:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ug5PU-00057d-7k for qemu-devel@nongnu.org; Fri, 24 May 2013 23:44:56 -0400 Received: from ozlabs.org ([2402:b800:7003:1:1::1]:45369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ug5PT-00057S-SC for qemu-devel@nongnu.org; Fri, 24 May 2013 23:44:48 -0400 Date: Sat, 25 May 2013 13:44:41 +1000 From: David Gibson Message-ID: <20130525034441.GB6112@boomeroo.fritz.box> References: <1369133851-1894-1-git-send-email-pbonzini@redhat.com> <1369133851-1894-16-git-send-email-pbonzini@redhat.com> <519F1E7E.7050700@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EuxKj2iCbKjpUGkD" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 15/30] memory: add address_space_valid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paolo Bonzini , qemu-devel@nongnu.org, jan.kiszka@gmail.com --EuxKj2iCbKjpUGkD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 24, 2013 at 11:52:17AM +0100, Peter Maydell wrote: > On 24 May 2013 09:02, Paolo Bonzini wrote: > > Il 23/05/2013 20:04, Peter Maydell ha scritto: > >> Shouldn't we be calling the MemoryRegionOps > >> accepts() callback here? What about access alignment constraints > >> and access size restrictions? > > > > Yes, we should. > > > >> What if the validity of the range > >> changes between the time you asked and when you actually do the > >> access? > > > > If that's a concern, you shouldn't use this API, you should just do the > > access and rely on the return value of address_space_rw & friends. >=20 > So when *is* it a good idea to use this API? In real > hardware you don't usually get a "tell me whether this > access would succeed if I did it" bus operation -- you > just do the operation and the memory transaction either > succeeds or it doesn't. Are we modelling something that > really exists in hardware on spapr here? So, as a general rule, you should just attempt the access and handle failures - this is a bad interface. The reason I added it, however, is that the PAPR specification mandates that the virtual LAN pre-check various buffers when they're registered, and return specific errors if they're not mapped to valid memory. Since we have nothing to read or write at that point, adding this interface was the only way I could see to implement that requirement. Or... a bit more charitably: You should always handle failures at the point of read or write, but using this interface can give you an earlier, and therefore potentially easier to analyze, error in the more common failure cases, even if there are more complex cases where the pre-check succeeds but the read/write still fails later. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --EuxKj2iCbKjpUGkD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlGgM6kACgkQaILKxv3ab8Y7EACcDiqcMH2bqI02S98DVwefCbp6 wyEAni5MzgYShKaftFGGOQb9Gnre46hG =9w7e -----END PGP SIGNATURE----- --EuxKj2iCbKjpUGkD--