From: sundeep subbaraya <sundeep.lkml@gmail.com>
To: "Subbaraya Sundeep" <sundeep.lkml@gmail.com>,
"QEMU Developers" <qemu-devel@nongnu.org>,
qemu-arm <qemu-arm@nongnu.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Alistair Francis" <alistair23@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Darren Kenny" <darren.kenny@oracle.com>
Subject: Re: [Qemu-devel] [Qemu devel v3 PATCH] msf2: Remove dead code reported by Coverity
Date: Mon, 23 Oct 2017 08:56:00 +0530 [thread overview]
Message-ID: <CALHRZuoFkPwZ+fwCktKEC=itat0pM78jqzzSeghB+0HA2sMQfA@mail.gmail.com> (raw)
In-Reply-To: <20171022184847.xgkhvteu67ajxq3d@starbug-vm.ie.oracle.com>
Hi Darren,
On Mon, Oct 23, 2017 at 12:18 AM, Darren Kenny <darren.kenny@oracle.com>
wrote:
> On Sun, Oct 22, 2017 at 06:58:02PM +0530, Subbaraya Sundeep wrote:
>
>> Fixed incorrect frame size mask, validated maximum frame
>> size in spi_write and removed dead code.
>>
>> Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>
>> ---
>> v3:
>> Added comment that [31:6] bits are reserved in R_SPI_DFSIZE
>> register and logged incorrect value too in guest error(suggested
>> by Darren).
>> v2:
>> else if -> else in set_fifodepth
>> log guest error when frame size is more than 32
>>
>> hw/ssi/mss-spi.c | 18 ++++++++++++++----
>> 1 file changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c
>> index 5a8e308..e1b6227 100644
>> --- a/hw/ssi/mss-spi.c
>> +++ b/hw/ssi/mss-spi.c
>> @@ -76,9 +76,10 @@
>> #define C_BIGFIFO (1 << 29)
>> #define C_RESET (1 << 31)
>>
>> -#define FRAMESZ_MASK 0x1F
>> +#define FRAMESZ_MASK 0x3F
>> #define FMCOUNT_MASK 0x00FFFF00
>> #define FMCOUNT_SHIFT 8
>> +#define FRAMESZ_MAX 32
>>
>> static void txfifo_reset(MSSSpiState *s)
>> {
>> @@ -104,10 +105,8 @@ static void set_fifodepth(MSSSpiState *s)
>> s->fifo_depth = 32;
>> } else if (size <= 16) {
>> s->fifo_depth = 16;
>> - } else if (size <= 32) {
>> - s->fifo_depth = 8;
>> } else {
>> - s->fifo_depth = 4;
>> + s->fifo_depth = 8;
>> }
>> }
>>
>> @@ -301,6 +300,17 @@ static void spi_write(void *opaque, hwaddr addr,
>> if (s->enabled) {
>> break;
>> }
>> + /*
>> + * [31:6] bits are reserved bits and for future use.
>> + * [5:0] are for frame size. Only [5:0] bits are validated
>> + * during write, [31:6] bits are untouched.
>> + */
>> + if ((value & FRAMESZ_MASK) > FRAMESZ_MAX) {
>> + qemu_log_mask(LOG_GUEST_ERROR, "%s: Incorrect size %d
>> provided."
>> + "Maximum frame size is %d\n",
>> + __func__, value & FRAMESZ_MASK, FRAMESZ_MAX);
>>
>
> Nitpicking here really, but shouldn't the %d be %u since value is a
> uint32_t?
>
> Ok I will change to %u.
Thanks,
Sundeep
> Thanks,
>
> Darren.
>
>
> + break;
>> + }
>> s->regs[R_SPI_DFSIZE] = value;
>> break;
>>
>> --
>> 2.5.0
>>
>>
>>
prev parent reply other threads:[~2017-10-23 3:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-22 13:28 [Qemu-devel] [Qemu devel v3 PATCH] msf2: Remove dead code reported by Coverity Subbaraya Sundeep
2017-10-22 14:05 ` no-reply
2017-10-23 3:29 ` sundeep subbaraya
2017-10-23 5:18 ` Fam Zheng
2017-10-23 11:17 ` sundeep subbaraya
2017-10-22 18:48 ` Darren Kenny
2017-10-23 3:26 ` sundeep subbaraya [this message]
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='CALHRZuoFkPwZ+fwCktKEC=itat0pM78jqzzSeghB+0HA2sMQfA@mail.gmail.com' \
--to=sundeep.lkml@gmail.com \
--cc=alistair23@gmail.com \
--cc=crosthwaite.peter@gmail.com \
--cc=darren.kenny@oracle.com \
--cc=f4bug@amsat.org \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.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).