qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	thuth@redhat.com, cohuck@redhat.com, david@redhat.com,
	borntraeger@de.ibm.com, "Alexander Graf" <agraf@suse.de>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"Matthew Rosato" <mjrosato@linux.vnet.ibm.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [PATCH v1 05/27] s390/tcg: turn INTERRUPT_EXT into a mask
Date: Mon, 18 Sep 2017 17:59:50 +0200	[thread overview]
Message-ID: <20170918160012.4317-6-david@redhat.com> (raw)
In-Reply-To: <20170918160012.4317-1-david@redhat.com>

External interrupts are currently all handled like floating external
interrupts, they are queued. Let's prepare for a split of floating
and local interrupts by turning INTERRUPT_EXT into a mask.

While we can have various floating external interrupts of one kind, there
is usually only one (or a fixed number) of the local external interrupts.

So turn INTERRUPT_EXT into a mask and properly indicate the kind of
external interrupt. Floating interrupts will have to moved out of
one CPU instance later once we have SMP support.

This get's rid of the ugly special handling for cpu timer and clock
comparator interrupts. And we really only store the parameters as
defined by the PoP.

We'll introduce external calls and emergency signals in the following
patches.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 target/s390x/cpu.h         | 13 ++++++----
 target/s390x/excp_helper.c | 65 ++++++++++++++++++++++++----------------------
 target/s390x/helper.c      | 12 ++-------
 target/s390x/internal.h    |  2 ++
 target/s390x/interrupt.c   | 18 ++++++++++++-
 5 files changed, 63 insertions(+), 47 deletions(-)

diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 5f539b1057..d4e2aa2f24 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -400,11 +400,14 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState* env, target_ulong *pc,
 #define EXCP_IO  7 /* I/O interrupt */
 #define EXCP_MCHK 8 /* machine check */
 
-#define INTERRUPT_EXT        (1 << 0)
-#define INTERRUPT_TOD        (1 << 1)
-#define INTERRUPT_CPUTIMER   (1 << 2)
-#define INTERRUPT_IO         (1 << 3)
-#define INTERRUPT_MCHK       (1 << 4)
+#define INTERRUPT_IO                     (1 << 0)
+#define INTERRUPT_MCHK                   (1 << 1)
+#define INTERRUPT_EXT_FLOATING           (1 << 2)
+#define INTERRUPT_EXT_CPU_TIMER          (1 << 3)
+#define INTERRUPT_EXT_CLOCK_COMPARATOR   (1 << 4)
+#define INTERRUPT_EXT                    (INTERRUPT_EXT_FLOATING | \
+                                          INTERRUPT_EXT_CPU_TIMER | \
+                                          INTERRUPT_EXT_CLOCK_COMPARATOR)
 
 /* Program Status Word.  */
 #define S390_PSWM_REGNUM 0
diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c
index 470cf8f5bc..46d015f260 100644
--- a/target/s390x/excp_helper.c
+++ b/target/s390x/excp_helper.c
@@ -238,29 +238,44 @@ static void do_ext_interrupt(CPUS390XState *env)
         cpu_abort(CPU(cpu), "Ext int w/o ext mask\n");
     }
 
-    if (env->ext_index < 0 || env->ext_index >= MAX_EXT_QUEUE) {
-        cpu_abort(CPU(cpu), "Ext queue overrun: %d\n", env->ext_index);
-    }
-
-    q = &env->ext_queue[env->ext_index];
     lowcore = cpu_map_lowcore(env);
 
-    lowcore->ext_int_code = cpu_to_be16(q->code);
-    lowcore->ext_params = cpu_to_be32(q->param);
-    lowcore->ext_params2 = cpu_to_be64(q->param64);
-    lowcore->external_old_psw.mask = cpu_to_be64(get_psw_mask(env));
-    lowcore->external_old_psw.addr = cpu_to_be64(env->psw.addr);
-    lowcore->cpu_addr = cpu_to_be16(env->core_id | VIRTIO_SUBCODE_64);
+    if (env->pending_int & INTERRUPT_EXT_CLOCK_COMPARATOR) {
+        lowcore->ext_int_code = cpu_to_be16(EXT_CLOCK_COMP);
+        lowcore->cpu_addr = 0;
+        env->pending_int &= ~INTERRUPT_EXT_CLOCK_COMPARATOR;
+    } else if (env->pending_int & INTERRUPT_EXT_CPU_TIMER) {
+        lowcore->ext_int_code = cpu_to_be16(EXT_CPU_TIMER);
+        lowcore->cpu_addr = 0;
+        env->pending_int &= ~INTERRUPT_EXT_CPU_TIMER;
+    } else if (env->pending_int | INTERRUPT_EXT_FLOATING) {
+        g_assert(env->ext_index >= 0);
+        /*
+         * FIXME: floating IRQs should be considered by all CPUs and
+         *        shuld not get cleared by CPU reset.
+         */
+        q = &env->ext_queue[env->ext_index];
+        lowcore->ext_int_code = cpu_to_be16(q->code);
+        lowcore->ext_params = cpu_to_be32(q->param);
+        lowcore->ext_params2 = cpu_to_be64(q->param64);
+        lowcore->external_old_psw.mask = cpu_to_be64(get_psw_mask(env));
+        lowcore->external_old_psw.addr = cpu_to_be64(env->psw.addr);
+        lowcore->cpu_addr = cpu_to_be16(env->core_id | VIRTIO_SUBCODE_64);
+        env->ext_index--;
+        if (env->ext_index == -1) {
+            env->pending_int &= ~INTERRUPT_EXT_FLOATING;
+        }
+    } else {
+        g_assert_not_reached();
+    }
+
     mask = be64_to_cpu(lowcore->external_new_psw.mask);
     addr = be64_to_cpu(lowcore->external_new_psw.addr);
