From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kmsdh-0003Mj-GB for qemu-devel@nongnu.org; Mon, 06 Oct 2008 12:08:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kmsdg-0003MG-9o for qemu-devel@nongnu.org; Mon, 06 Oct 2008 12:08:52 -0400 Received: from [199.232.76.173] (port=48014 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kmsdf-0003M8-QT for qemu-devel@nongnu.org; Mon, 06 Oct 2008 12:08:52 -0400 Received: from mx2.redhat.com ([66.187.237.31]:60884) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kmsdf-0004uh-8e for qemu-devel@nongnu.org; Mon, 06 Oct 2008 12:08:51 -0400 Message-ID: <48EA3719.8090304@redhat.com> Date: Mon, 06 Oct 2008 18:04:41 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 4/4] pci: use pci_config_header in pci.c References: <1222870375-13489-1-git-send-email-kraxel@redhat.com> <1222870375-13489-4-git-send-email-kraxel@redhat.com> <48E3A5BD.8010000@codemonkey.ws> <48E3CAF9.5040207@redhat.com> <48E3CF33.3050702@codemonkey.ws> <48E47E93.5000605@redhat.com> <48E4EE3D.2090503@codemonkey.ws> In-Reply-To: <48E4EE3D.2090503@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, Paul Brook Anthony Liguori wrote: > Gerd Hoffmann wrote: >> Well. That assumes the guests always use the correct in{b,w,l} >> instruction to access the config space values, i.e. never ever try to >> use two inb reads for a 16bit value for example. Or a inw for the lower >> 16 bits of a 32bit value because they know the high bits are zero anyway. >> >> I have my doubts that this is a sane expectation. > > The config space seems organized by data size so you could always just > take care of this in the accessors. That is, if you get a byte access > to a 32-bit value, you would do something like: > > (cpu_to_le32(d->config + (addr & ~3)) >> (8 * (addr % 4))) & 0xFF; > > Not the prettiest thing in the world, but it would work. -ETOO_MUCH_MAGIC. I want make the code more readable, that would go into the wrong direction IMHO. I think it is much more sane to explicitly call the byteswapping macros in the code. And add sparse checking support to qemu so we have some way to check correctness without taking the struct-trick route. cheers, Gerd