qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] [uq/master] Patch queue, part VI (interrupt disentangling)
@ 2011-03-18 12:19 Jan Kiszka
  2011-03-18 12:19 ` [Qemu-devel] [PATCH 1/3] Break up user and system cpu_interrupt implementations Jan Kiszka
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jan Kiszka @ 2011-03-18 12:19 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: Riku Voipio, qemu-devel, kvm

Repost of the remaining three patches from part V. No functional
changes, I just updated the commit log for reflect their complete
rationale.

CC: Riku Voipio <riku.voipio@iki.fi>

Jan Kiszka (3):
  Break up user and system cpu_interrupt implementations
  Redirect cpu_interrupt to callback handler
  kvm: Install specialized interrupt handler

 cpu-all.h |   14 +++++++++++++-
 exec.c    |   18 +++++++++++++-----
 kvm-all.c |   11 +++++++++++
 3 files changed, 37 insertions(+), 6 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 1/3] Break up user and system cpu_interrupt implementations
  2011-03-18 12:19 [Qemu-devel] [PATCH 0/3] [uq/master] Patch queue, part VI (interrupt disentangling) Jan Kiszka
@ 2011-03-18 12:19 ` Jan Kiszka
  2011-03-18 12:19 ` [Qemu-devel] [PATCH 2/3] Redirect cpu_interrupt to callback handler Jan Kiszka
  2011-03-18 12:19 ` [Qemu-devel] [PATCH 3/3] kvm: Install specialized interrupt handler Jan Kiszka
  2 siblings, 0 replies; 5+ messages in thread
From: Jan Kiszka @ 2011-03-18 12:19 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: Riku Voipio, qemu-devel, kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

Both have only two lines in common, and we will convert the system
service into a callback which is of no use for user mode operation.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Riku Voipio <riku.voipio@iki.fi>
---
 exec.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/exec.c b/exec.c
index 964ce31..4721f04 100644
--- a/exec.c
+++ b/exec.c
@@ -1630,6 +1630,7 @@ static void cpu_unlink_tb(CPUState *env)
     spin_unlock(&interrupt_lock);
 }
 
+#ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
 void cpu_interrupt(CPUState *env, int mask)
 {
@@ -1638,7 +1639,6 @@ void cpu_interrupt(CPUState *env, int mask)
     old_mask = env->interrupt_request;
     env->interrupt_request |= mask;
 
-#ifndef CONFIG_USER_ONLY
     /*
      * If called from iothread context, wake the target cpu in
      * case its halted.
@@ -1647,21 +1647,27 @@ void cpu_interrupt(CPUState *env, int mask)
         qemu_cpu_kick(env);
         return;
     }
-#endif
 
     if (use_icount) {
         env->icount_decr.u16.high = 0xffff;
-#ifndef CONFIG_USER_ONLY
         if (!can_do_io(env)
             && (mask & ~old_mask) != 0) {
             cpu_abort(env, "Raised interrupt while not in I/O function");
         }
-#endif
     } else {
         cpu_unlink_tb(env);
     }
 }
 
+#else /* CONFIG_USER_ONLY */
+
+void cpu_interrupt(CPUState *env, int mask)
+{
+    env->interrupt_request |= mask;
+    cpu_unlink_tb(env);
+}
+#endif /* CONFIG_USER_ONLY */
+
 void cpu_reset_interrupt(CPUState *env, int mask)
 {
     env->interrupt_request &= ~mask;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 2/3] Redirect cpu_interrupt to callback handler
  2011-03-18 12:19 [Qemu-devel] [PATCH 0/3] [uq/master] Patch queue, part VI (interrupt disentangling) Jan Kiszka
  2011-03-18 12:19 ` [Qemu-devel] [PATCH 1/3] Break up user and system cpu_interrupt implementations Jan Kiszka
@ 2011-03-18 12:19 ` Jan Kiszka
  2011-03-28 14:46   ` [Qemu-devel] " Marcelo Tosatti
  2011-03-18 12:19 ` [Qemu-devel] [PATCH 3/3] kvm: Install specialized interrupt handler Jan Kiszka
  2 siblings, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2011-03-18 12:19 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: qemu-devel, kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

This allows to override the interrupt handling of QEMU in system mode.
KVM will make use of it to set a specialized handler.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 cpu-all.h |   14 +++++++++++++-
 exec.c    |    4 +++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index 4f4631d..5835cfa 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -790,7 +790,19 @@ extern CPUState *cpu_single_env;
 #define CPU_INTERRUPT_SIPI   0x800 /* SIPI pending. */
 #define CPU_INTERRUPT_MCE    0x1000 /* (x86 only) MCE pending. */
 
-void cpu_interrupt(CPUState *s, int mask);
+#ifndef CONFIG_USER_ONLY
+typedef void (*CPUInterruptHandler)(CPUState *, int);
+
+extern CPUInterruptHandler cpu_interrupt_handler;
+
+static inline void cpu_interrupt(CPUState *s, int mask)
+{
+    cpu_interrupt_handler(s, mask);
+}
+#else /* USER_ONLY */
+void cpu_interrupt(CPUState *env, int mask);
+#endif /* USER_ONLY */
+
 void cpu_reset_interrupt(CPUState *env, int mask);
 
 void cpu_exit(CPUState *s);
diff --git a/exec.c b/exec.c
index 4721f04..0c80f84 100644
--- a/exec.c
+++ b/exec.c
@@ -1632,7 +1632,7 @@ static void cpu_unlink_tb(CPUState *env)
 
 #ifndef CONFIG_USER_ONLY
 /* mask must never be zero, except for A20 change call */
-void cpu_interrupt(CPUState *env, int mask)
+static void tcg_handle_interrupt(CPUState *env, int mask)
 {
     int old_mask;
 
@@ -1659,6 +1659,8 @@ void cpu_interrupt(CPUState *env, int mask)
     }
 }
 
+CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
+
 #else /* CONFIG_USER_ONLY */
 
 void cpu_interrupt(CPUState *env, int mask)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 3/3] kvm: Install specialized interrupt handler
  2011-03-18 12:19 [Qemu-devel] [PATCH 0/3] [uq/master] Patch queue, part VI (interrupt disentangling) Jan Kiszka
  2011-03-18 12:19 ` [Qemu-devel] [PATCH 1/3] Break up user and system cpu_interrupt implementations Jan Kiszka
  2011-03-18 12:19 ` [Qemu-devel] [PATCH 2/3] Redirect cpu_interrupt to callback handler Jan Kiszka
@ 2011-03-18 12:19 ` Jan Kiszka
  2 siblings, 0 replies; 5+ messages in thread
From: Jan Kiszka @ 2011-03-18 12:19 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: qemu-devel, kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

KVM only requires to set the raised IRQ in CPUState and to kick the
receiving vcpu if it is remote. Installing a specialized handler allows
potential future changes to the TCG code path without risking KVM side
effects.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 kvm-all.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 1d7e8ea..fd1fbfe 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -651,6 +651,15 @@ static CPUPhysMemoryClient kvm_cpu_phys_memory_client = {
     .log_stop = kvm_log_stop,
 };
 
+static void kvm_handle_interrupt(CPUState *env, int mask)
+{
+    env->interrupt_request |= mask;
+
+    if (!qemu_cpu_is_self(env)) {
+        qemu_cpu_kick(env);
+    }
+}
+
 int kvm_init(void)
 {
     static const char upgrade_note[] =
@@ -759,6 +768,8 @@ int kvm_init(void)
 
     s->many_ioeventfds = kvm_check_many_ioeventfds();
 
+    cpu_interrupt_handler = kvm_handle_interrupt;
+
     return 0;
 
 err:
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] Re: [PATCH 2/3] Redirect cpu_interrupt to callback handler
  2011-03-18 12:19 ` [Qemu-devel] [PATCH 2/3] Redirect cpu_interrupt to callback handler Jan Kiszka
@ 2011-03-28 14:46   ` Marcelo Tosatti
  0 siblings, 0 replies; 5+ messages in thread
From: Marcelo Tosatti @ 2011-03-28 14:46 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, kvm, qemu-devel

On Fri, Mar 18, 2011 at 01:19:15PM +0100, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> This allows to override the interrupt handling of QEMU in system mode.
> KVM will make use of it to set a specialized handler.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  cpu-all.h |   14 +++++++++++++-
>  exec.c    |    4 +++-
>  2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/cpu-all.h b/cpu-all.h
> index 4f4631d..5835cfa 100644
> --- a/cpu-all.h
> +++ b/cpu-all.h
> @@ -790,7 +790,19 @@ extern CPUState *cpu_single_env;
>  #define CPU_INTERRUPT_SIPI   0x800 /* SIPI pending. */
>  #define CPU_INTERRUPT_MCE    0x1000 /* (x86 only) MCE pending. */
>  
> -void cpu_interrupt(CPUState *s, int mask);
> +#ifndef CONFIG_USER_ONLY
> +typedef void (*CPUInterruptHandler)(CPUState *, int);
> +
> +extern CPUInterruptHandler cpu_interrupt_handler;
> +
> +static inline void cpu_interrupt(CPUState *s, int mask)
> +{
> +    cpu_interrupt_handler(s, mask);
> +}
> +#else /* USER_ONLY */
> +void cpu_interrupt(CPUState *env, int mask);
> +#endif /* USER_ONLY */
> +
>  void cpu_reset_interrupt(CPUState *env, int mask);
>  
>  void cpu_exit(CPUState *s);
> diff --git a/exec.c b/exec.c
> index 4721f04..0c80f84 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1632,7 +1632,7 @@ static void cpu_unlink_tb(CPUState *env)
>  
>  #ifndef CONFIG_USER_ONLY
>  /* mask must never be zero, except for A20 change call */
> -void cpu_interrupt(CPUState *env, int mask)
> +static void tcg_handle_interrupt(CPUState *env, int mask)
>  {
>      int old_mask;
>  
> @@ -1659,6 +1659,8 @@ void cpu_interrupt(CPUState *env, int mask)
>      }
>  }
>  
> +CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
> +
>  #else /* CONFIG_USER_ONLY */
>  
>  void cpu_interrupt(CPUState *env, int mask)
> -- 
> 1.7.1

Perhaps a function would be a better interface, but can be changed
later.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-03-29 13:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-18 12:19 [Qemu-devel] [PATCH 0/3] [uq/master] Patch queue, part VI (interrupt disentangling) Jan Kiszka
2011-03-18 12:19 ` [Qemu-devel] [PATCH 1/3] Break up user and system cpu_interrupt implementations Jan Kiszka
2011-03-18 12:19 ` [Qemu-devel] [PATCH 2/3] Redirect cpu_interrupt to callback handler Jan Kiszka
2011-03-28 14:46   ` [Qemu-devel] " Marcelo Tosatti
2011-03-18 12:19 ` [Qemu-devel] [PATCH 3/3] kvm: Install specialized interrupt handler Jan Kiszka

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).