Skip to content

RFC hw/block/pflash: Mmap read-only backend files with MAP_SHARED

Philippe Mathieu-Daudé qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest3 patches 3 repliesIn review
  2. v1 RFC3 patches 7 repliesSuperseded

Changes in v2 from the cover letter

- check driver is "raw" (David)
- ignore CFI02 for now

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3exec/memory: Introduce memory_region_init_rom_device_from_file()include/exec/memory.h softmmu/memory.c+183 -00 replies
2/3hw/block/pflash: Move code aroundhw/block/pflash_cfi01.c hw/block/pflash_cfi02.c+21 -210 replies
3/3hw/block/pflash: use memory_region_init_rom_device_from_file()hw/block/pflash_cfi01.c+31 -83 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchDavid Edmondson
1/3
2/3R-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [RFC PATCH v2 0/3] hw/block/pflash: Mmap read-only backend files with MAP_SHARED

Since v1:
- check driver is "raw" (David)
- ignore CFI02 for now

Hi,

This series aims to reduce the memory footprint of flash devices when the backing file is read-only.

When a backing file is read-only, the model considers the flash is in "protected" mode. No write are allowed, but the MMIO state machine is still usable.

This series introduces a new memory region helper to mmap files and use it with the pflash device (only with read-only backing files).

The goal is to reduce QEMU's memory footprint when multiple VMs are instantiated using the same read-only backing file, which is the case with the CODE flash from OVMF and AAVMF.

Previous attempts:

- Huawei
https://www.mail-archive.com/[email protected]/msg607292.html
- Tencent
https://www.mail-archive.com/[email protected]/msg742066.html
- Oracle
https://www.mail-archive.com/[email protected]/msg760065.html

RFC because yet another approach to tackle this technical debt, and very little tested.

Regards,

Phil.

Philippe Mathieu-Daudé (3):
exec/memory: Introduce memory_region_init_rom_device_from_file() hw/block/pflash: Move code around
hw/block/pflash: use memory_region_init_rom_device_from_file()

 include/exec/memory.h   | 85 +++++++++++++++++++++++++++++++++++
 hw/block/pflash_cfi01.c | 49 +++++++++++++++------
 hw/block/pflash_cfi02.c | 18 ++++----
 softmmu/memory.c        | 98 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 228 insertions(+), 22 deletions(-)
Signature · 1 line
2.26.2