diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-04-08 16:51:11 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-04-08 18:37:45 +0100 |
commit | 7dc176bce49c61551b513508def136d5bb632b72 (patch) | |
tree | 465316199814f3411c52ed844a70d98da5f93c46 | |
parent | 9bc1a1d817670702f642633a325da346047f7508 (diff) |
hw/pci-host/prep: Don't reverse IO accesses on bigendian hosts
The raven_io_read() and raven_io_write() functions pass and
return values in little-endian format (since the IO op struct
is marked DEVICE_LITTLE_ENDIAN); however they were storing the
values in the buffer to pass to address_space_read/write()
in host-endian order, which meant that on big-endian hosts
the values were inadvertently reversed. Use the *_le_p()
accessors instead so that we are consistent regardless of
host endianness.
Strictly speaking the byte order of the buffer for
address_space_rw() is target byte order (which for PPC
will be BE) but it doesn't actually matter as long as we
are consistent about the marking on the IO op struct and
which stl_*_p().
This bug was probably introduced due to confusion caused by
the two different versions of ldl_p() and friends:
bswap.h defines versions meaning "host endianness access"
cpu-all.h defines versions meaning "target endianness access"
As a target-independent source file prep.c gets the bswap.h
versions; the very similar looking code in ioport.c is
compiled per-target and gets the cpu-all.h versions.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1396972271-22660-1-git-send-email-peter.maydell@linaro.org
Reviewed-by: Richard Henderson <rth@twiddle.net>
-rw-r--r-- | hw/pci-host/prep.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c index d3e746c0f8..40145408ef 100644 --- a/hw/pci-host/prep.c +++ b/hw/pci-host/prep.c @@ -145,9 +145,9 @@ static uint64_t raven_io_read(void *opaque, hwaddr addr, if (size == 1) { return buf[0]; } else if (size == 2) { - return lduw_p(buf); + return lduw_le_p(buf); } else if (size == 4) { - return ldl_p(buf); + return ldl_le_p(buf); } else { g_assert_not_reached(); } @@ -164,9 +164,9 @@ static void raven_io_write(void *opaque, hwaddr addr, if (size == 1) { buf[0] = val; } else if (size == 2) { - stw_p(buf, val); + stw_le_p(buf, val); } else if (size == 4) { - stl_p(buf, val); + stl_le_p(buf, val); } else { g_assert_not_reached(); } |