Received: from eggs.gnu.org ([2001:4830:134:3::10]:45876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoZ0W-00087V-4m for qemu-devel@nongnu.org; Wed, 12 Nov 2014 09:35:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XoZ0L-0001FC-Nu for qemu-devel@nongnu.org; Wed, 12 Nov 2014 09:34:52 -0500 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:43784) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoZ0L-0001F2-Fy for qemu-devel@nongnu.org; Wed, 12 Nov 2014 09:34:41 -0500 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Nov 2014 14:34:39 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 199CB1B08049 for ; Wed, 12 Nov 2014 14:34:45 +0000 (GMT) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sACEYaGG62324940 for ; Wed, 12 Nov 2014 14:34:36 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sAC9VsaP020171 for ; Wed, 12 Nov 2014 04:31:54 -0500 Date: Wed, 12 Nov 2014 15:34:35 +0100 From: Frank Blaschka Message-ID: <20141112143435.GA38044@tuxmaker.boeblingen.de.ibm.com> References: <5461FE04.2050400@suse.de> <20141111123911.GA16205@tuxmaker.boeblingen.de.ibm.com> <877C2703-5899-460C-BFF8-8856B6382F4C@suse.de> <20141111140829.GC16205@tuxmaker.boeblingen.de.ibm.com> <54622A28.6020507@suse.de> <20141112084944.GA16686@tuxmaker.boeblingen.de.ibm.com> <54632383.7080103@suse.de> <20141112091930.GA45236@tuxmaker.boeblingen.de.ibm.com> <546326E8.1000909@suse.de> <54632A03.6050403@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54632A03.6050403@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/3] s390: implement pci instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: "peter.maydell@linaro.org" , Frank Blaschka , "james.hogan@imgtec.com" , "mtosatti@redhat.com" , "qemu-devel@nongnu.org" , Alexander Graf , "borntraeger@de.ibm.com" , "cornelia.huck@de.ibm.com" , "rth@twiddle.net" On Wed, Nov 12, 2014 at 10:36:03AM +0100, Paolo Bonzini wrote: > > > On 12/11/2014 10:22, Alexander Graf wrote: > >>>> Absolutely lets make an example for qemu running on BE and LE > >>>> > >>>> byte order config space backing pci_default_read_config pcilg (with cpu_to_le) > >>>> BE 0x78563412 0x12345678 0x78563412 > >>>> LE 0x78563412 0x78563412 0x78563412 > >>> > >>> No, pci_default_read_config() always returns 0x12345678 because it > >>> returns a register, not memory. > >>> > >> > >> You mean implementation of pci_default_read_config is broken? > >> If it should return a register it should not do "return le32_to_cpu(val);" > > > > It has to, to convert from memory (after memcpy) to an actual register > > value. Look at the value list in Paolo's email - I really have no idea > > how to explain it any better. > > pci_default_read_config is reading from a *device* register, and has > absolutely zero knowledge of the host CPU endianness. > > Another way to explain that the result of pci_default_read_config is > independent of the host endianness, is that the function is basically > doing this: > > switch (len) { > case 1: return d->config[address]; > case 2: return ldw_le_p(&d->config[address)]); > case 4: return ldl_le_p(&d->config[address)]); > default: abort(); > } > > So if you want to make the outcome big endian, you have to swap > unconditionally. > > Paolo Hi Paolo, Alex, thx a lot for all the explanation and patience. I think I have understand your point now. I will change the code to unconditional swap. I feel I had a knowledge gap regarding running guest and host which different byte orders. Hope this gap is filled now ;) Frank >