From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
"patches@linaro.org" <patches@linaro.org>,
Richard Henderson <rth@twiddle.net>,
Paolo Bonzini <pbonzini@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Laurent Vivier <laurent@vivier.eu>
Subject: Re: [Qemu-devel] [PATCH for-2.9 4/6] disas/microblaze: Avoid unintended sign extension
Date: Fri, 3 Mar 2017 17:06:01 +0100 [thread overview]
Message-ID: <20170303160601.GA9606@toto> (raw)
In-Reply-To: <CAFEAcA9fm4XmY1LhssvkeAV4eBDC3ooQ7Tep=saRB7XYu10OZQ@mail.gmail.com>
On Fri, Mar 03, 2017 at 04:02:07PM +0000, Peter Maydell wrote:
> On 3 March 2017 at 15:58, Edgar E. Iglesias <edgar.iglesias@gmail.com> wrote:
> > On Fri, Mar 03, 2017 at 03:50:31PM +0000, Peter Maydell wrote:
> >> In read_insn_microblaze() we assemble 4 bytes into an 'unsigned
> >> long'. If 'unsigned long' is 64 bits and the high byte has its top
> >> bit set, then C's implicit conversion from 'unsigned char' to 'int'
> >> for the shift will result in an unintended sign extension which sets
> >> the top 32 bits in 'inst'. Add casts to prevent this. (Spotted by
> >> Coverity, CID 1005401.)
> >
> > I'm OK with this but perhaps it would have been more readable to
> > change inst to uint32_t ? (All microblaze insns are 32bit).
>
> I thought about that, but it was more invasive a change than
> I was happy with: you'd want to change not just 'inst' but
> also the return type of read_insn_microblaze, the opcode_mask
> field of struct op_code_struct, 'inst' and 'prev_inst' in
> print_insn_microblaze, the type of the instr arguments to
> get_field, get_field_imm, etc...
Ah, I see, didn't think about that...
Cheers,
Edgar
next prev parent reply other threads:[~2017-03-03 16:06 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 15:50 [Qemu-devel] [PATCH for-2.9 0/6] disas: Fix various coverity nits Peter Maydell
2017-03-03 15:50 ` [Qemu-devel] [PATCH for-2.9 1/6] disas/hppa: Remove dead code Peter Maydell
2017-03-03 19:40 ` Philippe Mathieu-Daudé
2017-03-03 15:50 ` [Qemu-devel] [PATCH for-2.9 2/6] disas/i386: Avoid NULL pointer dereference in error case Peter Maydell
2017-03-03 15:50 ` [Qemu-devel] [PATCH for-2.9 3/6] disas/m68k: Avoid unintended sign extension in get_field() Peter Maydell
2017-03-03 18:56 ` Laurent Vivier
2017-03-03 15:50 ` [Qemu-devel] [PATCH for-2.9 4/6] disas/microblaze: Avoid unintended sign extension Peter Maydell
2017-03-03 15:58 ` Edgar E. Iglesias
2017-03-03 16:02 ` Peter Maydell
2017-03-03 16:06 ` Edgar E. Iglesias [this message]
2017-03-03 15:50 ` [Qemu-devel] [PATCH for-2.9 5/6] disas/cris: " Peter Maydell
2017-03-03 15:58 ` Edgar E. Iglesias
2017-03-03 19:43 ` Philippe Mathieu-Daudé
2017-03-03 15:50 ` [Qemu-devel] [PATCH for-2.9 6/6] disas/arm: " Peter Maydell
2017-03-03 16:11 ` [Qemu-devel] [PATCH for-2.9 0/6] disas: Fix various coverity nits no-reply
2017-03-04 0:00 ` no-reply
2017-03-04 12:44 ` Peter Maydell
2017-03-06 1:03 ` Fam Zheng
2017-03-07 17:06 ` 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=20170303160601.GA9606@toto \
--to=edgar.iglesias@gmail.com \
--cc=ehabkost@redhat.com \
--cc=laurent@vivier.eu \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).