From mboxrd@z Thu Jan 1 00:00:00 1970 From: marc.zyngier@arm.com (Marc Zyngier) Date: Fri, 11 Oct 2013 15:36:10 +0100 Subject: [PATCH 2/3] virtio: mmio: fix signature checking for BE guests In-Reply-To: <1381502171-8187-1-git-send-email-marc.zyngier@arm.com> References: <1381502171-8187-1-git-send-email-marc.zyngier@arm.com> Message-ID: <1381502171-8187-3-git-send-email-marc.zyngier@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org 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: Rusty Russell Cc: Michael S. Tsirkin Cc: Pawel Moll Signed-off-by: Marc Zyngier --- drivers/virtio/virtio_mmio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index 1ba0d68..57f24fd 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -470,7 +470,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; } -- 1.8.2.3