On 2 February 2013 18:26, Blue Swirl <blauwir...@gmail.com> wrote: > On Sat, Feb 2, 2013 at 5:44 PM, Peter Maydell <peter.mayd...@linaro.org> > wrote: >> On 2 February 2013 17:37, Andreas Färber <afaer...@suse.de> wrote: >>> Am 02.02.2013 17:49, schrieb Peter Maydell: >>> libqtest.h has no generic endian-aware memread functions unlike Alex, >>> you or me expected. It reads a sequence of bytes from guest memory and >>> transmits them one-by-one over the text-based qtest protocol. >> >> OK, so this is just busted for accessing devices. The protocol >> has to have some way of letting you do a 32 bit / 16 bit / 8 bit >> access (and maybe 64 bit as well while we're here). memread >> and memwrite are OK for RAM accesses [ie anything you'd be >> happy to have cached or buffered in a real system] but for >> memory mapped registers we need to have an equivalent of >> inb/inw/inl/outb/outw/outl that guarantee to do exactly one >> access of exactly the required width. > > I was also just making a patch (but not so nice as Andreas'). My > analysis was that qtest.c and libqtest.c just pass the result of > cpu_physical_memory_rw() as is, with no endian conversion. So the > result needs to be converted to host CPU order just like Andreas did. > I think the protocol is OK, my initial reaction was to put byte > swapping there but that's not right.
No, I think the protocol is broken, even if you ignore the question of endianness. Consider that a device's MemoryRegion can have different behaviour depending on whether you access it as a byte, halfword or word size. cpu_physical_memory_rw() won't let you make a word size access to an unaligned address. -- PMM