From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8BZJ-0005du-SW for qemu-devel@nongnu.org; Tue, 28 Jan 2014 11:31:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8BZ8-0002sY-KZ for qemu-devel@nongnu.org; Tue, 28 Jan 2014 11:31:21 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:46873) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8BZ8-0002sM-EQ for qemu-devel@nongnu.org; Tue, 28 Jan 2014 11:31:10 -0500 Received: by mail-pa0-f46.google.com with SMTP id rd3so564977pab.19 for ; Tue, 28 Jan 2014 08:31:09 -0800 (PST) Date: Tue, 28 Jan 2014 08:31:04 -0800 From: Christoffer Dall Message-ID: <20140128163104.GE9687@cbox> References: <1390865691.3872.33.camel@pasglop> <1390869373.3872.43.camel@pasglop> <20140128004443.GB9687@cbox> <1390884452.3872.84.camel@pasglop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1390884452.3872.84.camel@pasglop> Subject: Re: [Qemu-devel] [Qemu-ppc] KVM and variable-endianness guest CPUs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Benjamin Herrenschmidt Cc: Peter Maydell , Thomas Falcon , kvm-devel , Victor Kamensky , QEMU Developers , "qemu-ppc@nongnu.org" , "kvmarm@lists.cs.columbia.edu" On Tue, Jan 28, 2014 at 03:47:32PM +1100, Benjamin Herrenschmidt wrote: > On Mon, 2014-01-27 at 16:44 -0800, Christoffer Dall wrote: > > > I'm loosing track of this discussion, Ben, can you explain a bit? You > > wrote: > > > > Having a byte array coming in that represents what the CPU does in its > > current byte order means you do *NOT* need to query the endianness of > > the guest CPU from userspace. > > > > What does "a byte array that represents what the CPU does in its current > > byte order" mean in this context. Do you mean the VCPU or the physical > > CPU when you say CPU. > > It doesn't matter once it's a byte array in address order. Again this is > the *right* abstraction for the kernel ABI, because you do not care > about the endianness of either side, guest or host. > > It makes no sense to treat a modern CPU data bus as having an MSB and an > LSB (even if they have it sometimes on the block diagram). Only when > *interpreting a value* on that bus, such as an *address* does the > endianness become of use. > > Treat the bus instead as an ordered sequence of bytes in ascending > address order and most of the complexity goes away. > > From there, for a given device, it all depends which bytes *that device* > choses to consider as being the MSB vs. LSB. It's not even a bus thing, > though of course some busses suggest an endianness, and some like PCI > mandates it for configuration space. > > But it remains a device-side choice. > > > I read your text as saying "just do a store of the register into the > > data pointer and don't worry about endianness", but somebody, somewhere, > > has to check the VCPU endianness setting. > > > > I'm probably wrong, and you are probably the right person to clear this > > up, but can you formulate exactly what you think the KVM ABI is and how > > you would put it in Documentation/virtual/kvm/api.txt? > > > > My point of view is that it is KVM that needs to do this, and it should > > "emulate the CPU" by performing a byteswap in the case where the CPU > > E-bit is set on ARM, but this is an ARM-centric way of looking at > > things. > > The ABI going to qemu should be (and inside qemu from TCG to the > emulation) that the CPU did an access of N bytes wide at address A > whose value is the byte array data[] in ascending address order. > OK, I've sent a v3 of the ABI clarification patch following the wording from you and Scott. I think we all agree what the format should look like at this point and hopefully we can quickly agree about a text to describe that. Thanks, -Christoffer