From: Scott Wood <scottwood@freescale.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] KVM: flush icache after writing to RAM
Date: Fri, 8 Apr 2011 13:00:29 -0500 [thread overview]
Message-ID: <20110408180028.GA22376@schlenkerla.am.freescale.net> (raw)
This is required so that the guest does not execute any stale
instructions.
qemu-kvm does this in cpu_physical_memory_rw, but not in
cpu_physical_memory_write_rom.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
exec.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/exec.c b/exec.c
index 983c0db..055d304 100644
--- a/exec.c
+++ b/exec.c
@@ -33,6 +33,7 @@
#include "osdep.h"
#include "kvm.h"
#include "qemu-timer.h"
+#include "cache-utils.h"
#if defined(CONFIG_USER_ONLY)
#include <qemu.h>
#include <signal.h>
@@ -3768,6 +3769,12 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
cpu_physical_memory_set_dirty_flags(
addr1, (0xff & ~CODE_DIRTY_FLAG));
}
+ /* qemu doesn't execute guest code directly, but kvm does
+ therefore flush instruction caches */
+ if (kvm_enabled()) {
+ flush_icache_range((unsigned long)ptr,
+ (unsigned long)ptr + l);
+ }
}
} else {
if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM &&
@@ -3838,6 +3845,13 @@ void cpu_physical_memory_write_rom(target_phys_addr_t addr,
/* ROM/RAM case */
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
+
+ /* qemu doesn't execute guest code directly, but kvm does
+ therefore flush instruction caches */
+ if (kvm_enabled()) {
+ flush_icache_range((unsigned long)ptr,
+ (unsigned long)ptr + l);
+ }
}
len -= l;
buf += l;
--
1.7.1
reply other threads:[~2011-04-08 18:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20110408180028.GA22376@schlenkerla.am.freescale.net \
--to=scottwood@freescale.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).