From: Marc Zyngier Date: Tue, 5 Nov 2013 10:51:28 +0000 (+1030) Subject: virtio: mmio: fix signature checking for BE guests X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4ae85370720156025e9cb873c13a0afb06ca1612;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.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 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) /* 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; }