[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v2 3/3] hw/pflash_cfi01: Allow devices to have a smaller
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [RFC PATCH v2 3/3] hw/pflash_cfi01: Allow devices to have a smaller backing device |
Date: |
Mon, 22 Feb 2021 15:06:35 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 |
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.
> 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?
Thanks,
Phil.