From: Jan Kiszka <jan.kiszka@web.de>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Avi Kivity <avi@redhat.com>, Gleb Natapov <gleb@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] kvm: Avoid COW if KVM MMU is asynchronous
Date: Sun, 26 Apr 2009 14:21:13 +0200 [thread overview]
Message-ID: <49F451B9.8040205@web.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 1203 bytes --]
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 <jan.kiszka@siemens.com>
---
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 = ram_blocks;
ram_blocks = new_block;
+ if (kvm_enabled() && !kvm_has_sync_mmu()) {
+#ifdef MADV_DONTFORK
+ int ret = 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 = qemu_realloc(phys_ram_dirty,
(last_ram_offset + size) >> TARGET_PAGE_BITS);
memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS),
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
next reply other threads:[~2009-04-26 12:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-26 12:21 Jan Kiszka [this message]
2009-04-26 13:08 ` [Qemu-devel] [PATCH] kvm: Avoid COW if KVM MMU is asynchronous Avi Kivity
2009-04-26 16:03 ` [Qemu-devel] [PATCH v2] " Jan Kiszka
2009-04-26 16:21 ` Avi Kivity
2009-04-26 16:44 ` [Qemu-devel] [PATCH v3] " Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49F451B9.8040205@web.de \
--to=jan.kiszka@web.de \
--cc=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).