aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2018-11-22 19:23:35 +0100
committerKevin Wolf <kwolf@redhat.com>2018-11-22 19:37:31 +0100
commit71a86ddece548860f040d565204cf1bf59d74663 (patch)
treec64dc8208eba88addce9661078b3317c6ff6cfa2
parent2067d39e5e53b053bece6fa15711640123c119ed (diff)
downloadqemu-arm-71a86ddece548860f040d565204cf1bf59d74663.tar.gz
nvme: fix CMB endianness confusion
The CMB is marked as DEVICE_LITTLE_ENDIAN, so the data must be read/written as if it was little-endian output (in the case of big endian, we get two swaps, one in the memory core and one in nvme.c). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--hw/block/nvme.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 84062d388f..01f3e853cf 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1177,16 +1177,13 @@ static void nvme_cmb_write(void *opaque, hwaddr addr, uint64_t data,
unsigned size)
{
NvmeCtrl *n = (NvmeCtrl *)opaque;
- memcpy(&n->cmbuf[addr], &data, size);
+ stn_le_p(&n->cmbuf[addr], size, data);
}
static uint64_t nvme_cmb_read(void *opaque, hwaddr addr, unsigned size)
{
- uint64_t val;
NvmeCtrl *n = (NvmeCtrl *)opaque;
-
- memcpy(&val, &n->cmbuf[addr], size);
- return val;
+ return ldn_le_p(&n->cmbuf[addr], size);
}
static const MemoryRegionOps nvme_cmb_ops = {