Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-14 Thread Benjamin Herrenschmidt
On Wed, 2013-02-13 at 15:28 +, Marc Zyngier wrote: > Well, the spec clearly says that the registers reflect the endianess of > the guest, and it makes sense: when performing the MMIO access, KVM > needs to convert between host and guest endianess. It's actually a horrible idea :-) What does

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-14 Thread Benjamin Herrenschmidt
On Wed, 2013-02-13 at 15:28 +, Marc Zyngier wrote: Well, the spec clearly says that the registers reflect the endianess of the guest, and it makes sense: when performing the MMIO access, KVM needs to convert between host and guest endianess. It's actually a horrible idea :-) What does

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Rusty Russell
"Michael S. Tsirkin" writes: > On Wed, Feb 13, 2013 at 03:28:52PM +, Marc Zyngier wrote: >> On 13/02/13 15:08, Pawel Moll wrote: >> > On Wed, 2013-02-13 at 14:25 +, Marc Zyngier wrote: >> >> Using readl() to read the magic value and then memcmp() to check it >> >> fails on BE, as bytes

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Marc Zyngier
On 13/02/13 16:53, Michael S. Tsirkin wrote: > On Wed, Feb 13, 2013 at 03:28:52PM +, Marc Zyngier wrote: >> On 13/02/13 15:08, Pawel Moll wrote: >>> On Wed, 2013-02-13 at 14:25 +, Marc Zyngier wrote: Using readl() to read the magic value and then memcmp() to check it fails on BE,

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Michael S. Tsirkin
On Wed, Feb 13, 2013 at 03:28:52PM +, Marc Zyngier wrote: > On 13/02/13 15:08, Pawel Moll wrote: > > On Wed, 2013-02-13 at 14:25 +, Marc Zyngier wrote: > >> Using readl() to read the magic value and then memcmp() to check it > >> fails on BE, as bytes will be the other way around (by

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Marc Zyngier
On 13/02/13 15:46, Pawel Moll wrote: > On Wed, 2013-02-13 at 15:28 +, Marc Zyngier wrote: Fix it by encoding the magic as an integer instead of a string. So I'm not completely sure this is the right fix, >>> >>> It seems right, however... >>> - Using __raw_readl() instead. Is

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Pawel Moll
On Wed, 2013-02-13 at 15:28 +, Marc Zyngier wrote: > >> Fix it by encoding the magic as an integer instead of a string. > >> So I'm not completely sure this is the right fix, > > > > It seems right, however... > > > >> - Using __raw_readl() instead. Is that a generic enough API? > >> > >

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Marc Zyngier
On 13/02/13 15:08, Pawel Moll wrote: > On Wed, 2013-02-13 at 14:25 +, Marc Zyngier wrote: >> Using readl() to read the magic value and then memcmp() to check it >> fails on BE, as bytes will be the other way around (by virtue of >> the registers to follow the endianess of the guest). > > Hm.

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Pawel Moll
On Wed, 2013-02-13 at 14:25 +, Marc Zyngier wrote: > Using readl() to read the magic value and then memcmp() to check it > fails on BE, as bytes will be the other way around (by virtue of > the registers to follow the endianess of the guest). Hm. Interesting. I missed the fact that readl() as

[RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Marc Zyngier
Using readl() to read the magic value and then memcmp() to check it fails on BE, as bytes will be the other way around (by virtue of the registers to follow the endianess of the guest). Fix it by encoding the magic as an integer instead of a string. Cc: Rusty Russell Cc: Michael S. Tsirkin Cc:

[RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Marc Zyngier
Using readl() to read the magic value and then memcmp() to check it fails on BE, as bytes will be the other way around (by virtue of the registers to follow the endianess of the guest). Fix it by encoding the magic as an integer instead of a string. Cc: Rusty Russell ru...@rustcorp.com.au Cc:

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Pawel Moll
On Wed, 2013-02-13 at 14:25 +, Marc Zyngier wrote: Using readl() to read the magic value and then memcmp() to check it fails on BE, as bytes will be the other way around (by virtue of the registers to follow the endianess of the guest). Hm. Interesting. I missed the fact that readl() as a

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Marc Zyngier
On 13/02/13 15:08, Pawel Moll wrote: On Wed, 2013-02-13 at 14:25 +, Marc Zyngier wrote: Using readl() to read the magic value and then memcmp() to check it fails on BE, as bytes will be the other way around (by virtue of the registers to follow the endianess of the guest). Hm.

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Pawel Moll
On Wed, 2013-02-13 at 15:28 +, Marc Zyngier wrote: Fix it by encoding the magic as an integer instead of a string. So I'm not completely sure this is the right fix, It seems right, however... - Using __raw_readl() instead. Is that a generic enough API? ... this implies that

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Marc Zyngier
On 13/02/13 15:46, Pawel Moll wrote: On Wed, 2013-02-13 at 15:28 +, Marc Zyngier wrote: Fix it by encoding the magic as an integer instead of a string. So I'm not completely sure this is the right fix, It seems right, however... - Using __raw_readl() instead. Is that a generic enough

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Michael S. Tsirkin
On Wed, Feb 13, 2013 at 03:28:52PM +, Marc Zyngier wrote: On 13/02/13 15:08, Pawel Moll wrote: On Wed, 2013-02-13 at 14:25 +, Marc Zyngier wrote: Using readl() to read the magic value and then memcmp() to check it fails on BE, as bytes will be the other way around (by virtue of

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Marc Zyngier
On 13/02/13 16:53, Michael S. Tsirkin wrote: On Wed, Feb 13, 2013 at 03:28:52PM +, Marc Zyngier wrote: On 13/02/13 15:08, Pawel Moll wrote: On Wed, 2013-02-13 at 14:25 +, Marc Zyngier wrote: Using readl() to read the magic value and then memcmp() to check it fails on BE, as bytes will

Re: [RFC PATCH] virt_mmio: fix signature checking for BE guests

2013-02-13 Thread Rusty Russell
Michael S. Tsirkin m...@redhat.com writes: On Wed, Feb 13, 2013 at 03:28:52PM +, Marc Zyngier wrote: On 13/02/13 15:08, Pawel Moll wrote: On Wed, 2013-02-13 at 14:25 +, Marc Zyngier wrote: Using readl() to read the magic value and then memcmp() to check it fails on BE, as bytes