> On Fri, Sep 04, 2020 at 02:18:37PM +0000, Mircea CIRJALIU - MELIU wrote: > > > This seems really sketchy, get_user_pages is sensitive to the VMA, > > > what happens when VMA flags are different/etc? > > > > A debugger shouldn't complain if a portion of the debuggee is > > read-only, just overwrite the data. > > At this point the kernel API here is so incredibly limited you may as well use a > memfd for passing the shared address space instead of trying to do and > maintain this complexity. > > Your use case is only qemu, so what is the problem to replace the allocator > backing VM memory in userspace? Other people have been talking about > doing a memfd already for different reasons - and memfd can already be > shared as this scheme desires. KSM doesn't work on shmem. Once you replace the allocator you render KSM useless. Besides that, I had a mail once from Paolo Bonzini: >> Hi, >> >> here at FOSDEM we discussed having a way for a parent process to >> split parts of an mmap range with one or more child processes. This >> turns out to be a generalization of the remote memory mapping concept >> that BitDefender proposed for virtual machine introspection ( >> https://patchwork.kernel.org/patch/11284561/). So far the patches >> haven't had a great reception from the MM people, but it shouldn't be >> hard to adjust the API according to the sketch below. I am also >> including Mircea who is the author. >> >> The proposed API is a new pidfd system call, through which the parent >> can map portions of its virtual address space into a file descriptor >> and then pass that file descriptor to a child. (the rest can be found in the cover letter) Therefore I had to do a module that peeks into anon process memory. And be compatible with KSM. This was among the requirements for the first version of remote mapping, which ended up non-scalable. Figures out it can peek into any kind of memory involving pages. Also it doesn't have the overhead associated with mapping a page in a VMA. And compared to ptrace(), it can keep the pages resident as long as needed. Mircea