aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/virtio/virtio_mmio.c
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2013-11-05 05:51:28 -0500
committerRusty Russell <rusty@rustcorp.com.au>2013-11-06 20:43:04 -0500
commit4ae85370720156025e9cb873c13a0afb06ca1612 (patch)
tree3f2fc075e48cdfb64df2dd659a3acc656308f18a /drivers/virtio/virtio_mmio.c
parent2342d6a6512ce5a3d2433bf77e6580e738cfd709 (diff)
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>
Diffstat (limited to 'drivers/virtio/virtio_mmio.c')
-rw-r--r--drivers/virtio/virtio_mmio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index e9fdeb861992..c600ccfd6922 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -471,7 +471,7 @@ static int virtio_mmio_probe(struct platform_device *pdev)
471 471
472 /* Check magic value */ 472 /* Check magic value */
473 magic = readl(vm_dev->base + VIRTIO_MMIO_MAGIC_VALUE); 473 magic = readl(vm_dev->base + VIRTIO_MMIO_MAGIC_VALUE);
474 if (memcmp(&magic, "virt", 4) != 0) { 474 if (magic != ('v' | 'i' << 8 | 'r' << 16 | 't' << 24)) {
475 dev_warn(&pdev->dev, "Wrong magic value 0x%08lx!\n", magic); 475 dev_warn(&pdev->dev, "Wrong magic value 0x%08lx!\n", magic);
476 return -ENODEV; 476 return -ENODEV;
477 } 477 }