+    lowcore->external_old_psw.mask = cpu_to_be64(get_psw_mask(env));
+    lowcore->external_old_psw.addr = cpu_to_be64(env->psw.addr);
 
     cpu_unmap_lowcore(lowcore);
 
-    env->ext_index--;
-    if (env->ext_index == -1) {
-        env->pending_int &= ~INTERRUPT_EXT;
-    }
-
     DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__,
             env->psw.mask, env->psw.addr);
 
@@ -413,21 +428,9 @@ void s390_cpu_do_interrupt(CPUState *cs)
     }
     /* handle external interrupts */
     if ((env->psw.mask & PSW_MASK_EXT) &&
-        cs->exception_index == -1) {
-        if (env->pending_int & INTERRUPT_EXT) {
-            /* code is already in env */
-            cs->exception_index = EXCP_EXT;
-        } else if (env->pending_int & INTERRUPT_TOD) {
-            cpu_inject_ext(cpu, 0x1004, 0, 0);
-            cs->exception_index = EXCP_EXT;
-            env->pending_int &= ~INTERRUPT_EXT;
-            env->pending_int &= ~INTERRUPT_TOD;
-        } else if (env->pending_int & INTERRUPT_CPUTIMER) {
-            cpu_inject_ext(cpu, 0x1005, 0, 0);
-            cs->exception_index = EXCP_EXT;
-            env->pending_int &= ~INTERRUPT_EXT;
-            env->pending_int &= ~INTERRUPT_TOD;
-        }
+        cs->exception_index == -1 &&
+        (env->pending_int & INTERRUPT_EXT)) {
+        cs->exception_index = EXCP_EXT;
     }
     /* handle I/O interrupts */
     if ((env->psw.mask & PSW_MASK_IO) &&
diff --git a/target/s390x/helper.c b/target/s390x/helper.c
index 97adbcc86d..e22b93258b 100644
--- a/target/s390x/helper.c
+++ b/target/s390x/helper.c
@@ -51,20 +51,12 @@
 #ifndef CONFIG_USER_ONLY
 void s390x_tod_timer(void *opaque)
 {
-    S390CPU *cpu = opaque;
-    CPUS390XState *env = &cpu->env;
-
-    env->pending_int |= INTERRUPT_TOD;
-    cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
+    cpu_inject_clock_comparator((S390CPU *) opaque);
 }
 
 void s390x_cpu_timer(void *opaque)
 {
-    S390CPU *cpu = opaque;
-    CPUS390XState *env = &cpu->env;
-
-    env->pending_int |= INTERRUPT_CPUTIMER;
-    cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
+    cpu_inject_cpu_timer((S390CPU *) opaque);
 }
 #endif
 
diff --git a/target/s390x/internal.h b/target/s390x/internal.h
index bc8f83129a..ae4b27a574 100644
--- a/target/s390x/internal.h
+++ b/target/s390x/internal.h
@@ -348,6 +348,8 @@ void cpu_unmap_lowcore(LowCore *lowcore);
 void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ilen);
 void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param,
                     uint64_t param64);
+void cpu_inject_clock_comparator(S390CPU *cpu);
+void cpu_inject_cpu_timer(S390CPU *cpu);
 
 
 /* ioinst.c */
diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c
index 058e219fe5..4ba33c49cb 100644
--- a/target/s390x/interrupt.c
+++ b/target/s390x/interrupt.c
@@ -71,7 +71,23 @@ void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param,
     env->ext_queue[env->ext_index].param = param;
     env->ext_queue[env->ext_index].param64 = param64;
 
-    env->pending_int |= INTERRUPT_EXT;
+    env->pending_int |= INTERRUPT_EXT_FLOATING;
+    cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
+}
+
+void cpu_inject_clock_comparator(S390CPU *cpu)
+{
+    CPUS390XState *env = &cpu->env;
+
+    env->pending_int |= INTERRUPT_EXT_CLOCK_COMPARATOR;
+    cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
+}
+
+void cpu_inject_cpu_timer(S390CPU *cpu)
+{
+    CPUS390XState *env = &cpu->env;
+
+    env->pending_int |= INTERRUPT_EXT_CPU_TIMER;
     cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
 }
 
