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.edmond...@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.