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
