From nobody Sun Feb 8 22:34:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506631318715641.951249597943; Thu, 28 Sep 2017 13:41:58 -0700 (PDT) Received: from localhost ([::1]:60787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfd3-000767-Sb for importer@patchew.org; Thu, 28 Sep 2017 16:41:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYg-0003aS-9L for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYf-000327-6A for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44014) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYe-00031h-TK for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:21 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E858AC057F91; Thu, 28 Sep 2017 20:37:19 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D5EF17F33; Thu, 28 Sep 2017 20:37:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E858AC057F91 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Thu, 28 Sep 2017 22:36:41 +0200 Message-Id: <20170928203708.9376-4-david@redhat.com> In-Reply-To: <20170928203708.9376-1-david@redhat.com> References: <20170928203708.9376-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 28 Sep 2017 20:37:20 +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 v2 03/30] s390x/tcg: injection of emergency signals and external calls X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, David Hildenbrand , cohuck@redhat.com, Richard Henderson , Alexander Graf , Christian Borntraeger Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Preparation for new TCG SIGP code. Especially also prepare for indicating that another external call is already pending. Take care of interrupt priority. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.h | 8 +++++++- target/s390x/excp_helper.c | 16 +++++++++++++++- target/s390x/internal.h | 2 ++ target/s390x/interrupt.c | 26 ++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 7bea97a2d7..f0f5ff0359 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -126,6 +126,8 @@ struct CPUS390XState { =20 int pending_int; uint32_t service_param; + uint16_t external_call_addr; + DECLARE_BITMAP(emergency_signals, S390_MAX_CPUS); int io_index[8]; int mchk_index; =20 @@ -401,9 +403,13 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState*= env, target_ulong *pc, #define INTERRUPT_EXT_SERVICE (1 << 2) #define INTERRUPT_EXT_CPU_TIMER (1 << 3) #define INTERRUPT_EXT_CLOCK_COMPARATOR (1 << 4) +#define INTERRUPT_EXTERNAL_CALL (1 << 5) +#define INTERRUPT_EMERGENCY_SIGNAL (1 << 6) #define INTERRUPT_EXT (INTERRUPT_EXT_SERVICE | \ INTERRUPT_EXT_CPU_TIMER | \ - INTERRUPT_EXT_CLOCK_COMPARATOR) + INTERRUPT_EXT_CLOCK_COMPARATOR |= \ + INTERRUPT_EXTERNAL_CALL | \ + INTERRUPT_EMERGENCY_SIGNAL) =20 /* Program Status Word. */ #define S390_PSWM_REGNUM 0 diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 8228104a49..bffcf7f39e 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -239,6 +239,7 @@ static void do_ext_interrupt(CPUS390XState *env) { S390CPU *cpu =3D s390_env_get_cpu(env); uint64_t mask, addr; + uint16_t cpu_addr; LowCore *lowcore; =20 if (!(env->psw.mask & PSW_MASK_EXT)) { @@ -247,7 +248,20 @@ static void do_ext_interrupt(CPUS390XState *env) =20 lowcore =3D cpu_map_lowcore(env); =20 - if (env->pending_int & INTERRUPT_EXT_CLOCK_COMPARATOR) { + if (env->pending_int & INTERRUPT_EMERGENCY_SIGNAL) { + lowcore->ext_int_code =3D cpu_to_be16(EXT_EMERGENCY); + cpu_addr =3D find_first_bit(env->emergency_signals, S390_MAX_CPUS); + g_assert(cpu_addr < S390_MAX_CPUS); + lowcore->cpu_addr =3D cpu_to_be16(cpu_addr); + clear_bit(cpu_addr, env->emergency_signals); + if (bitmap_empty(env->emergency_signals, max_cpus)) { + env->pending_int &=3D ~INTERRUPT_EMERGENCY_SIGNAL; + } + } else if (env->pending_int & INTERRUPT_EXTERNAL_CALL) { + lowcore->ext_int_code =3D cpu_to_be16(EXT_EXTERNAL_CALL); + lowcore->cpu_addr =3D cpu_to_be16(env->external_call_addr); + env->pending_int &=3D ~INTERRUPT_EXTERNAL_CALL; + } else if (env->pending_int & INTERRUPT_EXT_CLOCK_COMPARATOR) { lowcore->ext_int_code =3D cpu_to_be16(EXT_CLOCK_COMP); lowcore->cpu_addr =3D 0; env->pending_int &=3D ~INTERRUPT_EXT_CLOCK_COMPARATOR; diff --git a/target/s390x/internal.h b/target/s390x/internal.h index eaa071a183..f67c2a1785 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -362,6 +362,8 @@ void cpu_unmap_lowcore(LowCore *lowcore); void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ile= n); void cpu_inject_clock_comparator(S390CPU *cpu); void cpu_inject_cpu_timer(S390CPU *cpu); +void cpu_inject_emergency_signal(S390CPU *cpu, uint16_t src_cpu_addr); +int cpu_inject_external_call(S390CPU *cpu, uint16_t src_cpu_addr); =20 =20 /* ioinst.c */ diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index cbc7b7696d..afd311c1e1 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -81,6 +81,32 @@ void cpu_inject_cpu_timer(S390CPU *cpu) cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); } =20 +void cpu_inject_emergency_signal(S390CPU *cpu, uint16_t src_cpu_addr) +{ + CPUS390XState *env =3D &cpu->env; + + g_assert(src_cpu_addr < S390_MAX_CPUS); + set_bit(src_cpu_addr, env->emergency_signals); + + env->pending_int |=3D INTERRUPT_EMERGENCY_SIGNAL; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); +} + +int cpu_inject_external_call(S390CPU *cpu, uint16_t src_cpu_addr) +{ + CPUS390XState *env =3D &cpu->env; + + g_assert(src_cpu_addr < S390_MAX_CPUS); + if (env->pending_int & INTERRUPT_EXTERNAL_CALL) { + return -EBUSY; + } + env->external_call_addr =3D src_cpu_addr; + + env->pending_int |=3D INTERRUPT_EXTERNAL_CALL; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); + return 0; +} + static void cpu_inject_io(S390CPU *cpu, uint16_t subchannel_id, uint16_t subchannel_number, uint32_t io_int_parm, uint32_t io_int_word) --=20 2.13.5