From: Jason Wang <jasowang@redhat.com>
To: "Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Helge Deller <deller@gmx.de>,
Sven Schnelle <svens@stackframe.org>,
QEMU Developers <qemu-devel@nongnu.org>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH] hw/net/i82596: Correct command bitmask (CID 1419392)
Date: Tue, 17 Mar 2020 13:51:16 +0800 [thread overview]
Message-ID: <cbc557d0-a32d-af1c-33d8-c6177dca2883@redhat.com> (raw)
In-Reply-To: <CAFEAcA9CdtrbTTFAkngP90jNaSALVN2svOx75qLORhLKGUoUUA@mail.gmail.com>
On 2020/3/13 下午7:01, Peter Maydell wrote:
> On Fri, 14 Feb 2020 at 00:48, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>> The command is 32-bit, but we are loading the 16 upper bits with
>> the 'get_uint16(s->scb + 2)' call.
>>
>> Once shifted by 16, the command bits match the status bits:
>>
>> - Command
>> Bit 31 ACK-CX Acknowledges that the CU completed an Action Command.
>> Bit 30 ACK-FR Acknowledges that the RU received a frame.
>> Bit 29 ACK-CNA Acknowledges that the Command Unit became not active.
>> Bit 28 ACK-RNR Acknowledges that the Receive Unit became not ready.
>>
>> - Status
>> Bit 15 CX The CU finished executing a command with its I(interrupt) bit set.
>> Bit 14 FR The RU finished receiving a frame.
>> Bit 13 CNA The Command Unit left the Active state.
>> Bit 12 RNR The Receive Unit left the Ready state.
>>
>> Add the SCB_COMMAND_ACK_MASK definition to simplify the code.
>>
>> This fixes Coverity 1419392 (CONSTANT_EXPRESSION_RESULT):
>>
>> /hw/net/i82596.c: 352 in examine_scb()
>> 346 cuc = (command >> 8) & 0x7;
>> 347 ruc = (command >> 4) & 0x7;
>> 348 DBG(printf("MAIN COMMAND %04x cuc %02x ruc %02x\n", command, cuc, ruc));
>> 349 /* and clear the scb command word */
>> 350 set_uint16(s->scb + 2, 0);
>> 351
>> >>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
>> >>> "command & (2147483648UL /* 1UL << 31 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
>> 352 if (command & BIT(31)) /* ACK-CX */
>> 353 s->scb_status &= ~SCB_STATUS_CX;
>> >>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
>> >>> "command & (1073741824UL /* 1UL << 30 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
>> 354 if (command & BIT(30)) /*ACK-FR */
>> 355 s->scb_status &= ~SCB_STATUS_FR;
>> >>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
>> >>> "command & (536870912UL /* 1UL << 29 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
>> 356 if (command & BIT(29)) /*ACK-CNA */
>> 357 s->scb_status &= ~SCB_STATUS_CNA;
>> >>> CID 1419392: (CONSTANT_EXPRESSION_RESULT)
>> >>> "command & (268435456UL /* 1UL << 28 */)" is always 0 regardless of the values of its operands. This occurs as the logical operand of "if".
>> 358 if (command & BIT(28)) /*ACK-RNR */
>> 359 s->scb_status &= ~SCB_STATUS_RNR;
>>
>> Fixes: Covertiy CID 1419392 (commit 376b851909)
> ("Coverity")
>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> Jason, are you planning to pick this one up?
Yes. queued.
Thanks
> thanks
> -- PMM
>
prev parent reply other threads:[~2020-03-17 5:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 0:47 [PATCH] hw/net/i82596: Correct command bitmask (CID 1419392) Philippe Mathieu-Daudé
2020-03-13 11:01 ` Peter Maydell
2020-03-17 5:51 ` Jason Wang [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=cbc557d0-a32d-af1c-33d8-c6177dca2883@redhat.com \
--to=jasowang@redhat.com \
--cc=deller@gmx.de \
--cc=f4bug@amsat.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=svens@stackframe.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).