From patchwork Mon Sep 18 15:59:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 815001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xwrTD1q2sz9s78 for ; Tue, 19 Sep 2017 02:05:52 +1000 (AEST) Received: from localhost ([::1]:37595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyYQ-0001wo-Ae for incoming@patchwork.ozlabs.org; Mon, 18 Sep 2017 12:05:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyTr-0006u7-Od for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTl-0007nr-L4 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47514) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTl-0007nC-DW for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4FD107E43B; Mon, 18 Sep 2017 16:01:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4FD107E43B Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id D40CC5D6A8; Mon, 18 Sep 2017 16:00:57 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:50 +0200 Message-Id: <20170918160012.4317-6-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 18 Sep 2017 16:01:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 05/27] s390/tcg: turn INTERRUPT_EXT into a mask X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Richard Henderson --- 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); }