From: Glauber Costa <gcosta@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm-devel@lists.sourceforge.net
Subject: [Qemu-devel] [PATCH 03/13] [PATCH] introduce QEMUAccel and fill it with interrupt specific driver
Date: Thu, 15 May 2008 11:09:23 -0300 [thread overview]
Message-ID: <12108605883967-git-send-email-gcosta@redhat.com> (raw)
In-Reply-To: <12108605843020-git-send-email-gcosta@redhat.com>
This patch introduces QEMUAccel, a placeholder for function pointers
that aims at helping qemu to abstract accelerators such as kqemu and
kvm (actually, the 'accelerator' name was proposed by avi kivity, since
he loves referring to kvm that way).
To begin with, the accelerator is given the opportunity to register a
cpu_interrupt function, to be called after the raw cpu_interrupt.
This has the side effect of, for the kqemu accelerator, calling kqemu_cpu_interrupt
everytime, which didn't use to happen. But looking at the code, this seems safe to me.
This patch applies on raw qemu.
---
block-raw-posix.c | 5 -----
exec-all.h | 18 +++++++++++++++++-
exec.c | 2 ++
kqemu.c | 27 +++++++++++++++++----------
vl.c | 6 +-----
5 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/block-raw-posix.c b/block-raw-posix.c
index 6b0009e..61c23ba 100644
--- a/block-raw-posix.c
+++ b/block-raw-posix.c
@@ -250,11 +250,6 @@ static void aio_signal_handler(int signum)
if (env) {
/* stop the currently executing cpu because a timer occured */
cpu_interrupt(env, CPU_INTERRUPT_EXIT);
-#ifdef USE_KQEMU
- if (env->kqemu_enabled) {
- kqemu_cpu_interrupt(env);
- }
-#endif
}
#endif
}
diff --git a/exec-all.h b/exec-all.h
index 8c32858..7b2d97d 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -578,6 +578,23 @@ static inline target_ulong get_phys_addr_code(CPUState *env1, target_ulong addr)
}
#endif
+typedef struct QEMUAccel {
+ void (*cpu_interrupt)(CPUState *env);
+} QEMUAccel;
+
+extern QEMUAccel *current_accel;
+
+static inline void register_qemu_accel(QEMUAccel *accel)
+{
+ current_accel = accel;
+}
+
+static inline void accel_cpu_interrupt(CPUState *env)
+{
+ if (current_accel && current_accel->cpu_interrupt)
+ current_accel->cpu_interrupt(env);
+}
+
#ifdef USE_KQEMU
#define KQEMU_MODIFY_PAGE_MASK (0xff & ~(VGA_DIRTY_FLAG | CODE_DIRTY_FLAG))
@@ -587,7 +604,6 @@ void kqemu_flush_page(CPUState *env, target_ulong addr);
void kqemu_flush(CPUState *env, int global);
void kqemu_set_notdirty(CPUState *env, ram_addr_t ram_addr);
void kqemu_modify_page(CPUState *env, ram_addr_t ram_addr);
-void kqemu_cpu_interrupt(CPUState *env);
void kqemu_record_dump(void);
static inline int kqemu_is_ok(CPUState *env)
diff --git a/exec.c b/exec.c
index dfedfc3..73360d3 100644
--- a/exec.c
+++ b/exec.c
@@ -1256,6 +1256,8 @@ void cpu_interrupt(CPUState *env, int mask)
tb_reset_jump_recursive(tb);
resetlock(&interrupt_lock);
}
+
+ accel_cpu_interrupt(env);
}
void cpu_reset_interrupt(CPUState *env, int mask)
diff --git a/kqemu.c b/kqemu.c
index 0e38d52..f875e0e 100644
--- a/kqemu.c
+++ b/kqemu.c
@@ -159,6 +159,8 @@ static void kqemu_update_cpuid(CPUState *env)
accelerated code */
}
+QEMUAccel kqemu_accel;
+
int kqemu_start(void)
{
struct kqemu_init init;
@@ -240,6 +242,7 @@ int kqemu_start(void)
}
nb_pages_to_flush = 0;
nb_ram_pages_to_update = 0;
+ register_qemu_accel(&kqemu_accel);
return 0;
}
@@ -249,6 +252,20 @@ void kqemu_init_env(CPUState *env)
env->kqemu_enabled = kqemu_allowed;
}
+void kqemu_cpu_interrupt(CPUState *env)
+{
+#if defined(_WIN32) && KQEMU_VERSION >= 0x010101
+ /* cancelling the I/O request causes KQEMU to finish executing the
+ current block and successfully returning. */
+ CancelIo(kqemu_fd);
+#endif
+}
+
+QEMUAccel kqemu_accel = {
+ .cpu_interrupt = kqemu_cpu_interrupt,
+};
+
+
void kqemu_flush_page(CPUState *env, target_ulong addr)
{
#if defined(DEBUG)
@@ -906,14 +923,4 @@ int kqemu_cpu_exec(CPUState *env)
}
return 0;
}
-
-void kqemu_cpu_interrupt(CPUState *env)
-{
-#if defined(_WIN32) && KQEMU_VERSION >= 0x010101
- /* cancelling the I/O request causes KQEMU to finish executing the
- current block and successfully returning. */
- CancelIo(kqemu_fd);
-#endif
-}
-
#endif
diff --git a/vl.c b/vl.c
index 5999b37..26c1677 100644
--- a/vl.c
+++ b/vl.c
@@ -239,6 +239,7 @@ struct drive_opt {
static CPUState *cur_cpu;
static CPUState *next_cpu;
static int event_pending = 1;
+QEMUAccel *current_accel;
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
@@ -1199,11 +1200,6 @@ static void host_alarm_handler(int host_signum)
if (env) {
/* stop the currently executing cpu because a timer occured */
cpu_interrupt(env, CPU_INTERRUPT_EXIT);
-#ifdef USE_KQEMU
- if (env->kqemu_enabled) {
- kqemu_cpu_interrupt(env);
- }
-#endif
}
event_pending = 1;
}
--
1.5.5
next prev parent reply other threads:[~2008-05-15 14:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-15 14:09 [Qemu-devel] [PATCH 0/13] New shot at QEMUAccel Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 01/13] [PATCH] make cpu_exec_init symmetric Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 02/13] [PATCH] split kqemu_init into two Glauber Costa
2008-05-15 14:09 ` Glauber Costa [this message]
2008-05-15 14:09 ` [Qemu-devel] [PATCH 04/13] [PATCH] init env made accel driver Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 05/13] [PATCH] wrap cache flushing functions into accel drivers Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 06/13] [PATCH] turn info kqemu into generic info accelerator Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 07/13] [PATCH] separate accelerator part of info profiler Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 08/13] [PATCH] move kqemu externs to kqemu.h Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 09/13] [PATCH] move disabling code to kqemu.c instead of vl.c Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 10/13] [PATCH] set_notdirty goes through accel wrapper Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 11/13] [PATCH] wrap modify_page through accel calls Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 12/13] [PATCH] remove kqemu reference from hw/pc.c Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 13/13] [PATCH] build list of available accelerators Glauber Costa
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=12108605883967-git-send-email-gcosta@redhat.com \
--to=gcosta@redhat.com \
--cc=kvm-devel@lists.sourceforge.net \
--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).