From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ly3MM-0006vU-Fw for qemu-devel@nongnu.org; Sun, 26 Apr 2009 08:21:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ly3MH-0006vI-Vr for qemu-devel@nongnu.org; Sun, 26 Apr 2009 08:21:25 -0400 Received: from [199.232.76.173] (port=46471 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ly3MH-0006vF-QL for qemu-devel@nongnu.org; Sun, 26 Apr 2009 08:21:21 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:46200) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ly3MH-00080Z-7i for qemu-devel@nongnu.org; Sun, 26 Apr 2009 08:21:21 -0400 Message-ID: <49F451B9.8040205@web.de> Date: Sun, 26 Apr 2009 14:21:13 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig2E68CD50A648A4CE1F670B9A" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH] kvm: Avoid COW if KVM MMU is asynchronous List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Avi Kivity , Gleb Natapov , qemu-devel This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig2E68CD50A648A4CE1F670B9A Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable If the KVM MMU is asynchronous (kernel does not support MMU_NOTIFIER), we have to avoid COW for the guest memory. Otherwise we risk serious breakage when guest pages change there physical locations due to COW after fork. Seen when forking smbd during runtime via -smb. Signed-off-by: Jan Kiszka --- exec.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/exec.c b/exec.c index 23013fb..ce0603e 100644 --- a/exec.c +++ b/exec.c @@ -2477,6 +2477,20 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size) new_block->next =3D ram_blocks; ram_blocks =3D new_block; =20 + if (kvm_enabled() && !kvm_has_sync_mmu()) { +#ifdef MADV_DONTFORK + int ret =3D madvise(new_block->host, size, MADV_DONTFORK); + if (ret) { + perror("madvice"); + exit(1); + } +#else + fprintf(stderr, + "Need MADV_DONTFORK in absence of synchronous KVM MMU\n"= ); + exit(1); +#endif + } + phys_ram_dirty =3D qemu_realloc(phys_ram_dirty, (last_ram_offset + size) >> TARGET_PAGE_BITS); memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS), --------------enig2E68CD50A648A4CE1F670B9A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkn0Ub4ACgkQniDOoMHTA+kdswCaAzoix3XRB9cX/fuTUUkfVjef iPcAni2vpDtbSmZfVsSn2EjlyMJF60HW =qgk8 -----END PGP SIGNATURE----- --------------enig2E68CD50A648A4CE1F670B9A--