[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 14/26] virtio: change memcpy to guest reads
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PATCH 14/26] virtio: change memcpy to guest reads |
Date: |
Sat, 21 Jan 2012 05:18:59 +0100 |
When accessing the device specific virtio config space, we memcpy
the data into a variable in QEMU. At that point we're basically
pulling host endianness into the game which is a really bad idea.
So instead, let's use the target specific load/store helpers for
memory pointers which fetch things in target endianness. The whole
array is already populated in target endianness anyways
(see virtio-blk).
Signed-off-by: Alexander Graf <address@hidden>
Reviewed-by: Anthony Liguori <address@hidden>
---
hw/virtio.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/virtio.c b/hw/virtio.c
index 81ecc40..74cc038 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -539,7 +539,7 @@ uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t
addr)
if (addr > (vdev->config_len - sizeof(val)))
return (uint32_t)-1;
- memcpy(&val, vdev->config + addr, sizeof(val));
+ val = ldub_p(vdev->config + addr);
return val;
}
@@ -552,7 +552,7 @@ uint32_t virtio_config_readw(VirtIODevice *vdev, uint32_t
addr)
if (addr > (vdev->config_len - sizeof(val)))
return (uint32_t)-1;
- memcpy(&val, vdev->config + addr, sizeof(val));
+ val = lduw_p(vdev->config + addr);
return val;
}
@@ -565,7 +565,7 @@ uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t
addr)
if (addr > (vdev->config_len - sizeof(val)))
return (uint32_t)-1;
- memcpy(&val, vdev->config + addr, sizeof(val));
+ val = ldl_p(vdev->config + addr);
return val;
}
@@ -576,7 +576,7 @@ void virtio_config_writeb(VirtIODevice *vdev, uint32_t
addr, uint32_t data)
if (addr > (vdev->config_len - sizeof(val)))
return;
- memcpy(vdev->config + addr, &val, sizeof(val));
+ stb_p(vdev->config + addr, val);
if (vdev->set_config)
vdev->set_config(vdev, vdev->config);
@@ -589,7 +589,7 @@ void virtio_config_writew(VirtIODevice *vdev, uint32_t
addr, uint32_t data)
if (addr > (vdev->config_len - sizeof(val)))
return;
- memcpy(vdev->config + addr, &val, sizeof(val));
+ stw_p(vdev->config + addr, val);
if (vdev->set_config)
vdev->set_config(vdev, vdev->config);
@@ -602,7 +602,7 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t
addr, uint32_t data)
if (addr > (vdev->config_len - sizeof(val)))
return;
- memcpy(vdev->config + addr, &val, sizeof(val));
+ stl_p(vdev->config + addr, val);
if (vdev->set_config)
vdev->set_config(vdev, vdev->config);
--
1.6.0.2
- [Qemu-ppc] [PULL 00/26] ppc patch queue 2012-01-21, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 06/26] PPC: 440: Default to 440EP CPU, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 12/26] PPC: Bamboo: Integrate SoC instatiation, use qdev for PCI, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 07/26] PPC: Enable 440EP CPU target, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 16/26] Fix dirty logging with 32-bit qemu & 64-bit guests, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 14/26] virtio: change memcpy to guest reads,
Alexander Graf <=
- [Qemu-ppc] [PATCH 02/26] PPC: Bamboo: Register CPU reset, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 26/26] grackle_pci: Clean up qdev names, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 11/26] PPC: Bamboo: fold ppc440.c and ppc440_bamboo.c into a single file, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 09/26] PPC: bamboo: fix whitespace, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 13/26] virtio-pci: Fix endianness of virtio config, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 05/26] PPC: Bamboo: recompile device tree, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 04/26] PPC: 440: Ignore invalid PCI IRQs, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 01/26] PPC: 440EP: Initialize timer, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 18/26] Correct types in bmdma_addr_{read,write}, Alexander Graf, 2012/01/20
- [Qemu-ppc] [PATCH 03/26] PPC: Bamboo: Set initial TLB entry, Alexander Graf, 2012/01/20