From: Marc Zyngier Date: Tue, 5 Nov 2013 10:51:28 +0000 (+1030) Subject: virtio: mmio: fix signature checking for BE guests X-Git-Tag: v3.13-rc1~82^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ae85370720156025e9cb873c13a0afb06ca1612;p=profile%2Fivi%2Fkernel-x86-ivi.git 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 Signed-off-by: Marc Zyngier Acked-by: Pawel Moll Signed-off-by: Rusty Russell --- diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index e9fdeb8..c600ccf 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) /* Check 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); return -ENODEV; }