qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ray Wang <raywang@linux.vnet.ibm.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Changed the type of val argument of the function gt64120_writel() from uint32_t to uint64_t, so change the corresponding bswap32() to bswap64().
Date: Tue, 27 Sep 2011 09:20:35 +0800	[thread overview]
Message-ID: <4E8124E3.7020100@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAFEAcA--C3mZ+6sGE15rFi36CpMk+EtZToWkjG0WZQg=OzYLyw@mail.gmail.com>

On 9/26/2011 5:46 PM, Peter Maydell wrote:
> On 26 September 2011 07:22, Ray Wang<raywang@linux.vnet.ibm.com>  wrote:
>> diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c
>> index 1c34253..d0a31d2 100644
>> --- a/hw/gt64xxx.c
>> +++ b/hw/gt64xxx.c
>> @@ -312,7 +312,7 @@ static void gt64120_writel (void *opaque, target_phys_addr_t addr,
>>      uint32_t saddr;
>>
>>      if (!(s->regs[GT_CPU]&  0x00001000))
>> -        val = bswap32(val);
>> +        val = bswap64(val);
>>
>>      saddr = (addr&  0xfff)>>  2;
>>      switch (saddr) {
>> @@ -533,7 +533,7 @@ static void gt64120_writel (void *opaque, target_phys_addr_t addr,
>>          break;
>>      case GT_PCI0_CFGDATA:
>>          if (!(s->regs[GT_PCI0_CMD]&  1)&&  (s->pci.config_reg&  0x00fff800))
>> -            val = bswap32(val);
>> +            val = bswap64(val);
>>          if (s->pci.config_reg&  (1u<<  31))
>>              pci_data_write(s->pci.bus, s->pci.config_reg, val, 4);
>>          break;
> I don't know this device, but this looks a bit suspicious. If
> you do a bswap64() on the value for a 32-bit write this will put
> the data into the high 32 bits and zeros into the low half; then
> storing into s->regs[] will just write a zero (since regs[] is
> 32 bits), won't it? Changing only writel and not readl also looks
> odd.
    Yes, you're right. However, if a 64-bit value with effective high 32 
bits is considered as a 32-bit one, some significant information will be 
lost.
>
> What is the bug this change is trying to fix?
    It is always a potential bug to process a 64-bit value as 32-bit 
one, isn't it?
>
> -- PMM
>


-- 
Best Regards,
-------------------------------------------------
Ray Wang
Linux Technology Center, KVM China
IBM Corp., Beijing, China
xianleiw@cn.ibm.com

  reply	other threads:[~2011-09-27  1:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-26  6:22 [Qemu-devel] [PATCH] Changed the type of val argument of the function gt64120_writel() from uint32_t to uint64_t, so change the corresponding bswap32() to bswap64() Ray Wang
2011-09-26  9:46 ` Peter Maydell
2011-09-27  1:20   ` Ray Wang [this message]
2011-09-27 11:15     ` Peter Maydell

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=4E8124E3.7020100@linux.vnet.ibm.com \
    --to=raywang@linux.vnet.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).