-- 
2.13.5

  parent reply	other threads:[~2017-09-18 16:01 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 15:59 [Qemu-devel] [PATCH v1 00/27] s390x: SMP for TCG (+ cleanups) David Hildenbrand
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 01/27] s390x: raise CPU hotplug irq after really hotplugged David Hildenbrand
2017-09-25  7:18   ` Christian Borntraeger
2017-09-25 23:10   ` Richard Henderson
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 02/27] s390x/cpumodel: fix max STFL(E) bit number David Hildenbrand
2017-09-25  8:14   ` Christian Borntraeger
2017-09-25  9:18   ` Thomas Huth
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 03/27] target/s390x: get rid of next_core_id David Hildenbrand
2017-09-21 13:28   ` Igor Mammedov
2017-09-25 23:14   ` Richard Henderson
2017-09-26  8:49     ` Igor Mammedov
2017-09-26 12:40       ` David Hildenbrand
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 04/27] s390x: introduce and use S390_MAX_CPUS David Hildenbrand
2017-09-25 10:08   ` Thomas Huth
2017-09-25 23:14   ` Richard Henderson
2017-09-18 15:59 ` David Hildenbrand [this message]
2017-09-25 23:18   ` [Qemu-devel] [PATCH v1 05/27] s390/tcg: turn INTERRUPT_EXT into a mask Richard Henderson
2017-09-28 19:08     ` David Hildenbrand
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 06/27] s390x/tcg: injection of emergency signals and extarnal calls David Hildenbrand
2017-09-25 13:16   ` David Hildenbrand
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 07/27] s390x/tcg: STOPPED cpus can never wake up David Hildenbrand
2017-09-25 23:20   ` Richard Henderson
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 08/27] s390x/tcg: a CPU cannot switch state due to an interrupt David Hildenbrand
2017-09-25 23:20   ` Richard Henderson
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 09/27] target/s390x: factor out handling of WAIT PSW into handle_wait() David Hildenbrand
2017-09-25 10:22   ` Thomas Huth
2017-09-26 13:04     ` David Hildenbrand
2017-09-25 23:23   ` Richard Henderson
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 10/27] s390x/kvm: pass ipb directly into handle_sigp() David Hildenbrand
2017-09-25 10:27   ` Thomas Huth
2017-09-25 23:24   ` Richard Henderson
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 11/27] s390x/kvm: generalize SIGP stop and restart interrupt injection David Hildenbrand
2017-09-25 23:29   ` Richard Henderson
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 12/27] s390x/kvm: factor out storing of CPU status David Hildenbrand
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 13/27] target/s390x: proper cpu->be convertion in s390_store_status() David Hildenbrand
2017-09-18 15:59 ` [Qemu-devel] [PATCH v1 14/27] s390x/kvm: factor out storing of adtl CPU status David Hildenbrand
2017-09-25 23:31   ` Richard Henderson
2017-09-25 23:41   ` Richard Henderson
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 15/27] s390x/kvm: drop two debug prints David Hildenbrand
2017-09-25 10:32   ` Thomas Huth
2017-09-25 23:41   ` Richard Henderson
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 16/27] s390x/kvm: factor out SIGP code into sigp.c David Hildenbrand
2017-09-18 17:25   ` Christian Borntraeger
2017-09-18 18:14     ` David Hildenbrand
2017-09-25 23:49   ` Richard Henderson
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 17/27] s390x/kvm: factor out actual handling of STOP interrupts David Hildenbrand
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 18/27] s390x/tcg: implement SIGP SENSE RUNNING STATUS David Hildenbrand
2017-09-25 12:47   ` Thomas Huth
2017-09-25 12:51     ` David Hildenbrand
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 19/27] s390x/tcg: implement SIGP SENSE David Hildenbrand
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 20/27] s390x/tcg: implement SIGP EXTERNAL CALL David Hildenbrand
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 21/27] s390x/tcg: implement SIGP EMERGENCY SIGNAL David Hildenbrand
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 22/27] s390x/tcg: implement SIGP CONDITIONAL " David Hildenbrand
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 23/27] s390x/tcg: implement STOP and RESET interrupts for TCG David Hildenbrand
2017-09-18 20:00   ` David Hildenbrand
2017-09-18 20:21     ` David Hildenbrand
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 24/27] s390x/tcg: flush the tlb on SIGP SET PREFIX David Hildenbrand
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 25/27] s390x/tcg: switch to new SIGP handling code David Hildenbrand
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 26/27] s390x/tcg: unlock NMI David Hildenbrand
2017-09-18 16:00 ` [Qemu-devel] [PATCH v1 27/27] s390x/tcg: refactor stfl(e) to use s390_get_feat_block() David Hildenbrand
2017-09-18 17:31 ` [Qemu-devel] [PATCH v1 00/27] s390x: SMP for TCG (+ cleanups) Christian Borntraeger
2017-09-18 18:28   ` David Hildenbrand
2017-09-21 13:07 ` David Hildenbrand

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=20170918160012.4317-6-david@redhat.com \
    --to=david@redhat.com \
    --cc=agraf@suse.de \
    --cc=alex.bennee@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mjrosato@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    /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).