[PATCH 9/9] virtio: virtio-pci: restrict MIPS support to MMU configuration

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Mar 3 17:10:43 GMT 2021


Hello Antony,

On 02.03.21 15:28, Antony Pavlov wrote:
> On Sun, 28 Feb 2021 20:08:36 +0100
> Ahmad Fatoum <ahmad at a3f.at> wrote:
> 
> Hi!
> 
>> MMU-less MIPS doesn't play along nicely with VIRTIO_PCI.
>> e.g. Reading from a virtio-rng, will return clearly bogus data.
>> Document this in the Kconfig, so no one else trips over this.
>>
>> Eventually, this should be fixed..
> 
> 
> Please describe, how can I reproduce the problem.

- Apply this series on top of next, but revert this patch
- Use qemu-malta-defconfig
- Built with CONFIG_HW_RANDOM_VIRTIO=y and CONFIG_VIRTIO_PCI=y
- Run:
  qemu-system-mips -m 256M -device VGA -M malta -serial stdio -monitor null \
  -bios ./images/barebox-qemu-malta.img -device virtio-rng-pci,disable-legacy=on
- Execute md -s /dev/hwrng0 three times:

barebox at qemu malta:/ md -s /dev/hwrng0 
00000000: 0000e632 0000000d 81ff8410 00000000                ...2............
00000010: 0000e632 0000000d 81ff8410 00000000                ...2............
00000020: 0000e632 0000000d 81ff8410 00000000                ...2............
00000030: 0000e632 0000000d 81ff8410 00000000                ...2............
00000040: 0000e632 0000000d 81ff8410 00000000                ...2............
00000050: 0000e632 0000000d 81ff8410 00000000                ...2............
00000060: 0000e632 0000000d 81ff8410 00000000                ...2............
00000070: 0000e632 0000000d 81ff8410 00000000                ...2............
00000080: 0000e632 0000000d 81ff8410 00000000                ...2............
00000090: 0000e632 0000000d 81ff8410 00000000                ...2............
000000a0: 0000e632 0000000d 81ff8410 00000000                ...2............
000000b0: 0000e632 0000000d 81ff8410 00000000                ...2............
000000c0: 0000e632 0000000d 81ff8410 00000000                ...2............
000000d0: 0000e632 0000000d 81ff8410 00000000                ...2............
000000e0: 0000e632 0000000d 81ff8410 00000000                ...2............
000000f0: 0000e632 0000000d 81ff8410 00000000                ...2............
barebox at qemu malta:/ md -s /dev/hwrng0 
00000000: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
00000010: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
00000020: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
00000030: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
00000040: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
00000050: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
00000060: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
00000070: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
00000080: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
00000090: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
000000a0: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
000000b0: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
000000c0: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
000000d0: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
000000e0: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
000000f0: 30303030 30306630 3a203030 30306536                000000f0: 0000e6
barebox at qemu malta:/ md -s /dev/hwrng0 
00000000: 30303030 30306630 3a203330 33303330                000000f0: 303030
00000010: 30303030 30306630 3a203330 33303330                000000f0: 303030
00000020: 30303030 30306630 3a203330 33303330                000000f0: 303030
00000030: 30303030 30306630 3a203330 33303330                000000f0: 303030
00000040: 30303030 30306630 3a203330 33303330                000000f0: 303030
00000050: 30303030 30306630 3a203330 33303330                000000f0: 303030
00000060: 30303030 30306630 3a203330 33303330                000000f0: 303030
00000070: 30303030 30306630 3a203330 33303330                000000f0: 303030
00000080: 30303030 30306630 3a203330 33303330                000000f0: 303030
00000090: 30303030 30306630 3a203330 33303330                000000f0: 303030
000000a0: 30303030 30306630 3a203330 33303330                000000f0: 303030
000000b0: 30303030 30306630 3a203330 33303330                000000f0: 303030
000000c0: 30303030 30306630 3a203330 33303330                000000f0: 303030
000000d0: 30303030 30306630 3a203330 33303330                000000f0: 303030
000000e0: 30303030 30306630 3a203330 33303330                000000f0: 303030
000000f0: 30303030 30306630 3a203330 33303330                000000f0: 303030


Something is clearly wrong here, but I didn't look further.
If you repeat the same steps but with CONFIG_MMU=y, you will see random
data as expected (You can cp /dev/hwrng0 /dev/fb0 to see for yourself
that there is no obvious pattern, unlike with MMU=n).

Cheers,
Ahmad

> 
> 
>>
>> Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
>> ---
>>  drivers/virtio/Kconfig | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
>> index ecf66987b3ed..91a89d3e1b89 100644
>> --- a/drivers/virtio/Kconfig
>> +++ b/drivers/virtio/Kconfig
>> @@ -28,6 +28,7 @@ config VIRTIO_MMIO
>>  config VIRTIO_PCI
>>  	tristate "PCI driver for virtio devices"
>>  	depends on PCI && HAS_DMA
>> +	depends on MMU && MIPS || !MIPS
>>  	select VIRTIO
>>  	help
>>  	  This driver provides support for virtio based paravirtual device
>> -- 
>> 2.30.0
>>
>>
>> _______________________________________________
>> barebox mailing list
>> barebox at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox
> 
> 

-- 
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 |



More information about the barebox mailing list