On Fri, Sep 04, 2020 at 03:40:55PM +0000, Mircea CIRJALIU - MELIU wrote: > > 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. I suspect making memfd to work with KSM will be much less hacky than this. > Figures out it can peek into any kind of memory involving pages. No, this approach is really liminted to anonymous VMAs. You might make some argument that VMA differences can be ignored if they are all anonymous to start with, but certainly not once other types are VMAs are included. Jason