Received: from eggs.gnu.org ([2001:4830:134:3::10]:34031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brfFS-0003QG-Ps for qemu-devel@nongnu.org; Wed, 05 Oct 2016 02:00:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brfFM-0003qh-Q6 for qemu-devel@nongnu.org; Wed, 05 Oct 2016 02:00:09 -0400 Received: from 18.mo1.mail-out.ovh.net ([46.105.35.72]:41631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brfFM-0003pe-Jp for qemu-devel@nongnu.org; Wed, 05 Oct 2016 02:00:04 -0400 Received: from player726.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id 4986EFBB6 for ; Wed, 5 Oct 2016 08:00:02 +0200 (CEST) References: <1475583448-21013-1-git-send-email-clg@kaod.org> <20161004234352.GE18648@umbus.fritz.box> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: <4e0630c3-de9f-5d96-2bca-0fa1c52024f6@kaod.org> Date: Wed, 5 Oct 2016 07:59:57 +0200 MIME-Version: 1.0 In-Reply-To: <20161004234352.GE18648@umbus.fritz.box> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qtest: add read/write accessors with a specific endianness List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , Peter Maydell Cc: QEMU Developers , Greg Kurz , Laurent Vivier On 10/05/2016 01:43 AM, David Gibson wrote: > On Tue, Oct 04, 2016 at 01:36:09PM +0100, Peter Maydell wrote: >> On 4 October 2016 at 13:17, C=E9dric Le Goater wrote: >>> Some test scenarios require to access memory regions using a specific >>> endianness, such as a device region, but the current qtest memory >>> accessors are done in native endian, which means that the values are >>> byteswapped in qtest if the endianness of the guest and the host are >>> different. >>> >>> To maintain the endianness of a value, we need a new set of memory >>> accessor. This can be done in two ways: >>> >>> - first, convert the value to the required endianness in libqtest and >>> then use the memread/write routines so that qtest accesses the gues= t >>> memory without doing any supplementary byteswapping >>> >>> - an alternative method would be to handle the byte swapping on the >>> qtest side. For that, we would need to extend the read/write >>> protocol with an ending word : "native|le|be" and modify the tswap >>> calls accordingly under the qtest_process_command() routine. >>> >>> The result is the same and the first method is simpler. >> >> The difficulty with this patch is that it's hard to tell whether >> it's really required, or if this is just adding an extra layer >> of byteswapping that should really be done in some other location >=20 > Actually, it's neither. It's not essential for anything, but it > *removes* an extra layer of byteswapping that really never should have > been done in the first place. So may be removing the tswap in qtest_process_command() is a better=20 solution ? I don't know how much of an earthquake this will be in the=20 tests results. Tests will have to be explicit on which endianness they expect else=20 they will be using the qtest default endianness which is the host.=20 >> in the stack. What's the actual test case here? >=20 > The current readw, readl, etc. all work in "guest endianness". But > guest endianness is not well defined - there are a number of targets > which can support either. And it's doubly meaningless since it's a > property of the guest cpu, which we're essentially replacing with the > qtest stub anyway. >=20 > Furthermore "guest endianness" isn't useful. With a tiny handful of > exceptions, all peripherals have their own endianness which is known > independent of the target. It makes more sense for test cases to > explicitly do their accesses in the correct endianness for the device, > without having to compensate for the fact that it'll be swapped into > the essentially arbitrary "guest endianness" along the way. >=20 > Basically, the existing byteswaps, instead of removing the need for > them in the testcase code, instead mean that target-conditional > byteswaps will be *required* in nearly every testcase. It's a recipe > for endianness-unsafe testcases. and plenty of baroque work arounds. Thanks, C.=20