qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Edmondson <dme@dme.org>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [RFC PATCH v2 3/3] hw/pflash_cfi01: Allow devices to have a smaller backing device
Date: Mon, 22 Feb 2021 14:31:05 +0000	[thread overview]
Message-ID: <cunblccw4wm.fsf@dme.org> (raw)
In-Reply-To: <012fce58-9543-eb63-0358-a0b3f135f6c2@redhat.com>

On Monday, 2021-02-22 at 15:06:35 +01, Philippe Mathieu-Daudé wrote:

> Hi David,
>
> On 2/22/21 10:07 AM, David Edmondson wrote:
>> Allow the backing device to be smaller than the extent of the flash
>> device by mapping it as a subregion of the flash device region.
>> 
>> Return zeroes for all reads of the flash device beyond the extent of
>> the backing device.
>> 
>> For writes beyond the extent of the underlying device, fail on
>> read-only devices and discard them for writable devices.
>
> This looks much simpler now.

Thanks for looking at it.

>> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
>> ---
>>  hw/block/pflash_cfi01.c | 108 ++++++++++++++++++++++++++++++----------
>>  hw/block/trace-events   |   3 ++
>>  2 files changed, 86 insertions(+), 25 deletions(-)
>
>>      if (pfl->blk) {
>>          uint64_t perm;
>> +
>>          pfl->ro = !blk_supports_write_perm(pfl->blk);
>>          perm = BLK_PERM_CONSISTENT_READ | (pfl->ro ? 0 : BLK_PERM_WRITE);
>>          ret = blk_set_perm(pfl->blk, perm, BLK_PERM_ALL, errp);
>>          if (ret < 0) {
>>              return;
>>          }
>> +
>> +        inner_len = blk_getlength(pfl->blk);
>> +
>> +        if (inner_len > outer_len) {
>> +            error_setg(errp,
>> +                       "block backend provides %" HWADDR_PRIu " bytes, "
>> +                       "device limited to %" PRIu64 " bytes",
>> +                       inner_len, outer_len);
>> +            return;
>> +        }
>
> Do you mind extracting this change in a previous patch?

Before this change that test was performed by
blk_check_size_and_read_all(), which insisted that the block device was
exactly the same size as the region (because it was told to read enough
bytes to fill the region).

Now that we pass the size of the backing device to that function, rather
than the size of the region, it's necessary to add the extra check
before the call.

Hence, I don't think that it's useful to add this as an earlier patch.

It would perhaps make sense to switch away from
blk_check_size_and_read_all(), preferring to just call blk_pread() now,
which would be cleaner?

dme.
-- 
Do I have to tell the story, of a thousand rainy days since we first met?


      reply	other threads:[~2021-02-22 14:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22  9:07 [RFC PATCH v2 0/3] hw/flash_cfi01: Reduce memory consumption when flash image is smaller than region David Edmondson
2021-02-22  9:07 ` [RFC PATCH v2 1/3] hw/pflash_cfi*: Replace DPRINTF with trace events David Edmondson
2021-02-22 13:59   ` Philippe Mathieu-Daudé
2021-02-22  9:07 ` [RFC PATCH v2 2/3] hw/pflash_cfi01: Correct the type of PFlashCFI01.ro David Edmondson
2021-02-22 13:59   ` Philippe Mathieu-Daudé
2021-02-22  9:07 ` [RFC PATCH v2 3/3] hw/pflash_cfi01: Allow devices to have a smaller backing device David Edmondson
2021-02-22 14:06   ` Philippe Mathieu-Daudé
2021-02-22 14:31     ` David Edmondson [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=cunblccw4wm.fsf@dme.org \
    --to=dme@dme.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@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).