Re: [RFC PATCH 0/5] madvise MADV_DOEXEC

Christian Brauner
2020-07-28T13:40:30Z

On Mon, Jul 27, 2020 at 02:00:17PM -0400, Steven Sistare wrote:
> On 7/27/2020 1:07 PM, ebiederm@xmission.com wrote:
> > Anthony Yznaga <anthony.yznaga@oracle.com> writes:
> >
> >> This patchset adds support for preserving an anonymous memory range across
> >> exec(3) using a new madvise MADV_DOEXEC argument. The primary benefit for
> >> sharing memory in this manner, as opposed to re-attaching to a named shared
> >> memory segment, is to ensure it is mapped at the same virtual address in
> >> the new process as it was in the old one. An intended use for this is to
> >> preserve guest memory for guests using vfio while qemu exec's an updated
> >> version of itself. By ensuring the memory is preserved at a fixed address,
> >> vfio mappings and their associated kernel data structures can remain valid.
> >> In addition, for the qemu use case, qemu instances that back guest RAM with
> >> anonymous memory can be updated.
> >
> > What is wrong with using a file descriptor to a possibly deleted file
> > and re-mmaping it?
> >
> > There is already MAP_FIXED that allows you to ensure you have the same
> > address.
>
> MAP_FIXED blows away any existing mapping in that range, which is not the
> desired behavior. We want to preserve the previously created mapping at

There's also MAP_FIXED_NOREPLACE since v4.17 in case that helps.

Note that this should really go to linux-api too. I won't argue to
resend it since that would mean spamming everyone's inbox with the same
thread again but in case you send a revised version, please ensure to Cc
linux-api. The glibc folks are listening on there too.

Thanks!
Christian