From patchwork Mon Sep 18 15:59:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 815005 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 3xwrXT1CH3z9s78 for ; Tue, 19 Sep 2017 02:08:41 +1000 (AEST) Received: from localhost ([::1]:37610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyb9-0004cl-4v for incoming@patchwork.ozlabs.org; Mon, 18 Sep 2017 12:08:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyTu-0006wT-Tw for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTo-0007p4-M5 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56844) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTo-0007oO-E0 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:04 -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 52813C0050BF; Mon, 18 Sep 2017 16:01:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 52813C0050BF 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 Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id A08715D6A9; Mon, 18 Sep 2017 16:01:00 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:51 +0200 Message-Id: <20170918160012.4317-7-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.32]); Mon, 18 Sep 2017 16:01:03 +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 06/27] s390x/tcg: injection of emergency signals and extarnal calls 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" Preparation for new TCG SIGP code. Especially also prepare for indicating that another external call is already pending. Signed-off-by: David Hildenbrand --- target/s390x/cpu.h | 8 +++++++- target/s390x/excp_helper.c | 14 ++++++++++++++ target/s390x/internal.h | 2 ++ target/s390x/interrupt.c | 26 ++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index d4e2aa2f24..857af21d06 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -132,6 +132,8 @@ struct CPUS390XState { MchkQueue mchk_queue[MAX_MCHK_QUEUE]; int pending_int; + uint16_t external_call_addr; + DECLARE_BITMAP(emergency_signals, S390_MAX_CPUS); int ext_index; int io_index[8]; int mchk_index; @@ -405,9 +407,13 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState* env, target_ulong *pc, #define INTERRUPT_EXT_FLOATING (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_FLOATING | \ INTERRUPT_EXT_CPU_TIMER | \ - INTERRUPT_EXT_CLOCK_COMPARATOR) + INTERRUPT_EXT_CLOCK_COMPARATOR | \ + INTERRUPT_EXTERNAL_CALL | \ + INTERRUPT_EMERGENCY_SIGNAL) /* Program Status Word. */ #define S390_PSWM_REGNUM 0 diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 46d015f260..ff257ba72e 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -231,6 +231,7 @@ static void do_ext_interrupt(CPUS390XState *env) { S390CPU *cpu = s390_env_get_cpu(env); uint64_t mask, addr; + uint16_t cpu_addr; LowCore *lowcore; ExtQueue *q; @@ -248,6 +249,19 @@ static void do_ext_interrupt(CPUS390XState *env) 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_EMERGENCY_SIGNAL) { + lowcore->ext_int_code = cpu_to_be16(EXT_EMERGENCY); + cpu_addr = find_first_bit(env->emergency_signals, S390_MAX_CPUS); + g_assert(cpu_addr < S390_MAX_CPUS); + lowcore->cpu_addr = cpu_to_be16(cpu_addr); + clear_bit(cpu_addr, env->emergency_signals); + if (bitmap_empty(env->emergency_signals, max_cpus)) { + env->pending_int &= ~INTERRUPT_EMERGENCY_SIGNAL; + } + } else if (env->pending_int & INTERRUPT_EXTERNAL_CALL) { + lowcore->ext_int_code = cpu_to_be16(EXT_EXTERNAL_CALL); + lowcore->cpu_addr = cpu_to_be16(env->external_call_addr); + env->pending_int &= ~INTERRUPT_EXTERNAL_CALL; } else if (env->pending_int | INTERRUPT_EXT_FLOATING) { g_assert(env->ext_index >= 0); /* diff --git a/target/s390x/internal.h b/target/s390x/internal.h index ae4b27a574..15743ec40f 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -350,6 +350,8 @@ 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); +void cpu_inject_emergency_signal(S390CPU *cpu, uint16_t src_cpu_addr); +int cpu_inject_external_call(S390CPU *cpu, uint16_t src_cpu_addr); /* ioinst.c */ diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index 4ba33c49cb..462316be8e 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -91,6 +91,32 @@ void cpu_inject_cpu_timer(S390CPU *cpu) cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); } +void cpu_inject_emergency_signal(S390CPU *cpu, uint16_t src_cpu_addr) +{ + CPUS390XState *env = &cpu->env; + + g_assert(src_cpu_addr < S390_MAX_CPUS); + set_bit(src_cpu_addr, env->emergency_signals); + + env->pending_int |= INTERRUPT_EMERGENCY_SIGNAL; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); +} + +int cpu_inject_external_call(S390CPU *cpu, uint16_t src_cpu_addr) +{ + CPUS390XState *env = &cpu->env; + + g_assert(src_cpu_addr < S390_MAX_CPUS); + if (env->pending_int & INTERRUPT_EXTERNAL_CALL) { + return -EBUSY; + } + env->external_call_addr = src_cpu_addr; + + env->pending_int |= 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)