qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Hannes Reinecke <hare@suse.de>
Cc: Blue Swirl <blauwirbel@gmail.com>, Alexander Graf <agraf@suse.de>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 1/9] exec: add endian specific phys ld/st functions
Date: Wed, 06 Jul 2011 15:30:47 +0200	[thread overview]
Message-ID: <4E146387.2030402@redhat.com> (raw)
In-Reply-To: <4E145D1C.9050506@suse.de>

On 07/06/2011 03:03 PM, Hannes Reinecke wrote:
>
> uint32_t ldub_phys(target_phys_addr_t addr);
> uint32_t lduw_phys(target_phys_addr_t addr);
>
> Hmm? ldub is supposed to read an 'unsigned byte' (uint8_t),
> and lduw is supposed to read an 'unsigned word' (uint16_t).
>
> Why does it return an uint32_t?

I don't know if this is the reason, but uint{8,16}_t are promoted to a 
signed int.  So when you do

   (uint64_t) (ldub_phys (addr) << 24)

you'd get a sign extension in bits 32-63.  Admittedly a bit contrived, 
but it can happen and QEMU is full of such bugs:

     case 4:
         lba = (uint64_t) buf[9] | ((uint64_t) buf[8] << 8) |
               ((uint64_t) buf[7] << 16) | ((uint64_t) buf[6] << 24) |
               ((uint64_t) buf[5] << 32) | ((uint64_t) buf[4] << 40) |
               ((uint64_t) buf[3] << 48) | ((uint64_t) buf[2] << 56);
         break;

(found by Coverity).

This was the reason for my series at 
http://permalink.gmane.org/gmane.comp.emulators.qemu/105336 (which you 
reminded me to ping---thanks!)

Paolo

  parent reply	other threads:[~2011-07-06 13:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 16:28 [Qemu-devel] [PATCH 0/9] Don't use ld./st._phys in hw/ Alexander Graf
2011-07-05 16:28 ` [Qemu-devel] [PATCH 1/9] exec: add endian specific phys ld/st functions Alexander Graf
2011-07-05 21:48   ` Blue Swirl
2011-07-05 21:55     ` Alexander Graf
2011-07-05 22:05       ` Blue Swirl
2011-07-05 22:13         ` Alexander Graf
2011-07-05 22:22           ` Blue Swirl
2011-07-05 22:40             ` Alexander Graf
2011-07-06 10:24               ` Paolo Bonzini
2011-07-06 11:34                 ` Alexander Graf
2011-07-06 13:03                   ` Hannes Reinecke
2011-07-06 13:18                     ` Alexander Graf
2011-07-06 13:30                     ` Paolo Bonzini [this message]
2011-07-05 16:28 ` [Qemu-devel] [PATCH 2/9] hpet: use specific endian ld/st_phys Alexander Graf
2011-07-05 16:28 ` [Qemu-devel] [PATCH 3/9] intel-hda: " Alexander Graf
2011-07-05 16:28 ` [Qemu-devel] [PATCH 4/9] msi: " Alexander Graf
2011-07-05 16:28 ` [Qemu-devel] [PATCH 5/9] msix: " Alexander Graf
2011-07-05 16:28 ` [Qemu-devel] [PATCH 6/9] pl080: " Alexander Graf
2011-07-12 20:46   ` Peter Maydell
2011-07-05 16:28 ` [Qemu-devel] [PATCH 7/9] ppc405_uc: " Alexander Graf
2011-07-05 16:28 ` [Qemu-devel] [PATCH 8/9] s390-virtio: " Alexander Graf
2011-07-05 16:28 ` [Qemu-devel] [PATCH 9/9] spapr: " Alexander Graf
2011-07-05 21:53 ` [Qemu-devel] [PATCH 0/9] Don't use ld./st._phys in hw/ Blue Swirl

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=4E146387.2030402@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=agraf@suse.de \
    --cc=blauwirbel@gmail.com \
    --cc=hare@suse.de \
    --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).