[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/2] elf-ops.h: Map into memory the ELF to load
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 1/2] elf-ops.h: Map into memory the ELF to load |
Date: |
Tue, 23 Jul 2019 10:50:24 +0100 |
On Tue, 23 Jul 2019 at 10:42, Stefano Garzarella <address@hidden> wrote:
> Reading the 'g_mapped_file_new_from_fd()' docs [1]:
> "If writable is TRUE, the mapped buffer may be modified, otherwise it is an
> error to modify the mapped buffer. Modifications to the buffer are not visible
> to other processes mapping the same file, and are not written back to the
> file."
>
> I don't know what "error" means, but reading the second part I thought
> the changes in that case were only visible at the current process.
Ah, I misread the docs here (and thought the following paragraph
which talks about changes to the underlying file becoming visible
to the mapping process was talking about changes in the mapping
process becoming visible to the file).
So I think the answer is that we do want to pass writable=true.
Looking at the implementation, we always use mmap()'s MAP_PRIVATE,
so we get a copy-on-write mapping that doesn't change the underlying
file. The effect of the 'writable' flag is that we use PROT_READ|PROT_WRITE,
so if we don't pass writable=true we're liable to get a segfault.
thanks
-- PMM
[Qemu-devel] [PATCH 2/2] hw/i386/pc: Map into memory the initrd, Stefano Garzarella, 2019/07/23