public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Pawel Moll <pawel.moll@arm.com>, Marc Zyngier <Marc.Zyngier@arm.com>
Cc: "linux-arm-kernel\@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"kvmarm\@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	"kvm\@vger.kernel.org" <kvm@vger.kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH 2/3] virtio: mmio: fix signature checking for BE guests
Date: Tue, 05 Nov 2013 14:06:07 +1030	[thread overview]
Message-ID: <87a9hja5aw.fsf@rustcorp.com.au> (raw)
In-Reply-To: <87li1wb4k4.fsf@rustcorp.com.au>

Rusty Russell <rusty@rustcorp.com.au> writes:
> Pawel Moll <pawel.moll@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 <rusty@rustcorp.com.au>
>>> Cc: Michael S. Tsirkin <mst@redhat.com>
>>> Cc: Pawel Moll <pawel.moll@arm.com>
>>> Signed-off-by: Marc Zyngier <marc.zyngier@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.moll@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.

  reply	other threads:[~2013-11-05  3:36 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-11 14:36 [PATCH 0/3] virtio-mmio: handle BE guests on LE hosts Marc Zyngier
2013-10-11 14:36 ` [PATCH 1/3] virtio: let the guest report its endianess if advertized by the host Marc Zyngier
2013-10-11 14:36 ` [PATCH 2/3] virtio: mmio: fix signature checking for BE guests Marc Zyngier
2013-10-14  8:46   ` Pawel Moll
2013-10-14  9:11     ` Rusty Russell
2013-11-05  3:36       ` Rusty Russell [this message]
2013-11-05 10:45         ` Pawel Moll
2013-11-07  0:36           ` Rusty Russell
2013-10-11 14:36 ` [PATCH 3/3] virtio: mmio: access configuration space as little-endian Marc Zyngier
2013-10-14  8:44   ` Pawel Moll
2013-10-12 18:28 ` [PATCH 0/3] virtio-mmio: handle BE guests on LE hosts Michael S. Tsirkin
2013-10-14  8:24   ` Marc Zyngier
2013-10-14  8:59     ` Michael S. Tsirkin
2013-10-14  9:04       ` Pawel Moll
2013-10-14 10:46         ` Michael S. Tsirkin
2013-10-14 10:50           ` Pawel Moll
2013-10-14 23:02             ` Rusty Russell
2013-10-14  9:13     ` Rusty Russell
2013-10-14  8:21 ` Rusty Russell
2013-10-14 12:36   ` Marc Zyngier
2013-10-14 12:51     ` Michael S. Tsirkin
2013-10-17  0:27     ` Rusty Russell
2013-10-14 13:03 ` Paolo Bonzini
2013-10-14 13:10   ` Alexander Graf
2013-10-14 13:13     ` Paolo Bonzini
2013-10-14 13:24     ` Marc Zyngier
2013-10-14 13:29       ` Paolo Bonzini
2013-10-14 13:39       ` Alexander Graf
2013-10-14 13:49         ` Marc Zyngier
2013-10-14 14:05           ` Michael S. Tsirkin
2013-10-14 14:13             ` Marc Zyngier
2013-10-14 14:16               ` Alexander Graf
2013-10-14 14:52                 ` Marc Zyngier
2013-10-14 14:56                   ` Paolo Bonzini
2013-10-14 15:12                     ` Marc Zyngier
2013-10-14 15:22                       ` Paolo Bonzini
2013-10-14 15:36                         ` Marc Zyngier
2013-10-14 16:50                           ` Paolo Bonzini
2013-10-14 17:10                             ` Michael S. Tsirkin
2013-10-14 23:23                               ` Rusty Russell
2013-10-15  6:38                                 ` Michael S. Tsirkin
2013-10-15  9:19                                   ` Marc Zyngier
2013-10-14 15:45                         ` Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a9hja5aw.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=Marc.Zyngier@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mst@redhat.com \
    --cc=pawel.moll@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox