Re: [PATCH 2/3] virtio: mmio: fix signature checking for BE guests

2013-11-06 Thread Rusty Russell
Pawel Moll pawel.m...@arm.com writes:
 On Tue, 2013-11-05 at 03:36 +, Rusty Russell wrote:
 This particular can is empty - all worms already escaped :-)

I just thought that if you wait for 1.0, it will always be
little-endian, and if the current qemu only supported little-endian your
life might be simpler inside qemu.  But I'm sure Marc doesn't want to
wait :)

 It's a bugfix, not changing anything for the existing hosts. So - yes
 please, do merge this one.

Done, thanks.

Cheers,
Rusty.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] virtio: mmio: fix signature checking for BE guests

2013-11-05 Thread Pawel Moll
On Tue, 2013-11-05 at 03:36 +, Rusty Russell wrote:
 Rusty Russell ru...@rustcorp.com.au writes:
  Pawel Moll pawel.m...@arm.com writes:
  On Fri, 2013-10-11 at 15:36 +0100, Marc Zyngier wrote:
  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 ru...@rustcorp.com.au
  Cc: Michael S. Tsirkin m...@redhat.com
  Cc: Pawel Moll pawel.m...@arm.com
  Signed-off-by: Marc Zyngier marc.zyng...@arm.com
  ---
   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;
}
 
  The new spec will clarify this:
 
  * 0x000 | R | MagicValue
Magic value. Must be 0x74726976 (a Little Endian equivalent
of a virt string).
 
  ... but I like the 'v'i'r't' characters still being there :-)
 
  Acked-by: Pawel Moll pawel.m...@arm.com
 
  Applied, thanks.
 
 OK, I *said* applied, but left it in my pending queue.
 
 Pawel, do you want to open this can of worms?  If so, I'l merge this
 now.

This particular can is empty - all worms already escaped :-)

It's a bugfix, not changing anything for the existing hosts. So - yes
please, do merge this one.

Thanks

Paweł


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] virtio: mmio: fix signature checking for BE guests

2013-11-04 Thread Rusty Russell
Rusty Russell ru...@rustcorp.com.au writes:
 Pawel Moll pawel.m...@arm.com writes:
 On Fri, 2013-10-11 at 15:36 +0100, Marc Zyngier wrote:
 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 ru...@rustcorp.com.au
 Cc: Michael S. Tsirkin m...@redhat.com
 Cc: Pawel Moll pawel.m...@arm.com
 Signed-off-by: Marc Zyngier marc.zyng...@arm.com
 ---
  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;
 }

 The new spec will clarify this:

 * 0x000 | R | MagicValue
   Magic value. Must be 0x74726976 (a Little Endian equivalent
   of a virt string).

 ... but I like the 'v'i'r't' characters still being there :-)

 Acked-by: Pawel Moll pawel.m...@arm.com

 Applied, thanks.

OK, I *said* applied, but left it in my pending queue.

Pawel, do you want to open this can of worms?  If so, I'l merge this
now.

Cheers,
Rusty.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] virtio: mmio: fix signature checking for BE guests

2013-10-14 Thread Pawel Moll
On Fri, 2013-10-11 at 15:36 +0100, Marc Zyngier wrote:
 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 ru...@rustcorp.com.au
 Cc: Michael S. Tsirkin m...@redhat.com
 Cc: Pawel Moll pawel.m...@arm.com
 Signed-off-by: Marc Zyngier marc.zyng...@arm.com
 ---
  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;
   }

The new spec will clarify this:

* 0x000 | R | MagicValue
  Magic value. Must be 0x74726976 (a Little Endian equivalent
  of a virt string).

... but I like the 'v'i'r't' characters still being there :-)

Acked-by: Pawel Moll pawel.m...@arm.com

Paweł


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] virtio: mmio: fix signature checking for BE guests

2013-10-14 Thread Rusty Russell
Pawel Moll pawel.m...@arm.com writes:
 On Fri, 2013-10-11 at 15:36 +0100, Marc Zyngier wrote:
 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 ru...@rustcorp.com.au
 Cc: Michael S. Tsirkin m...@redhat.com
 Cc: Pawel Moll pawel.m...@arm.com
 Signed-off-by: Marc Zyngier marc.zyng...@arm.com
 ---
  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;
  }

 The new spec will clarify this:

 * 0x000 | R | MagicValue
   Magic value. Must be 0x74726976 (a Little Endian equivalent
   of a virt string).

 ... but I like the 'v'i'r't' characters still being there :-)

 Acked-by: Pawel Moll pawel.m...@arm.com

Applied, thanks.

Cheers,
Rusty.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] virtio: mmio: fix signature checking for BE guests

2013-10-11 Thread Marc Zyngier
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 ru...@rustcorp.com.au
Cc: Michael S. Tsirkin m...@redhat.com
Cc: Pawel Moll pawel.m...@arm.com
Signed-off-by: Marc Zyngier marc.zyng...@arm.com
---
 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


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html