Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtio Qemu 8.1.2 issues fix #11201

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/arm64/qemu/qemu-armv8a/configs/fb/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_TASK_STACKSIZE=8192
CONFIG_DEVICE_TREE=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIDEO=y
CONFIG_DRIVERS_VIRTIO=y
Expand Down
1 change: 1 addition & 0 deletions boards/arm64/qemu/qemu-armv8a/configs/netnsh/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_TASK_STACKSIZE=8192
CONFIG_DEVICE_TREE=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIRTIO=y
CONFIG_DRIVERS_VIRTIO_BLK=y
Expand Down
1 change: 1 addition & 0 deletions boards/arm64/qemu/qemu-armv8a/configs/netnsh_hv/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_TASK_STACKSIZE=8192
CONFIG_DEVICE_TREE=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIRTIO=y
CONFIG_DRIVERS_VIRTIO_BLK=y
Expand Down
1 change: 1 addition & 0 deletions boards/arm64/qemu/qemu-armv8a/configs/netnsh_smp/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_TASK_STACKSIZE=8192
CONFIG_DEVICE_TREE=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIRTIO=y
CONFIG_DRIVERS_VIRTIO_BLK=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_TASK_STACKSIZE=8192
CONFIG_DEVICE_TREE=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIRTIO=y
CONFIG_DRIVERS_VIRTIO_BLK=y
Expand Down
1 change: 1 addition & 0 deletions boards/risc-v/qemu-rv/rv-virt/configs/fb/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ CONFIG_BOARD_LOOPSPERMSEC=6366
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIDEO=y
CONFIG_DRIVERS_VIRTIO=y
Expand Down
1 change: 1 addition & 0 deletions boards/risc-v/qemu-rv/rv-virt/configs/fb64/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ CONFIG_BOARD_LOOPSPERMSEC=6366
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIDEO=y
CONFIG_DRIVERS_VIRTIO=y
Expand Down
1 change: 1 addition & 0 deletions boards/risc-v/qemu-rv/rv-virt/configs/knetnsh64/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CONFIG_BUILD_KERNEL=y
CONFIG_CODECS_HASH_MD5=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIRTIO=y
CONFIG_DRIVERS_VIRTIO_BLK=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CONFIG_BUILD_KERNEL=y
CONFIG_CODECS_HASH_MD5=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIRTIO=y
CONFIG_DRIVERS_VIRTIO_BLK=y
Expand Down
1 change: 1 addition & 0 deletions boards/risc-v/qemu-rv/rv-virt/configs/netnsh/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CONFIG_BUILTIN=y
CONFIG_CODECS_HASH_MD5=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIRTIO=y
CONFIG_DRIVERS_VIRTIO_BLK=y
Expand Down
1 change: 1 addition & 0 deletions boards/risc-v/qemu-rv/rv-virt/configs/netnsh64/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CONFIG_BUILTIN=y
CONFIG_CODECS_HASH_MD5=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIRTIO=y
CONFIG_DRIVERS_VIRTIO_BLK=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CONFIG_BUILTIN=y
CONFIG_CODECS_HASH_MD5=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIRTIO=y
CONFIG_DRIVERS_VIRTIO_BLK=y
Expand Down
1 change: 1 addition & 0 deletions boards/risc-v/qemu-rv/rv-virt/configs/netnsh_smp/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CONFIG_BUILTIN=y
CONFIG_CODECS_HASH_MD5=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIRTIO=y
CONFIG_DRIVERS_VIRTIO_BLK=y
Expand Down
4 changes: 2 additions & 2 deletions drivers/virtio/virtio-mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,9 +759,9 @@ static int virtio_mmio_init_device(FAR struct virtio_mmio_device_s *vmdev,
vmdev->shm_phy = (metal_phys_addr_t)0;
vmdev->cfg_phy = (metal_phys_addr_t)regs;
metal_io_init(&vmdev->shm_io, NULL, &vmdev->shm_phy,
SIZE_MAX, UINT_MAX, 0, NULL);
SIZE_MAX, UINT_MAX, 0, metal_io_get_ops());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not change metal io operation to non-atomic directly?

metal_io_init(&vmdev->cfg_io, regs, &vmdev->cfg_phy,
SIZE_MAX, UINT_MAX, 0, NULL);
SIZE_MAX, UINT_MAX, 0, metal_io_get_ops());

/* Init the virtio device */

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
From af3de6cd042c89ae2e8d07d503e0a07129e1296c Mon Sep 17 00:00:00 2001
From: Bowen Wang <wangbowen6@xiaomi.com>
Date: Thu, 16 Nov 2023 14:52:48 +0800
Subject: [PATCH] libmetal/nuttx/io.c: align access when read/write size = 1,
2, 4, 8

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
---
lib/system/nuttx/io.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/lib/system/nuttx/io.c libmetal/lib/system/nuttx/io.c
index 4fa4727..3ce9cbe 100644
--- a/lib/system/nuttx/io.c
+++ libmetal/lib/system/nuttx/io.c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's upstream to open-amp community

@@ -37,7 +37,17 @@ static int metal_io_block_read_(struct metal_io_region *io,
void *va = metal_io_virt(io, offset);

metal_cache_invalidate(va, len);
- memcpy(dst, va, len);
+ if (len == 1)
+ *(uint8_t *)dst = *(uint8_t *)va;
+ else if (len == 2)
+ *(uint16_t *)dst = *(uint16_t *)va;
+ else if (len == 4)
+ *(uint32_t *)dst = *(uint32_t *)va;
+ else if (len == 8) {
+ *(uint32_t *)dst = *(uint32_t *)va;
+ *(uint32_t *)(dst + 4) = *(uint32_t *)(va + 4);
+ } else
+ memcpy(dst, va, len);

return len;
}
@@ -50,7 +60,18 @@ static int metal_io_block_write_(struct metal_io_region *io,
{
void *va = metal_io_virt(io, offset);

- memcpy(va, src, len);
+ if (len == 1)
+ *(uint8_t *)va = *(uint8_t *)src;
+ else if (len == 2)
+ *(uint16_t *)va = *(uint16_t *)src;
+ else if (len == 4)
+ *(uint32_t *)va = *(uint32_t *)src;
+ else if (len == 8) {
+ *(uint32_t *)va = *(uint32_t *)src;
+ *(uint32_t *)(va + 4) = *(uint32_t *)(src + 4);
+ } else
+ memcpy(va, src, len);
+
metal_cache_flush(va, len);

return len;
--
2.34.1

1 change: 1 addition & 0 deletions openamp/libmetal.defs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ libmetal.zip:
$(Q) unzip -o libmetal.zip
$(Q) mv libmetal-$(VERSION) libmetal
$(Q) patch -p0 < 0001-libmetal-add-metal_list_for_each_safe-support.patch
$(Q) patch -p0 < 0002-libmetal-nuttx-io.c-align-access-when-read-write-siz.patch

.libmetal_headers: libmetal.zip
else
Expand Down
Loading