kvm: qemu: mark guest mapping as MADV_DONTFORK
commit52896bd9c819c71a411d56416a45087c7df0df19
authorMarcelo Tosatti <mtosatti@redhat.com>
Fri, 22 Aug 2008 23:03:35 +0000 (22 20:03 -0300)
committerAvi Kivity <avi@qumranet.com>
Mon, 25 Aug 2008 10:20:36 +0000 (25 13:20 +0300)
treea4a3f53e5ba2976cd32d5c8072149a9bbf208152
parent501797e19c7282e9579686bd80feff3754a7ccca
kvm: qemu: mark guest mapping as MADV_DONTFORK

When qemu fork's (ssh migration, qemu-nbd, slirp), the guest memory
mapping becomes shared and write-protected by parent and child, until
execve switches to a new mm.

get_user_pages with force=1 parameter will break COW during this window,
leaving stale shadow mappings that point to the previously shared page.

Fix this by madvising the range as MADV_DONTFORK, if mmu notifiers are
disabled.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
qemu/qemu-kvm.c
qemu/qemu-kvm.h
qemu/vl.c