virtio: mmio: fix signature checking for BE guests
As virtio-mmio config registers are specified to be little-endian, using readl() to read the magic value and then memcmp() to check it fails on BE (as readl() has an implicit swab). Fix it by encoding the magic value as an integer instead of a string. Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Acked-by: Pawel Moll <pawel.moll@arm.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Родитель
2342d6a651
Коммит
4ae8537072
|
@ -471,7 +471,7 @@ static int virtio_mmio_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
/* Check magic value */
|
/* Check magic value */
|
||||||
magic = readl(vm_dev->base + VIRTIO_MMIO_MAGIC_VALUE);
|
magic = readl(vm_dev->base + VIRTIO_MMIO_MAGIC_VALUE);
|
||||||
if (memcmp(&magic, "virt", 4) != 0) {
|
if (magic != ('v' | 'i' << 8 | 'r' << 16 | 't' << 24)) {
|
||||||
dev_warn(&pdev->dev, "Wrong magic value 0x%08lx!\n", magic);
|
dev_warn(&pdev->dev, "Wrong magic value 0x%08lx!\n", magic);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче