From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wi8wB-0007jU-BR for qemu-devel@nongnu.org; Wed, 07 May 2014 16:59:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wi8w1-0000r4-OX for qemu-devel@nongnu.org; Wed, 07 May 2014 16:59:35 -0400 Message-ID: <536A9EAB.1080105@suse.de> Date: Wed, 07 May 2014 22:59:23 +0200 From: Alexander Graf MIME-Version: 1.0 References: <20140505074816.25523.71374.stgit@bahia.local> <20140505080438.25523.94922.stgit@bahia.local> <53677043.5000606@suse.de> <20140507102037.72d76d56@bahia.local> <536A8336.2000500@gmail.com> <536A9D72.7030309@gmail.com> In-Reply-To: <536A9D72.7030309@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH v3 2/4] ppc64-dump: Support dump for little endian ppc64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tom Musta Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, bharata@linux.vnet.ibm.com, afaerber@suse.de, Greg Kurz On 05/07/2014 10:54 PM, Tom Musta wrote: > On 5/7/2014 2:02 PM, Tom Musta wrote: > >> It feels like there is an endianness issue here but I have not yet been able >> to put my finger on it. > OK ... after more thought and scribbling ... here is what I mean .... > > Suppose I have a 64-bit value 0xa0a1a2a3a4a5a6a7 stored in guest memory and it > gets loaded into a GPR. If I follow the dump code and view all four combinations > of guest/host big/little endian, I convince myself that the big endian guest > code writes the byte sequence 0xa0, 0xa1, 0xa2, ..., 0xa7 into the file. And > the little endian guest dumps contain the sequence 0xa7, 0xa6, ..., 0xa0. > > This make sense ... the endianness indicated in the dump header and the endianness of > the dump file layout are consistent, irrespective of the host endianness. > > If I take this a step further and consider a 128-bit value 0xa0a1a2a3a4a5a6a7a8a9aaabacadaeaf > stored in guest memory and look at the AVR structure (via printf or debugger) after doing > a 128-bit lvx load, I get the following: > > +------+-------+------------------+------------------+---------------------+ > | Host | Guest | avr.u64[0] | avr.u64[1] | file sequence | > +------+-------+------------------+------------------+---------------------+ > | BE | BE | a0a1a2a3a4a5a6a7 | a8a9aaabacadaeaf | a0,...,a7,a8,...,af | > | LE | BE | a8a9aaabacadaeaf | a0a1a2a3a4a5a6a7 | a8,...,af,a0,...,a7 | > | BE | LE | a0a1a2a3a4a5a6a7 | a8a9aaabacadaeaf | a7,...,a0,af,...,a8 | > | LE | LE | a8a9aaabacadaeaf | a0a1a2a3a4a5a6a7 | af,...,a8,a7,...,a0 | > +------+-------+------------------+------------------+---------------------+ > > The last column represents how I think the proposed dump code will write bytes > to disk. Notice that if you invert the (64-bit) array elements, then the two > BE dumps look alike and the two LE dumps look alike. If you swap array u64 > elements on LE hosts, and also swap on LE guests, then you get a byte sequence > that looks like a 128-bit integer in all cases. Since we're dumping an ELF core dump the big question is what gdb wants to load :) Alex