[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/3] memory: add readonly support to memory_region_init_ram_f
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH 1/3] memory: add readonly support to memory_region_init_ram_from_file() |
Date: |
Tue, 4 Aug 2020 14:47:56 +0100 |
On Tue, Aug 04, 2020 at 02:26:22PM +0200, Philippe Mathieu-Daudé wrote:
> On 8/4/20 2:25 PM, Philippe Mathieu-Daudé wrote:
> > Hi Stefan,
> >
> > On 8/4/20 12:12 PM, Stefan Hajnoczi wrote:
> >> There is currently no way to open(O_RDONLY) and mmap(PROT_READ) when
> >> creating a memory region from a file. This functionality is needed since
> >> the underlying host file may not allow writing.
> >>
> >> Add a bool readonly argument to memory_region_init_ram_from_file() and
> >> the APIs it calls.
> >>
> >> Extend memory_region_init_ram_from_file() rather than introducing a
> >> memory_region_init_rom_from_file() API so that callers can easily make a
> >> choice between read/write and read-only at runtime without calling
> >> different APIs.
> >
> > What happens if we call:
> >
> > memory_region_init_ram_from_file(mr, ..., readonly=false, ...);
> > memory_region_set_readonly(mr, false);
>
> In case my error is not obvious, I meant:
>
> memory_region_init_ram_from_file(mr, ..., readonly=true, ...);
> memory_region_set_readonly(mr, false);
Since the mmap was made using PROT_READ any store instructions to the
memory will fault.
Is there some scenario where memory_region_set_readonly() is called? I
can't find one.
Stefan
signature.asc
Description: PGP signature
[PATCH 2/3] hostmem-file: add readonly=on|off option, Stefan Hajnoczi, 2020/08/04
[PATCH 3/3] nvdimm: honor -object memory-backend-file, readonly=on option, Stefan Hajnoczi, 2020/08/04
Re: [PATCH 0/3] nvdimm: read-only file support, Michael S. Tsirkin, 2020/08/04
Re: [PATCH 0/3] nvdimm: read-only file support, Stefan Hajnoczi, 2020/08/21