* [Qemu-devel] [PATCH] nvme: fix CMB endianness confusion
@ 2018-11-22 18:23 Paolo Bonzini
2018-11-22 18:25 ` Peter Maydell
2018-11-22 18:45 ` Kevin Wolf
0 siblings, 2 replies; 3+ messages in thread
From: Paolo Bonzini @ 2018-11-22 18:23 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, peter.maydell
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>
---
hw/block/nvme.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 5d92794ef7..8a12fba24f 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1175,16 +1175,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 = {
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Qemu-devel] [PATCH] nvme: fix CMB endianness confusion
2018-11-22 18:23 [Qemu-devel] [PATCH] nvme: fix CMB endianness confusion Paolo Bonzini
@ 2018-11-22 18:25 ` Peter Maydell
2018-11-22 18:45 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2018-11-22 18:25 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: QEMU Developers, Kevin Wolf
On 22 November 2018 at 18:23, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 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>
> ---
> hw/block/nvme.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
Tested-by: Peter Maydell <peter.maydell@linaro.org>
This is sufficient to get the nvme-test to pass on sparc
(big-endian host).
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] nvme: fix CMB endianness confusion
2018-11-22 18:23 [Qemu-devel] [PATCH] nvme: fix CMB endianness confusion Paolo Bonzini
2018-11-22 18:25 ` Peter Maydell
@ 2018-11-22 18:45 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2018-11-22 18:45 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, peter.maydell
Am 22.11.2018 um 19:23 hat Paolo Bonzini geschrieben:
> 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>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-22 18:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-22 18:23 [Qemu-devel] [PATCH] nvme: fix CMB endianness confusion Paolo Bonzini
2018-11-22 18:25 ` Peter Maydell
2018-11-22 18:45 ` Kevin Wolf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.