Skip to content

Commit

Permalink
virtio: mmio: fix signature checking for BE guests
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marc Zyngier authored and Rusty Russell committed Nov 7, 2013
1 parent 2342d6a commit 4ae8537
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/virtio/virtio_mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4ae8537

Please sign in to comment.