Skip to contentSkip to conversation

virtio: ring: fix erroneous behavior on MIPS

PATCH Applied Antony Pavlov 2 participants 4 messages Nov 24, 2023 – Nov 27, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover virtio: ring: fix erroneous behavior on MIPS

Antony Pavlov (2):
virtio: ring: fix erroneous behavior on MIPS
MIPS: qemu-malta*_defconfig: enable virtio network driver

 arch/mips/configs/qemu-malta64el_defconfig | 1 +
 arch/mips/configs/qemu-malta_defconfig     | 1 +
 drivers/virtio/virtio_ring.c               | 4 ++--
 3 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.0
#1 lore raw

PATCH 1/2 virtio: ring: fix erroneous behavior on MIPS

How to reproduce the crash on the 64-bit malta board:

    export ARCH=mips
    export CROSS_COMPILE=mips-linux-gnu-
    make qemu-malta64el_defconfig
    sed -i "s/# \(CONFIG_DRIVER_NET_VIRTIO\).*$/\1=y/" .config
    make oldconfig
    make
    ...
    qemu-system-mips64el -m 256 -M malta -cpu MIPS64R2-generic \
        -bios ./images/barebox-qemu-malta.img.swapped \
        -nodefaults -nographic \
        -serial mon:stdio \
        -net nic,model=virtio-net-pci -net user
    ...
    barebox@qemu malta:/ dhcp
    WARNING: eth0: No MAC address set. Using random address 9e:85:56:74:55:bb

    Ooops, TLB miss on load or ifetch!

    $ 0   : 0000000000000000 0000000000000004 000000000000000c 0000000000000001
    $ 4   : ffffffffafb7fee8 000000000fb7402c 000000000000024e 0000000000000020
    $ 8   : 0000000000000001 0000000000000001 0000000000000110 ffffffffafba6df0
    $12   : 0000000000000008 ffffffffaffc9584 0000000000000001 646e617220676e69
    $16   : ffffffffafb7fee8 ffffffffafb6fee8 00000000b2d05e00 ffffffffaffeb090
    $20   : ffffffffafb800c0 0000000000000100 0000000000000122 ffffffffafb800f0
    $24   : 0000000000000006 ffffffffaff93974
    $28   : 0000000000000000 ffffffffafb5f9f0 ffffffffafff0000 ffffffffaff7a6e4
    Hi    : 0000000000000000
    Lo    : 000235e8a8000000
    epc   : ffffffffaffb5db0
    ra    : ffffffffaff7a6e4
    Status: 00000082
    Cause : 00000408
    Config: 80004482
    BadVA : 000000000fb74039
---
 drivers/virtio/virtio_ring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/virtio/virtio_ring.c +2 -2
index fd21d3adcdb..0efe1e00250 100644
@@ -256,8 +256,8 @@ void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len)
 		virtio_store_mb(&vring_used_event(&vq->vring),
 				cpu_to_virtio16(vq->vdev, vq->last_used_idx));
 
-	return (void *)(uintptr_t)virtio64_to_cpu(vq->vdev,
-						  vq->vring.desc[i].addr);
+	return IOMEM((uintptr_t)virtio64_to_cpu(vq->vdev,
+						  vq->vring.desc[i].addr));
 }
 
 static struct virtqueue *__vring_new_virtqueue(unsigned int index,
Signature · 1 line
2.39.0
#2 lore raw

PATCH 2/2 MIPS: qemu-malta*_defconfig: enable virtio network driver

In reply to Antony Pavlov
---
 arch/mips/configs/qemu-malta64el_defconfig | 1 +
 arch/mips/configs/qemu-malta_defconfig     | 1 +
 2 files changed, 2 insertions(+)
arch/mips/configs/qemu-malta64el_defconfig +1 -0
index 6091e6d0301..da3396246d5 100644
@@ -64,6 +64,7 @@ CONFIG_OFDEVICE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_VIRTIO_CONSOLE=y
 CONFIG_DRIVER_NET_RTL8139=y
+CONFIG_DRIVER_NET_VIRTIO=y
 # CONFIG_SPI is not set
 CONFIG_I2C=y
 CONFIG_I2C_GPIO=y
arch/mips/configs/qemu-malta_defconfig +1 -0
index 6cbc4efa86f..4be05b7e5a3 100644
@@ -61,6 +61,7 @@ CONFIG_OFDEVICE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_VIRTIO_CONSOLE=y
 CONFIG_DRIVER_NET_RTL8139=y
+CONFIG_DRIVER_NET_VIRTIO=y
 # CONFIG_SPI is not set
 CONFIG_I2C=y
 CONFIG_I2C_GPIO=y
Signature · 1 line
2.39.0
Applied
#3 lore raw
In reply to Antony Pavlov
Quoted 3 lines · Antony Pavlov

Antony Pavlov (2):
virtio: ring: fix erroneous behavior on MIPS
MIPS: qemu-malta*_defconfig: enable virtio network driver

Applied, thanks

Sascha

Quoted 10 lines
 arch/mips/configs/qemu-malta64el_defconfig | 1 +
 arch/mips/configs/qemu-malta_defconfig     | 1 +
 drivers/virtio/virtio_ring.c               | 4 ++--
 3 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.0
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |