qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeuk Kim <jeuk20.kim@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, "Jeuk Kim" <jeuk20.kim@samsung.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	qemu-block@nongnu.org, "Kevin Wolf" <kwolf@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>, "Fam Zheng" <fam@euphon.net>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [PULL 3/5] hw/ufs: Support for Query Transfer Requests
Date: Fri, 15 Sep 2023 07:28:10 +0900	[thread overview]
Message-ID: <da63cc27-2ac9-9d45-52c9-5ad1a0962f9c@gmail.com> (raw)
In-Reply-To: <CAFEAcA8K=TxoqUV-XK+_5KvmKxc+ue7rZ28Sd_yY=V_TVxmMcw@mail.gmail.com>


On 23. 9. 14. 23:40, Peter Maydell wrote:
> On Thu, 7 Sept 2023 at 19:17, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>> From: Jeuk Kim <jeuk20.kim@samsung.com>
>>
>> This commit makes the UFS device support query
>> and nop out transfer requests.
>>
>> The next patch would be support for UFS logical
>> unit and scsi command transfer request.
>>
>> Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com>
>> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>> Message-id: ff7a5f0fd26761936a553ffb89d3df0ba62844e9.1693980783.git.jeuk20.kim@gmail.com
>> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>> ---
>>   hw/ufs/ufs.h        |  46 +++
>>   hw/ufs/ufs.c        | 988 +++++++++++++++++++++++++++++++++++++++++++-
>>   hw/ufs/trace-events |   1 +
>>   3 files changed, 1033 insertions(+), 2 deletions(-)
> Hi; Coverity isn't happy about the code in this function
> (CID 1519050). The code isn't strictly wrong, but it's
> probably possible to make it a bit more clearly correct.
>
>> +static void ufs_process_db(UfsHc *u, uint32_t val)
>> +{
>> +    unsigned long doorbell;
>> +    uint32_t slot;
>> +    uint32_t nutrs = u->params.nutrs;
>> +    UfsRequest *req;
>> +
>> +    val &= ~u->reg.utrldbr;
>> +    if (!val) {
>> +        return;
>> +    }
>> +
>> +    doorbell = val;
>> +    slot = find_first_bit(&doorbell, nutrs);
> Here we pass the address of a single 'unsigned long' to
> find_first_bit(). That function operates on arrays, so
> unless nutrs is guaranteed to be less than 32 this might
> walk off the end of memory.
>
> There is a check on params.nutrs in ufs_check_constraints(),
> which checks for "> UFS_MAX_NUTRS" and that value is 32,
> so this won't actually overflow, but Coverity can't
> see that check and in any case what it really doesn't
> like here is the passing of the address of a 'long'
> variable to a function that is prototyped as taking
> an array of longs.
>
> You can probably make Coverity happy by defining
> doorbell here as a 1 element array, and asserting
> that nutrs is 32 or less. Alternatively, we have
> ctz32() for working through bits in a uint32_t, though
> that is a bit lower-level than find_first_bit/find_next_bit.
>
>> +
>> +    while (slot < nutrs) {
>> +        req = &u->req_list[slot];
>> +        if (req->state == UFS_REQUEST_ERROR) {
>> +            trace_ufs_err_utrl_slot_error(req->slot);
>> +            return;
>> +        }
>> +
>> +        if (req->state != UFS_REQUEST_IDLE) {
>> +            trace_ufs_err_utrl_slot_busy(req->slot);
>> +            return;
>> +        }
>> +
>> +        trace_ufs_process_db(slot);
>> +        req->state = UFS_REQUEST_READY;
>> +        slot = find_next_bit(&doorbell, nutrs, slot + 1);
>> +    }
>> +
>> +    qemu_bh_schedule(u->doorbell_bh);
>> +}
> thanks
> -- PMM
>

Thank you for letting me know about the coverity issue with a detailed 
description!

I have checked all the coverity issues related to ufs.
(cid 1519042, cid 1519043, cid 1519050, cid 1519051)

I will fix them with an additional patch as soon as possible.

Thank you!

Jeuk



  reply	other threads:[~2023-09-14 22:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07 18:16 [PULL 0/5] Block patches Stefan Hajnoczi
2023-09-07 18:16 ` [PULL 1/5] iothread: Set the GSource "name" field Stefan Hajnoczi
2023-09-07 18:16 ` [PULL 2/5] hw/ufs: Initial commit for emulated Universal-Flash-Storage Stefan Hajnoczi
2023-09-07 18:16 ` [PULL 3/5] hw/ufs: Support for Query Transfer Requests Stefan Hajnoczi
2023-09-14 14:40   ` Peter Maydell
2023-09-14 22:28     ` Jeuk Kim [this message]
2023-09-07 18:16 ` [PULL 4/5] hw/ufs: Support for UFS logical unit Stefan Hajnoczi
2023-09-14 14:27   ` Peter Maydell
2023-09-14 14:47   ` Peter Maydell
2023-09-14 17:31   ` Paolo Bonzini
2023-09-14 22:19     ` Jeuk Kim
2023-09-15  7:59       ` Paolo Bonzini
2023-09-18  4:41         ` Jeuk Kim
2023-09-18  4:52           ` Jeuk Kim
2023-09-21  8:38         ` Jeuk Kim
2023-10-04  1:18           ` Ping: " Jeuk Kim
2023-09-07 18:16 ` [PULL 5/5] tests/qtest: Introduce tests for UFS Stefan Hajnoczi
2023-09-08 15:55 ` [PULL 0/5] Block patches Stefan Hajnoczi

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=da63cc27-2ac9-9d45-52c9-5ad1a0962f9c@gmail.com \
    --to=jeuk20.kim@gmail.com \
    --cc=berrange@redhat.com \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=jeuk20.kim@samsung.com \
    --cc=kwolf@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /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).