From nobody Tue May 7 18:53:18 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1506631168004550.1906011630169; Thu, 28 Sep 2017 13:39:28 -0700 (PDT) Received: from localhost ([::1]:60774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaS-0004iY-4T for importer@patchew.org; Thu, 28 Sep 2017 16:39:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYc-0003Y9-IH for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYb-00030A-3Q for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYa-0002zp-QU for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:17 -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 A9518C057FA1; Thu, 28 Sep 2017 20:37:15 +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 001BA17F33; Thu, 28 Sep 2017 20:37:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A9518C057FA1 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:39 +0200 Message-Id: <20170928203708.9376-2-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:15 +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 01/30] s390x/tcg: turn INTERRUPT_EXT into a mask 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_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. The only floating external interrupts used right now are SERVICE interrupts, so let's use that name. Following patches will clean up SERVICE interrupt injection. 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. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/cpu.h | 13 ++++++---- target/s390x/excp_helper.c | 63 +++++++++++++++++++++++-------------------= ---- target/s390x/helper.c | 12 ++------- target/s390x/internal.h | 2 ++ target/s390x/interrupt.c | 18 ++++++++++++- 5 files changed, 61 insertions(+), 47 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 7e864c8478..e32f87a2f1 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -404,11 +404,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 */ =20 -#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_SERVICE (1 << 2) +#define INTERRUPT_EXT_CPU_TIMER (1 << 3) +#define INTERRUPT_EXT_CLOCK_COMPARATOR (1 << 4) +#define INTERRUPT_EXT (INTERRUPT_EXT_SERVICE | \ + INTERRUPT_EXT_CPU_TIMER | \ + INTERRUPT_EXT_CLOCK_COMPARATOR) =20 /* Program Status Word. */ #define S390_PSWM_REGNUM 0 diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index aa0cbf67ac..8521043bf2 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -246,29 +246,42 @@ static void do_ext_interrupt(CPUS390XState *env) cpu_abort(CPU(cpu), "Ext int w/o ext mask\n"); } =20 - if (env->ext_index < 0 || env->ext_index >=3D MAX_EXT_QUEUE) { - cpu_abort(CPU(cpu), "Ext queue overrun: %d\n", env->ext_index); - } - - q =3D &env->ext_queue[env->ext_index]; lowcore =3D cpu_map_lowcore(env); =20 - lowcore->ext_int_code =3D cpu_to_be16(q->code); - lowcore->ext_params =3D cpu_to_be32(q->param); - lowcore->ext_params2 =3D cpu_to_be64(q->param64); - lowcore->external_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); - lowcore->external_old_psw.addr =3D cpu_to_be64(env->psw.addr); - lowcore->cpu_addr =3D cpu_to_be16(env->core_id | VIRTIO_SUBCODE_64); + 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; + } else if (env->pending_int & INTERRUPT_EXT_CPU_TIMER) { + lowcore->ext_int_code =3D cpu_to_be16(EXT_CPU_TIMER); + lowcore->cpu_addr =3D 0; + env->pending_int &=3D ~INTERRUPT_EXT_CPU_TIMER; + } else if (env->pending_int & INTERRUPT_EXT_SERVICE) { + g_assert(env->ext_index >=3D 0); + /* + * FIXME: floating IRQs should be considered by all CPUs and + * shuld not get cleared by CPU reset. + */ + q =3D &env->ext_queue[env->ext_index]; + lowcore->ext_int_code =3D cpu_to_be16(q->code); + lowcore->ext_params =3D cpu_to_be32(q->param); + lowcore->ext_params2 =3D cpu_to_be64(q->param64); + lowcore->cpu_addr =3D cpu_to_be16(env->core_id | VIRTIO_SUBCODE_64= ); + env->ext_index--; + if (env->ext_index =3D=3D -1) { + env->pending_int &=3D ~INTERRUPT_EXT_SERVICE; + } + } else { + g_assert_not_reached(); + } + mask =3D be64_to_cpu(lowcore->external_new_psw.mask); addr =3D be64_to_cpu(lowcore->external_new_psw.addr); + lowcore->external_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); + lowcore->external_old_psw.addr =3D cpu_to_be64(env->psw.addr); =20 cpu_unmap_lowcore(lowcore); =20 - env->ext_index--; - if (env->ext_index =3D=3D -1) { - env->pending_int &=3D ~INTERRUPT_EXT; - } - DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__, env->psw.mask, env->psw.addr); =20 @@ -421,21 +434,9 @@ void s390_cpu_do_interrupt(CPUState *cs) } /* handle external interrupts */ if ((env->psw.mask & PSW_MASK_EXT) && - cs->exception_index =3D=3D -1) { - if (env->pending_int & INTERRUPT_EXT) { - /* code is already in env */ - cs->exception_index =3D EXCP_EXT; - } else if (env->pending_int & INTERRUPT_TOD) { - cpu_inject_ext(cpu, 0x1004, 0, 0); - cs->exception_index =3D EXCP_EXT; - env->pending_int &=3D ~INTERRUPT_EXT; - env->pending_int &=3D ~INTERRUPT_TOD; - } else if (env->pending_int & INTERRUPT_CPUTIMER) { - cpu_inject_ext(cpu, 0x1005, 0, 0); - cs->exception_index =3D EXCP_EXT; - env->pending_int &=3D ~INTERRUPT_EXT; - env->pending_int &=3D ~INTERRUPT_TOD; - } + cs->exception_index =3D=3D -1 && + (env->pending_int & INTERRUPT_EXT)) { + cs->exception_index =3D 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 =3D opaque; - CPUS390XState *env =3D &cpu->env; - - env->pending_int |=3D INTERRUPT_TOD; - cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); + cpu_inject_clock_comparator((S390CPU *) opaque); } =20 void s390x_cpu_timer(void *opaque) { - S390CPU *cpu =3D opaque; - CPUS390XState *env =3D &cpu->env; - - env->pending_int |=3D INTERRUPT_CPUTIMER; - cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); + cpu_inject_cpu_timer((S390CPU *) opaque); } #endif =20 diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 14bf3ea5e2..4dda5cf2f1 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_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); =20 =20 /* ioinst.c */ diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index 058e219fe5..b9c30f86d7 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 =3D param; env->ext_queue[env->ext_index].param64 =3D param64; =20 - env->pending_int |=3D INTERRUPT_EXT; + env->pending_int |=3D INTERRUPT_EXT_SERVICE; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); +} + +void cpu_inject_clock_comparator(S390CPU *cpu) +{ + CPUS390XState *env =3D &cpu->env; + + env->pending_int |=3D INTERRUPT_EXT_CLOCK_COMPARATOR; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); +} + +void cpu_inject_cpu_timer(S390CPU *cpu) +{ + CPUS390XState *env =3D &cpu->env; + + env->pending_int |=3D INTERRUPT_EXT_CPU_TIMER; cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); } =20 --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1506631168004917.1386020106709; Thu, 28 Sep 2017 13:39:28 -0700 (PDT) Received: from localhost ([::1]:60775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaU-0004kr-FQ for importer@patchew.org; Thu, 28 Sep 2017 16:39:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYe-0003Ye-89 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYd-00030y-16 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYc-00030Z-Oy for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:18 -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 C8E24C04AC45; Thu, 28 Sep 2017 20:37:17 +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 0C8A818C57; Thu, 28 Sep 2017 20:37:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C8E24C04AC45 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.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:40 +0200 Message-Id: <20170928203708.9376-3-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.31]); Thu, 28 Sep 2017 20:37:17 +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 02/30] s390x/tcg: cleanup service interrupt injection 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_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There are still some leftovers from old virtio interrupts in there. Most importantly, we don't have to queue service interrupts anymore. Just like KVM, we can simply multiplex the SCLP service interrupts and avoid the queue. Also, now only valid parametes/cpu_addr will be stored on service interrupts. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.c | 2 -- target/s390x/cpu.h | 10 +--------- target/s390x/excp_helper.c | 16 +++++----------- target/s390x/internal.h | 2 -- target/s390x/interrupt.c | 18 ++++-------------- 5 files changed, 10 insertions(+), 38 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index f42e28ea25..e240d99fe6 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -107,7 +107,6 @@ static void s390_cpu_initial_reset(CPUState *s) env->gbea =3D 1; =20 env->pfault_token =3D -1UL; - env->ext_index =3D -1; for (i =3D 0; i < ARRAY_SIZE(env->io_index); i++) { env->io_index[i] =3D -1; } @@ -144,7 +143,6 @@ static void s390_cpu_full_reset(CPUState *s) env->gbea =3D 1; =20 env->pfault_token =3D -1UL; - env->ext_index =3D -1; for (i =3D 0; i < ARRAY_SIZE(env->io_index); i++) { env->io_index[i] =3D -1; } diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index e32f87a2f1..7bea97a2d7 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -53,7 +53,6 @@ =20 #define MMU_USER_IDX 0 =20 -#define MAX_EXT_QUEUE 16 #define MAX_IO_QUEUE 16 #define MAX_MCHK_QUEUE 16 =20 @@ -67,12 +66,6 @@ typedef struct PSW { uint64_t addr; } PSW; =20 -typedef struct ExtQueue { - uint32_t code; - uint32_t param; - uint32_t param64; -} ExtQueue; - typedef struct IOIntQueue { uint16_t id; uint16_t nr; @@ -128,12 +121,11 @@ struct CPUS390XState { =20 uint64_t cregs[16]; /* control registers */ =20 - ExtQueue ext_queue[MAX_EXT_QUEUE]; IOIntQueue io_queue[MAX_IO_QUEUE][8]; MchkQueue mchk_queue[MAX_MCHK_QUEUE]; =20 int pending_int; - int ext_index; + uint32_t service_param; int io_index[8]; int mchk_index; =20 diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 8521043bf2..8228104a49 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -240,7 +240,6 @@ static void do_ext_interrupt(CPUS390XState *env) S390CPU *cpu =3D s390_env_get_cpu(env); uint64_t mask, addr; LowCore *lowcore; - ExtQueue *q; =20 if (!(env->psw.mask & PSW_MASK_EXT)) { cpu_abort(CPU(cpu), "Ext int w/o ext mask\n"); @@ -257,20 +256,15 @@ static void do_ext_interrupt(CPUS390XState *env) lowcore->cpu_addr =3D 0; env->pending_int &=3D ~INTERRUPT_EXT_CPU_TIMER; } else if (env->pending_int & INTERRUPT_EXT_SERVICE) { - g_assert(env->ext_index >=3D 0); /* * FIXME: floating IRQs should be considered by all CPUs and * shuld not get cleared by CPU reset. */ - q =3D &env->ext_queue[env->ext_index]; - lowcore->ext_int_code =3D cpu_to_be16(q->code); - lowcore->ext_params =3D cpu_to_be32(q->param); - lowcore->ext_params2 =3D cpu_to_be64(q->param64); - lowcore->cpu_addr =3D cpu_to_be16(env->core_id | VIRTIO_SUBCODE_64= ); - env->ext_index--; - if (env->ext_index =3D=3D -1) { - env->pending_int &=3D ~INTERRUPT_EXT_SERVICE; - } + lowcore->ext_int_code =3D cpu_to_be16(EXT_SERVICE); + lowcore->ext_params =3D cpu_to_be32(env->service_param); + lowcore->cpu_addr =3D 0; + env->service_param =3D 0; + env->pending_int &=3D ~INTERRUPT_EXT_SERVICE; } else { g_assert_not_reached(); } diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 4dda5cf2f1..eaa071a183 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -360,8 +360,6 @@ void cpu_unmap_lowcore(LowCore *lowcore); =20 /* interrupt.c */ void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ile= n); -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); =20 diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index b9c30f86d7..cbc7b7696d 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -54,22 +54,12 @@ void program_interrupt(CPUS390XState *env, uint32_t cod= e, int ilen) } =20 #if !defined(CONFIG_USER_ONLY) -void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param, - uint64_t param64) +static void cpu_inject_service(S390CPU *cpu, uint32_t param) { CPUS390XState *env =3D &cpu->env; =20 - if (env->ext_index =3D=3D MAX_EXT_QUEUE - 1) { - /* ugh - can't queue anymore. Let's drop. */ - return; - } - - env->ext_index++; - assert(env->ext_index < MAX_EXT_QUEUE); - - env->ext_queue[env->ext_index].code =3D code; - env->ext_queue[env->ext_index].param =3D param; - env->ext_queue[env->ext_index].param64 =3D param64; + /* multiplexing is good enough for sclp - also kvm does that internall= y */ + env->service_param |=3D param; =20 env->pending_int |=3D INTERRUPT_EXT_SERVICE; cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); @@ -145,7 +135,7 @@ void s390_sclp_extint(uint32_t parm) } else { S390CPU *dummy_cpu =3D s390_cpu_addr2state(0); =20 - cpu_inject_ext(dummy_cpu, EXT_SERVICE, parm, 0); + cpu_inject_service(dummy_cpu, parm); } } =20 --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 From nobody Tue May 7 18:53:18 2024 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 1506631482498998.3210739570649; Thu, 28 Sep 2017 13:44:42 -0700 (PDT) Received: from localhost ([::1]:60797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxffY-00011B-Q3 for importer@patchew.org; Thu, 28 Sep 2017 16:44:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYl-0003f1-7o for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYh-00033O-8u for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34150) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYh-000330-0z for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:23 -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 13C33883A5; Thu, 28 Sep 2017 20:37:22 +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 4D2FA18C57; Thu, 28 Sep 2017 20:37:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 13C33883A5 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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:42 +0200 Message-Id: <20170928203708.9376-5-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.26]); Thu, 28 Sep 2017 20:37:22 +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 04/30] s390x/tcg: rework checking for deliverable interrupts 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" Currently, enabling/disabling of interrupts is not really supported. Let's improve interrupt handling code by explicitly checking for deliverable interrupts only. This is the first step. Checking for external interrupt subclasses will be done next. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.c | 8 +++++--- target/s390x/excp_helper.c | 21 +++++++-------------- target/s390x/internal.h | 4 ++++ target/s390x/interrupt.c | 46 ++++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index e240d99fe6..9c2a1e6ac8 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -56,10 +56,12 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value) static bool s390_cpu_has_work(CPUState *cs) { S390CPU *cpu =3D S390_CPU(cs); - CPUS390XState *env =3D &cpu->env; =20 - return (cs->interrupt_request & CPU_INTERRUPT_HARD) && - (env->psw.mask & PSW_MASK_EXT); + if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) { + return false; + } + + return s390_cpu_has_int(cpu); } =20 #if !defined(CONFIG_USER_ONLY) diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index bffcf7f39e..02849e41e6 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -434,24 +434,16 @@ void s390_cpu_do_interrupt(CPUState *cs) =20 s390_cpu_set_state(CPU_STATE_OPERATING, cpu); /* handle machine checks */ - if ((env->psw.mask & PSW_MASK_MCHECK) && - (cs->exception_index =3D=3D -1)) { - if (env->pending_int & INTERRUPT_MCHK) { - cs->exception_index =3D EXCP_MCHK; - } + if (cs->exception_index =3D=3D -1 && s390_cpu_has_mcck_int(cpu)) { + cs->exception_index =3D EXCP_MCHK; } /* handle external interrupts */ - if ((env->psw.mask & PSW_MASK_EXT) && - cs->exception_index =3D=3D -1 && - (env->pending_int & INTERRUPT_EXT)) { + if (cs->exception_index =3D=3D -1 && s390_cpu_has_ext_int(cpu)) { cs->exception_index =3D EXCP_EXT; } /* handle I/O interrupts */ - if ((env->psw.mask & PSW_MASK_IO) && - (cs->exception_index =3D=3D -1)) { - if (env->pending_int & INTERRUPT_IO) { - cs->exception_index =3D EXCP_IO; - } + if (cs->exception_index =3D=3D -1 && s390_cpu_has_io_int(cpu)) { + cs->exception_index =3D EXCP_IO; } =20 switch (cs->exception_index) { @@ -473,6 +465,7 @@ void s390_cpu_do_interrupt(CPUState *cs) } cs->exception_index =3D -1; =20 + /* we might still have pending interrupts, but not deliverable */ if (!env->pending_int) { cs->interrupt_request &=3D ~CPU_INTERRUPT_HARD; } @@ -489,7 +482,7 @@ bool s390_cpu_exec_interrupt(CPUState *cs, int interrup= t_request) the parent EXECUTE insn. */ return false; } - if (env->psw.mask & PSW_MASK_EXT) { + if (s390_cpu_has_int(cpu)) { s390_cpu_do_interrupt(cs); return true; } diff --git a/target/s390x/internal.h b/target/s390x/internal.h index f67c2a1785..e41fb2e38e 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -364,6 +364,10 @@ 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); +bool s390_cpu_has_io_int(S390CPU *cpu); +bool s390_cpu_has_ext_int(S390CPU *cpu); +bool s390_cpu_has_mcck_int(S390CPU *cpu); +bool s390_cpu_has_int(S390CPU *cpu); =20 =20 /* ioinst.c */ diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index afd311c1e1..54eb400b0c 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -190,4 +190,50 @@ void s390_crw_mchk(void) } } =20 +bool s390_cpu_has_mcck_int(S390CPU *cpu) +{ + CPUS390XState *env =3D &cpu->env; + + if (!(env->psw.mask & PSW_MASK_MCHECK)) { + return false; + } + + return env->pending_int & INTERRUPT_MCHK; +} + +bool s390_cpu_has_ext_int(S390CPU *cpu) +{ + CPUS390XState *env =3D &cpu->env; + + if (!(env->psw.mask & PSW_MASK_EXT)) { + return false; + } + + return env->pending_int & INTERRUPT_EXT; +} + +bool s390_cpu_has_io_int(S390CPU *cpu) +{ + CPUS390XState *env =3D &cpu->env; + + if (!(env->psw.mask & PSW_MASK_IO)) { + return false; + } + + return env->pending_int & INTERRUPT_IO; +} #endif + +bool s390_cpu_has_int(S390CPU *cpu) +{ +#ifndef CONFIG_USER_ONLY + if (!tcg_enabled()) { + return false; + } + return s390_cpu_has_mcck_int(cpu) || + s390_cpu_has_ext_int(cpu) || + s390_cpu_has_io_int(cpu); +#else + return false; +#endif +} --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 150663117514798.85052949349688; Thu, 28 Sep 2017 13:39:35 -0700 (PDT) Received: from localhost ([::1]:60776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaf-0004tx-BE for importer@patchew.org; Thu, 28 Sep 2017 16:39:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYl-0003f2-82 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYj-000347-GZ for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59818) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYj-00033t-7t for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:25 -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 3B5E4821C7; Thu, 28 Sep 2017 20:37:24 +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 6C33717F33; Thu, 28 Sep 2017 20:37:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3B5E4821C7 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.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:43 +0200 Message-Id: <20170928203708.9376-6-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.28]); Thu, 28 Sep 2017 20:37:24 +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 05/30] s390x/tcg: take care of external interrupt subclasses 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" We can now let go of INTERRUPT_EXT. When cr0 changes, we have to revalidate if we now have a pending external interrupt, just like when the PSW (or SYSTEM MASK only) changes. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.h | 10 +++++----- target/s390x/excp_helper.c | 15 ++++++++++----- target/s390x/interrupt.c | 32 +++++++++++++++++++++++++++++++- target/s390x/translate.c | 6 ++++-- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index f0f5ff0359..6ae0c7dfc8 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -345,6 +345,11 @@ extern const struct VMStateDescription vmstate_s390_cp= u; #define CR0_LOWPROT 0x0000000010000000ULL #define CR0_SECONDARY 0x0000000004000000ULL #define CR0_EDAT 0x0000000000800000ULL +#define CR0_EMERGENCY_SIGNAL_SC 0x0000000000004000ULL +#define CR0_EXTERNAL_CALL_SC 0x0000000000002000ULL +#define CR0_CKC_SC 0x0000000000000800ULL +#define CR0_CPU_TIMER_SC 0x0000000000000400ULL +#define CR0_SERVICE_SC 0x0000000000000200ULL =20 /* MMU */ #define MMU_PRIMARY_IDX 0 @@ -405,11 +410,6 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState*= env, target_ulong *pc, #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_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 02849e41e6..fe68de5a77 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -248,7 +248,8 @@ static void do_ext_interrupt(CPUS390XState *env) =20 lowcore =3D cpu_map_lowcore(env); =20 - if (env->pending_int & INTERRUPT_EMERGENCY_SIGNAL) { + if ((env->pending_int & INTERRUPT_EMERGENCY_SIGNAL) && + (env->cregs[0] & CR0_EMERGENCY_SIGNAL_SC)) { 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); @@ -257,19 +258,23 @@ static void do_ext_interrupt(CPUS390XState *env) if (bitmap_empty(env->emergency_signals, max_cpus)) { env->pending_int &=3D ~INTERRUPT_EMERGENCY_SIGNAL; } - } else if (env->pending_int & INTERRUPT_EXTERNAL_CALL) { + } else if ((env->pending_int & INTERRUPT_EXTERNAL_CALL) && + (env->cregs[0] & CR0_EXTERNAL_CALL_SC)) { 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) { + } else if ((env->pending_int & INTERRUPT_EXT_CLOCK_COMPARATOR) && + (env->cregs[0] & CR0_CKC_SC)) { lowcore->ext_int_code =3D cpu_to_be16(EXT_CLOCK_COMP); lowcore->cpu_addr =3D 0; env->pending_int &=3D ~INTERRUPT_EXT_CLOCK_COMPARATOR; - } else if (env->pending_int & INTERRUPT_EXT_CPU_TIMER) { + } else if ((env->pending_int & INTERRUPT_EXT_CPU_TIMER) && + (env->cregs[0] & CR0_CPU_TIMER_SC)) { lowcore->ext_int_code =3D cpu_to_be16(EXT_CPU_TIMER); lowcore->cpu_addr =3D 0; env->pending_int &=3D ~INTERRUPT_EXT_CPU_TIMER; - } else if (env->pending_int & INTERRUPT_EXT_SERVICE) { + } else if ((env->pending_int & INTERRUPT_EXT_SERVICE) && + (env->cregs[0] & CR0_SERVICE_SC)) { /* * FIXME: floating IRQs should be considered by all CPUs and * shuld not get cleared by CPU reset. diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index 54eb400b0c..c1eaaea98b 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -209,7 +209,37 @@ bool s390_cpu_has_ext_int(S390CPU *cpu) return false; } =20 - return env->pending_int & INTERRUPT_EXT; + if ((env->pending_int & INTERRUPT_EMERGENCY_SIGNAL) && + (env->cregs[0] & CR0_EMERGENCY_SIGNAL_SC)) { + return true; + } + + if ((env->pending_int & INTERRUPT_EXTERNAL_CALL) && + (env->cregs[0] & CR0_EXTERNAL_CALL_SC)) { + return true; + } + + if ((env->pending_int & INTERRUPT_EXTERNAL_CALL) && + (env->cregs[0] & CR0_EXTERNAL_CALL_SC)) { + return true; + } + + if ((env->pending_int & INTERRUPT_EXT_CLOCK_COMPARATOR) && + (env->cregs[0] & CR0_CKC_SC)) { + return true; + } + + if ((env->pending_int & INTERRUPT_EXT_CPU_TIMER) && + (env->cregs[0] & CR0_CPU_TIMER_SC)) { + return true; + } + + if ((env->pending_int & INTERRUPT_EXT_SERVICE) && + (env->cregs[0] & CR0_SERVICE_SC)) { + return true; + } + + return false; } =20 bool s390_cpu_has_io_int(S390CPU *cpu) diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 9ef95141f9..405d94b87d 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2719,7 +2719,8 @@ static ExitStatus op_lctl(DisasContext *s, DisasOps *= o) gen_helper_lctl(cpu_env, r1, o->in2, r3); tcg_temp_free_i32(r1); tcg_temp_free_i32(r3); - return NO_EXIT; + /* Exit to main loop to reevaluate s390_cpu_exec_interrupt. */ + return EXIT_PC_STALE_NOCHAIN; } =20 static ExitStatus op_lctlg(DisasContext *s, DisasOps *o) @@ -2730,7 +2731,8 @@ static ExitStatus op_lctlg(DisasContext *s, DisasOps = *o) gen_helper_lctlg(cpu_env, r1, o->in2, r3); tcg_temp_free_i32(r1); tcg_temp_free_i32(r3); - return NO_EXIT; + /* Exit to main loop to reevaluate s390_cpu_exec_interrupt. */ + return EXIT_PC_STALE_NOCHAIN; } =20 static ExitStatus op_lra(DisasContext *s, DisasOps *o) --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506631318684633.4023361677207; Thu, 28 Sep 2017 13:41:58 -0700 (PDT) Received: from localhost ([::1]:60788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfd4-00077f-Jy for importer@patchew.org; Thu, 28 Sep 2017 16:41:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYm-0003fs-9e for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYl-00035T-KF for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45398) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYl-00034z-EQ for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:27 -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 6A06D5F7AD; Thu, 28 Sep 2017 20:37:26 +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 9147818C66; Thu, 28 Sep 2017 20:37:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6A06D5F7AD Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.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:44 +0200 Message-Id: <20170928203708.9376-7-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.39]); Thu, 28 Sep 2017 20:37:26 +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 06/30] s390x/tcg: STOPPED cpus can never wake up 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" Interrupts can't wake such CPUs up. SIGP from other CPUs has to be used to toggle the state. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 9c2a1e6ac8..a0b139056f 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -57,6 +57,12 @@ static bool s390_cpu_has_work(CPUState *cs) { S390CPU *cpu =3D S390_CPU(cs); =20 + /* STOPPED cpus can never wake up */ + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_LOAD && + s390_cpu_get_state(cpu) !=3D CPU_STATE_OPERATING) { + return false; + } + if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) { return false; } --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506631631902833.1023576617268; Thu, 28 Sep 2017 13:47:11 -0700 (PDT) Received: from localhost ([::1]:60811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfi6-0003N6-2C for importer@patchew.org; Thu, 28 Sep 2017 16:47:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYo-0003ij-FO for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYn-00036I-O7 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36074) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYn-000367-Hq for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:29 -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 86A174E4D4; Thu, 28 Sep 2017 20:37:28 +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 C268E18C7C; Thu, 28 Sep 2017 20:37:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 86A174E4D4 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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:45 +0200 Message-Id: <20170928203708.9376-8-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.38]); Thu, 28 Sep 2017 20:37:28 +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 07/30] s390x/tcg: a CPU cannot switch state due to an interrupt 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" Going to OPERATING here looks wrong. A CPU should even never be !OPERATING at this point. Unhalting will already be done in cpu_handle_halt() if there is work, so we can drop this statement completely. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/excp_helper.c | 1 - 1 file changed, 1 deletion(-) diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index fe68de5a77..f6747f3877 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -437,7 +437,6 @@ void s390_cpu_do_interrupt(CPUState *cs) qemu_log_mask(CPU_LOG_INT, "%s: %d at pc=3D%" PRIx64 "\n", __func__, cs->exception_index, env->psw.addr); =20 - s390_cpu_set_state(CPU_STATE_OPERATING, cpu); /* handle machine checks */ if (cs->exception_index =3D=3D -1 && s390_cpu_has_mcck_int(cpu)) { cs->exception_index =3D EXCP_MCHK; --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506631374787531.0631643383608; Thu, 28 Sep 2017 13:42:54 -0700 (PDT) Received: from localhost ([::1]:60790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfdy-00080U-1r for importer@patchew.org; Thu, 28 Sep 2017 16:42:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYq-0003lG-UM for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYq-000371-0b for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYp-00036i-NI for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:31 -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 B4A8281DEE; Thu, 28 Sep 2017 20:37:30 +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 DFB0C18C67; Thu, 28 Sep 2017 20:37:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B4A8281DEE Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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:46 +0200 Message-Id: <20170928203708.9376-9-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.25]); Thu, 28 Sep 2017 20:37:30 +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 08/30] target/s390x: factor out handling of WAIT PSW into s390_handle_wait() 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" This will now also detect crashes under TCG. We can directly use cpu->env.psw.addr instead of kvm_run, as we do a cpu_synchronize_state(). Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/helper.c | 27 +++++++++++++++++++++------ target/s390x/internal.h | 1 + target/s390x/kvm.c | 14 +------------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index e22b93258b..2d7df83c59 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -26,6 +26,7 @@ #include "qemu/timer.h" #include "exec/exec-all.h" #include "hw/s390x/ioinst.h" +#include "sysemu/hw_accel.h" #ifndef CONFIG_USER_ONLY #include "sysemu/sysemu.h" #endif @@ -113,6 +114,25 @@ hwaddr s390_cpu_get_phys_addr_debug(CPUState *cs, vadd= r vaddr) return phys_addr; } =20 +static inline bool is_special_wait_psw(uint64_t psw_addr) +{ + /* signal quiesce */ + return psw_addr =3D=3D 0xfffUL; +} + +void s390_handle_wait(S390CPU *cpu) +{ + if (s390_cpu_halt(cpu) =3D=3D 0) { +#ifndef CONFIG_USER_ONLY + if (is_special_wait_psw(cpu->env.psw.addr)) { + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } else { + qemu_system_guest_panicked(NULL); + } +#endif + } +} + void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr) { uint64_t old_mask =3D env->psw.mask; @@ -128,12 +148,7 @@ void load_psw(CPUS390XState *env, uint64_t mask, uint6= 4_t addr) } =20 if (mask & PSW_MASK_WAIT) { - S390CPU *cpu =3D s390_env_get_cpu(env); - if (s390_cpu_halt(cpu) =3D=3D 0) { -#ifndef CONFIG_USER_ONLY - qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); -#endif - } + s390_handle_wait(s390_env_get_cpu(env)); } } =20 diff --git a/target/s390x/internal.h b/target/s390x/internal.h index e41fb2e38e..6e500d6bb7 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -352,6 +352,7 @@ void s390_cpu_recompute_watchpoints(CPUState *cs); void s390x_tod_timer(void *opaque); void s390x_cpu_timer(void *opaque); void do_restart_interrupt(CPUS390XState *env); +void s390_handle_wait(S390CPU *cpu); #ifndef CONFIG_USER_ONLY LowCore *cpu_map_lowcore(CPUS390XState *env); void cpu_unmap_lowcore(LowCore *lowcore); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 9b91eeb7a9..8dc82fbb59 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1960,12 +1960,6 @@ static int handle_instruction(S390CPU *cpu, struct k= vm_run *run) return r; } =20 -static bool is_special_wait_psw(CPUState *cs) -{ - /* signal quiesce */ - return cs->kvm_run->psw_addr =3D=3D 0xfffUL; -} - static void unmanageable_intercept(S390CPU *cpu, const char *str, int pswo= ffset) { CPUState *cs =3D CPU(cpu); @@ -2037,13 +2031,7 @@ static int handle_intercept(S390CPU *cpu) case ICPT_WAITPSW: /* disabled wait, since enabled wait is handled in kernel */ cpu_synchronize_state(cs); - if (s390_cpu_halt(cpu) =3D=3D 0) { - if (is_special_wait_psw(cs)) { - qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUT= DOWN); - } else { - qemu_system_guest_panicked(NULL); - } - } + s390_handle_wait(cpu); r =3D EXCP_HALTED; break; case ICPT_CPU_STOP: --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506631535945788.2644450969669; Thu, 28 Sep 2017 13:45:35 -0700 (PDT) Received: from localhost ([::1]:60800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfgN-0001mD-O0 for importer@patchew.org; Thu, 28 Sep 2017 16:45:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYv-0003q1-Kw for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYu-00038c-AJ for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36394) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYu-00038H-44 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:36 -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 2535E4E4D4; Thu, 28 Sep 2017 20:37:35 +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 0EFC617F33; Thu, 28 Sep 2017 20:37:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2535E4E4D4 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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:47 +0200 Message-Id: <20170928203708.9376-10-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.38]); Thu, 28 Sep 2017 20:37:35 +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 09/30] s390x/tcg: handle WAIT PSWs during interrupt injection 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" If we encounter a WAIT PSW, we have to halt immediately. Using cpu_loop_exit() at this point feels wrong. Simply leaving cs->exception_index set doesn't result in an immediate stop. This is also necessary to properly handle SIGP STOP interrupts later. The CPU_INTERRUPT_HALT will be processed immediately and properly set the CPU to halted (also resetting cs->exception_index to EXCP_HLT) Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/excp_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index f6747f3877..1a0d0770a9 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -467,6 +467,12 @@ void s390_cpu_do_interrupt(CPUState *cs) do_mchk_interrupt(env); break; } + + /* WAIT PSW during interrupt injection */ + if (cs->exception_index =3D=3D EXCP_HLT) { + /* don't trigger a cpu_loop_exit(), use an interrupt instead */ + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HALT); + } cs->exception_index =3D -1; =20 /* we might still have pending interrupts, but not deliverable */ --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506631799153688.3441970147438; Thu, 28 Sep 2017 13:49:59 -0700 (PDT) Received: from localhost ([::1]:60820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfki-0005cd-E3 for importer@patchew.org; Thu, 28 Sep 2017 16:49:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYx-0003rX-4Q for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYw-00039S-DU for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58676) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYw-00039A-7L for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:38 -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 412BD81DE8; Thu, 28 Sep 2017 20:37:37 +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 7CC5A6E506; Thu, 28 Sep 2017 20:37:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 412BD81DE8 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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:48 +0200 Message-Id: <20170928203708.9376-11-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.25]); Thu, 28 Sep 2017 20:37:37 +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 10/30] target/s390x: interpret PSW_MASK_WAIT only for TCG 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" KVM handles the wait PSW itself and triggers a WAIT ICPT in case it really want to sleep (disabled wait). This will later allow us to change the order of loading a restart interrupt and setting a CPU to OPERATING on SIGP RESTART without changing KVM behavior. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 2d7df83c59..baa18777f1 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -147,7 +147,8 @@ void load_psw(CPUS390XState *env, uint64_t mask, uint64= _t addr) s390_cpu_recompute_watchpoints(CPU(s390_env_get_cpu(env))); } =20 - if (mask & PSW_MASK_WAIT) { + /* KVM will handle all WAITs and trigger a WAIT exit on disabled_wait = */ + if (tcg_enabled() && (mask & PSW_MASK_WAIT)) { s390_handle_wait(s390_env_get_cpu(env)); } } --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506631684361722.5667119652271; Thu, 28 Sep 2017 13:48:04 -0700 (PDT) Received: from localhost ([::1]:60813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfiw-000472-GD for importer@patchew.org; Thu, 28 Sep 2017 16:47:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfYz-0003u1-IP for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfYy-0003AU-SI for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52008) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfYy-0003A3-M5 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:40 -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 B27B137E68; Thu, 28 Sep 2017 20:37:39 +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 995056E506; Thu, 28 Sep 2017 20:37:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B27B137E68 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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:49 +0200 Message-Id: <20170928203708.9376-12-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.29]); Thu, 28 Sep 2017 20:37:39 +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 11/30] s390x/kvm: pass ipb directly into handle_sigp() 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" No need to pass kvm_run. Pass parameters alphabetically ordered. Reviewed-by: Thomas Huth Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/kvm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 8dc82fbb59..43f8f7331a 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1876,7 +1876,7 @@ static int sigp_set_architecture(S390CPU *cpu, uint32= _t param, return SIGP_CC_STATUS_STORED; } =20 -static int handle_sigp(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) +static int handle_sigp(S390CPU *cpu, uint8_t ipa1, uint32_t ipb) { CPUS390XState *env =3D &cpu->env; const uint8_t r1 =3D ipa1 >> 4; @@ -1890,7 +1890,7 @@ static int handle_sigp(S390CPU *cpu, struct kvm_run *= run, uint8_t ipa1) cpu_synchronize_state(CPU(cpu)); =20 /* get order code */ - order =3D decode_basedisp_rs(env, run->s390_sieic.ipb, NULL) + order =3D decode_basedisp_rs(env, ipb, NULL) & SIGP_ORDER_MASK; status_reg =3D &env->regs[r1]; param =3D (r1 % 2) ? env->regs[r1] : env->regs[r1 + 1]; @@ -1948,7 +1948,7 @@ static int handle_instruction(S390CPU *cpu, struct kv= m_run *run) r =3D handle_diag(cpu, run, run->s390_sieic.ipb); break; case IPA0_SIGP: - r =3D handle_sigp(cpu, run, ipa1); + r =3D handle_sigp(cpu, ipa1, run->s390_sieic.ipb); break; } =20 --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506631334154384.61298161373463; Thu, 28 Sep 2017 13:42:14 -0700 (PDT) Received: from localhost ([::1]:60789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfdE-0007FO-8t for importer@patchew.org; Thu, 28 Sep 2017 16:42:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfZ5-0003wk-2I for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfZ1-0003BY-3L for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52078) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfZ0-0003BB-Qp for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:43 -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 DAEF037E68; Thu, 28 Sep 2017 20:37:41 +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 158E118C57; Thu, 28 Sep 2017 20:37:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DAEF037E68 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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:50 +0200 Message-Id: <20170928203708.9376-13-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.29]); Thu, 28 Sep 2017 20:37:42 +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 12/30] s390x/kvm: generalize SIGP stop and restart interrupt injection 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 factoring it out into !kvm code. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/internal.h | 2 ++ target/s390x/interrupt.c | 20 ++++++++++++++++++++ target/s390x/kvm-stub.c | 8 ++++++++ target/s390x/kvm.c | 33 +++++++++++++++++++++------------ target/s390x/kvm_s390x.h | 2 ++ 5 files changed, 53 insertions(+), 12 deletions(-) diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 6e500d6bb7..0ac026d30f 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -369,6 +369,8 @@ bool s390_cpu_has_io_int(S390CPU *cpu); bool s390_cpu_has_ext_int(S390CPU *cpu); bool s390_cpu_has_mcck_int(S390CPU *cpu); bool s390_cpu_has_int(S390CPU *cpu); +void cpu_inject_restart(S390CPU *cpu); +void cpu_inject_stop(S390CPU *cpu); =20 =20 /* ioinst.c */ diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index c1eaaea98b..64b3f519ef 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -107,6 +107,26 @@ int cpu_inject_external_call(S390CPU *cpu, uint16_t sr= c_cpu_addr) return 0; } =20 +void cpu_inject_restart(S390CPU *cpu) +{ + if (kvm_enabled()) { + kvm_s390_restart_interrupt(cpu); + return; + } + /* FIXME TCG */ + g_assert_not_reached(); +} + +void cpu_inject_stop(S390CPU *cpu) +{ + if (kvm_enabled()) { + kvm_s390_stop_interrupt(cpu); + return; + } + /* FIXME TCG */ + g_assert_not_reached(); +} + 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) diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c index 261e1cdc44..18b53b2ad6 100644 --- a/target/s390x/kvm-stub.c +++ b/target/s390x/kvm-stub.c @@ -109,3 +109,11 @@ int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_= t *hw_limit) void kvm_s390_crypto_reset(void) { } + +void kvm_s390_stop_interrupt(S390CPU *cpu) +{ +} + +void kvm_s390_restart_interrupt(S390CPU *cpu) +{ +} diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 43f8f7331a..7f2623f679 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1502,9 +1502,6 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data a= rg) { S390CPU *cpu =3D S390_CPU(cs); SigpInfo *si =3D arg.host_ptr; - struct kvm_s390_irq irq =3D { - .type =3D KVM_S390_SIGP_STOP, - }; =20 if (s390_cpu_get_state(cpu) !=3D CPU_STATE_OPERATING) { si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; @@ -1517,7 +1514,7 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data a= rg) } else { /* execute the stop function */ cpu->env.sigp_order =3D SIGP_STOP; - kvm_s390_vcpu_interrupt(cpu, &irq); + cpu_inject_stop(cpu); } si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } @@ -1616,9 +1613,6 @@ static void sigp_stop_and_store_status(CPUState *cs, = run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); SigpInfo *si =3D arg.host_ptr; - struct kvm_s390_irq irq =3D { - .type =3D KVM_S390_SIGP_STOP, - }; =20 /* disabled wait - sleeping in user space */ if (s390_cpu_get_state(cpu) =3D=3D CPU_STATE_OPERATING && cs->halted) { @@ -1628,7 +1622,7 @@ static void sigp_stop_and_store_status(CPUState *cs, = run_on_cpu_data arg) switch (s390_cpu_get_state(cpu)) { case CPU_STATE_OPERATING: cpu->env.sigp_order =3D SIGP_STOP_STORE_STATUS; - kvm_s390_vcpu_interrupt(cpu, &irq); + cpu_inject_stop(cpu); /* store will be performed when handling the stop intercept */ break; case CPU_STATE_STOPPED: @@ -1718,9 +1712,6 @@ static void sigp_restart(CPUState *cs, run_on_cpu_dat= a arg) { S390CPU *cpu =3D S390_CPU(cs); SigpInfo *si =3D arg.host_ptr; - struct kvm_s390_irq irq =3D { - .type =3D KVM_S390_RESTART, - }; =20 switch (s390_cpu_get_state(cpu)) { case CPU_STATE_STOPPED: @@ -1730,7 +1721,7 @@ static void sigp_restart(CPUState *cs, run_on_cpu_dat= a arg) s390_cpu_set_state(CPU_STATE_OPERATING, cpu); break; case CPU_STATE_OPERATING: - kvm_s390_vcpu_interrupt(cpu, &irq); + cpu_inject_restart(cpu); break; } si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; @@ -2781,3 +2772,21 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *mo= del, Error **errp) kvm_s390_enable_cmma(); } } + +void kvm_s390_restart_interrupt(S390CPU *cpu) +{ + struct kvm_s390_irq irq =3D { + .type =3D KVM_S390_RESTART, + }; + + kvm_s390_vcpu_interrupt(cpu, &irq); +} + +void kvm_s390_stop_interrupt(S390CPU *cpu) +{ + struct kvm_s390_irq irq =3D { + .type =3D KVM_S390_SIGP_STOP, + }; + + kvm_s390_vcpu_interrupt(cpu, &irq); +} diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h index 2d594bd4ee..fd03cd662a 100644 --- a/target/s390x/kvm_s390x.h +++ b/target/s390x/kvm_s390x.h @@ -40,6 +40,8 @@ void kvm_s390_cmma_reset(void); void kvm_s390_reset_vcpu(S390CPU *cpu); int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_t *hw_limit); void kvm_s390_crypto_reset(void); +void kvm_s390_restart_interrupt(S390CPU *cpu); +void kvm_s390_stop_interrupt(S390CPU *cpu); =20 /* implemented outside of target/s390x/ */ int kvm_s390_inject_flic(struct kvm_s390_irq *irq); --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506631867829844.6922221896375; Thu, 28 Sep 2017 13:51:07 -0700 (PDT) Received: from localhost ([::1]:60827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxflf-0006V0-2U for importer@patchew.org; Thu, 28 Sep 2017 16:50:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfZ5-0003wj-22 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfZ3-0003Cg-Et for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfZ3-0003CG-5S for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:45 -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 2872A883A5; Thu, 28 Sep 2017 20:37:44 +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 406E717F33; Thu, 28 Sep 2017 20:37:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2872A883A5 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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:51 +0200 Message-Id: <20170928203708.9376-14-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.26]); Thu, 28 Sep 2017 20:37:44 +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 13/30] s390x/kvm: factor out storing of CPU status 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" Factor it out into s390_store_status(), to be used also by TCG later on. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/helper.c | 60 ++++++++++++++++++++++++++++++++++++++++++ target/s390x/internal.h | 2 ++ target/s390x/kvm.c | 69 +++------------------------------------------= ---- 3 files changed, 65 insertions(+), 66 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index baa18777f1..4c11822074 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -245,6 +245,66 @@ void s390_cpu_recompute_watchpoints(CPUState *cs) } } =20 +struct sigp_save_area { + uint64_t fprs[16]; /* 0x0000 */ + uint64_t grs[16]; /* 0x0080 */ + PSW psw; /* 0x0100 */ + uint8_t pad_0x0110[0x0118 - 0x0110]; /* 0x0110 */ + uint32_t prefix; /* 0x0118 */ + uint32_t fpc; /* 0x011c */ + uint8_t pad_0x0120[0x0124 - 0x0120]; /* 0x0120 */ + uint32_t todpr; /* 0x0124 */ + uint64_t cputm; /* 0x0128 */ + uint64_t ckc; /* 0x0130 */ + uint8_t pad_0x0138[0x0140 - 0x0138]; /* 0x0138 */ + uint32_t ars[16]; /* 0x0140 */ + uint64_t crs[16]; /* 0x0384 */ +}; +QEMU_BUILD_BUG_ON(sizeof(struct sigp_save_area) !=3D 512); + +int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch) +{ + static const uint8_t ar_id =3D 1; + struct sigp_save_area *sa; + hwaddr len =3D sizeof(*sa); + int i; + + sa =3D cpu_physical_memory_map(addr, &len, 1); + if (!sa) { + return -EFAULT; + } + if (len !=3D sizeof(*sa)) { + cpu_physical_memory_unmap(sa, len, 1, 0); + return -EFAULT; + } + + if (store_arch) { + cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id,= 1); + } + for (i =3D 0; i < 16; ++i) { + sa->fprs[i] =3D cpu_to_be64(get_freg(&cpu->env, i)->ll); + } + for (i =3D 0; i < 16; ++i) { + sa->grs[i] =3D cpu_to_be64(cpu->env.regs[i]); + } + sa->psw.addr =3D cpu_to_be64(cpu->env.psw.addr); + sa->psw.mask =3D cpu_to_be64(get_psw_mask(&cpu->env)); + sa->prefix =3D cpu_to_be32(cpu->env.psa); + sa->fpc =3D cpu_to_be32(cpu->env.fpc); + sa->todpr =3D cpu_to_be32(cpu->env.todpr); + sa->cputm =3D cpu_to_be64(cpu->env.cputm); + sa->ckc =3D cpu_to_be64(cpu->env.ckc >> 8); + for (i =3D 0; i < 16; ++i) { + sa->ars[i] =3D cpu_to_be32(cpu->env.aregs[i]); + } + for (i =3D 0; i < 16; ++i) { + sa->ars[i] =3D cpu_to_be64(cpu->env.cregs[i]); + } + + cpu_physical_memory_unmap(sa, len, 1, len); + + return 0; +} #endif /* CONFIG_USER_ONLY */ =20 void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 0ac026d30f..a301237c17 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -353,6 +353,8 @@ void s390x_tod_timer(void *opaque); void s390x_cpu_timer(void *opaque); void do_restart_interrupt(CPUS390XState *env); void s390_handle_wait(S390CPU *cpu); +#define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area) +int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch); #ifndef CONFIG_USER_ONLY LowCore *cpu_map_lowcore(CPUS390XState *env); void cpu_unmap_lowcore(LowCore *lowcore); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 7f2623f679..c7d0145fa9 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1547,68 +1547,6 @@ static int do_store_adtl_status(S390CPU *cpu, hwaddr= addr, hwaddr len) return 0; } =20 -struct sigp_save_area { - uint64_t fprs[16]; /* 0x0000 */ - uint64_t grs[16]; /* 0x0080 */ - PSW psw; /* 0x0100 */ - uint8_t pad_0x0110[0x0118 - 0x0110]; /* 0x0110 */ - uint32_t prefix; /* 0x0118 */ - uint32_t fpc; /* 0x011c */ - uint8_t pad_0x0120[0x0124 - 0x0120]; /* 0x0120 */ - uint32_t todpr; /* 0x0124 */ - uint64_t cputm; /* 0x0128 */ - uint64_t ckc; /* 0x0130 */ - uint8_t pad_0x0138[0x0140 - 0x0138]; /* 0x0138 */ - uint32_t ars[16]; /* 0x0140 */ - uint64_t crs[16]; /* 0x0384 */ -}; -QEMU_BUILD_BUG_ON(sizeof(struct sigp_save_area) !=3D 512); - -#define KVM_S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_= area) -static int kvm_s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arc= h) -{ - static const uint8_t ar_id =3D 1; - struct sigp_save_area *sa; - hwaddr len =3D sizeof(*sa); - int i; - - sa =3D cpu_physical_memory_map(addr, &len, 1); - if (!sa) { - return -EFAULT; - } - if (len !=3D sizeof(*sa)) { - cpu_physical_memory_unmap(sa, len, 1, 0); - return -EFAULT; - } - - if (store_arch) { - cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id,= 1); - } - for (i =3D 0; i < 16; ++i) { - sa->fprs[i] =3D cpu_to_be64(get_freg(&cpu->env, i)->ll); - } - for (i =3D 0; i < 16; ++i) { - sa->grs[i] =3D cpu_to_be64(cpu->env.regs[i]); - } - sa->psw.addr =3D cpu_to_be64(cpu->env.psw.addr); - sa->psw.mask =3D cpu_to_be64(get_psw_mask(&cpu->env)); - sa->prefix =3D cpu_to_be32(cpu->env.psa); - sa->fpc =3D cpu_to_be32(cpu->env.fpc); - sa->todpr =3D cpu_to_be32(cpu->env.todpr); - sa->cputm =3D cpu_to_be64(cpu->env.cputm); - sa->ckc =3D cpu_to_be64(cpu->env.ckc >> 8); - for (i =3D 0; i < 16; ++i) { - sa->ars[i] =3D cpu_to_be32(cpu->env.aregs[i]); - } - for (i =3D 0; i < 16; ++i) { - sa->ars[i] =3D cpu_to_be64(cpu->env.cregs[i]); - } - - cpu_physical_memory_unmap(sa, len, 1, len); - - return 0; -} - static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -1628,7 +1566,7 @@ static void sigp_stop_and_store_status(CPUState *cs, = run_on_cpu_data arg) case CPU_STATE_STOPPED: /* already stopped, just store the status */ cpu_synchronize_state(cs); - kvm_s390_store_status(cpu, KVM_S390_STORE_STATUS_DEF_ADDR, true); + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); break; } si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; @@ -1648,7 +1586,7 @@ static void sigp_store_status_at_address(CPUState *cs= , run_on_cpu_data arg) =20 cpu_synchronize_state(cs); =20 - if (kvm_s390_store_status(cpu, address, false)) { + if (s390_store_status(cpu, address, false)) { set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); return; } @@ -2030,8 +1968,7 @@ static int handle_intercept(S390CPU *cpu) qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN= ); } if (cpu->env.sigp_order =3D=3D SIGP_STOP_STORE_STATUS) { - kvm_s390_store_status(cpu, KVM_S390_STORE_STATUS_DEF_ADDR, - true); + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); } cpu->env.sigp_order =3D 0; r =3D EXCP_HALTED; --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506631481910608.7768791670528; Thu, 28 Sep 2017 13:44:41 -0700 (PDT) Received: from localhost ([::1]:60796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxffV-0000wv-Dy for importer@patchew.org; Thu, 28 Sep 2017 16:44:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfZI-00048Y-JE for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfZE-0003Hp-Lm for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58954) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfZE-0003HO-DY for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:56 -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 6C34885376; Thu, 28 Sep 2017 20:37:55 +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 841E118C67; Thu, 28 Sep 2017 20:37:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6C34885376 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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:52 +0200 Message-Id: <20170928203708.9376-15-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.25]); Thu, 28 Sep 2017 20:37:55 +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 14/30] s390x/kvm: factor out storing of adtl CPU status 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" Called from SIGP code to be factored out, so let's move it. Add a FIXME for TCG code in the future. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/helper.c | 29 +++++++++++++++++++++++++++++ target/s390x/internal.h | 1 + target/s390x/kvm.c | 30 +----------------------------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 4c11822074..2505f3aec0 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -305,6 +305,35 @@ int s390_store_status(S390CPU *cpu, hwaddr addr, bool = store_arch) =20 return 0; } + +#define ADTL_GS_OFFSET 1024 /* offset of GS data in adtl save area */ +#define ADTL_GS_MIN_SIZE 2048 /* minimal size of adtl save area for GS */ +int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) +{ + hwaddr save =3D len; + void *mem; + + mem =3D cpu_physical_memory_map(addr, &save, 1); + if (!mem) { + return -EFAULT; + } + if (save !=3D len) { + cpu_physical_memory_unmap(mem, len, 1, 0); + return -EFAULT; + } + + /* FIXME: as soon as TCG supports these features, convert cpu->be */ + if (s390_has_feat(S390_FEAT_VECTOR)) { + memcpy(mem, &cpu->env.vregs, 512); + } + if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && len >=3D ADTL_GS_MIN_S= IZE) { + memcpy(mem + ADTL_GS_OFFSET, &cpu->env.gscb, 32); + } + + cpu_physical_memory_unmap(mem, len, 1, len); + + return 0; +} #endif /* CONFIG_USER_ONLY */ =20 void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, diff --git a/target/s390x/internal.h b/target/s390x/internal.h index a301237c17..fb8ff6b078 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -355,6 +355,7 @@ void do_restart_interrupt(CPUS390XState *env); void s390_handle_wait(S390CPU *cpu); #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area) int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch); +int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len); #ifndef CONFIG_USER_ONLY LowCore *cpu_map_lowcore(CPUS390XState *env); void cpu_unmap_lowcore(LowCore *lowcore); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index c7d0145fa9..1aec1e26d4 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1519,34 +1519,6 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data = arg) si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } =20 -#define ADTL_GS_OFFSET 1024 /* offset of GS data in adtl save area */ -#define ADTL_GS_MIN_SIZE 2048 /* minimal size of adtl save area for GS */ -static int do_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) -{ - hwaddr save =3D len; - void *mem; - - mem =3D cpu_physical_memory_map(addr, &save, 1); - if (!mem) { - return -EFAULT; - } - if (save !=3D len) { - cpu_physical_memory_unmap(mem, len, 1, 0); - return -EFAULT; - } - - if (s390_has_feat(S390_FEAT_VECTOR)) { - memcpy(mem, &cpu->env.vregs, 512); - } - if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && len >=3D ADTL_GS_MIN_S= IZE) { - memcpy(mem + ADTL_GS_OFFSET, &cpu->env.gscb, 32); - } - - cpu_physical_memory_unmap(mem, len, 1, len); - - return 0; -} - static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -1639,7 +1611,7 @@ static void sigp_store_adtl_status(CPUState *cs, run_= on_cpu_data arg) =20 cpu_synchronize_state(cs); =20 - if (do_store_adtl_status(cpu, addr, len)) { + if (s390_store_adtl_status(cpu, addr, len)) { set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); return; } --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1506631486739910.687338738195; Thu, 28 Sep 2017 13:44:46 -0700 (PDT) Received: from localhost ([::1]:60798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfff-00017D-9d for importer@patchew.org; Thu, 28 Sep 2017 16:44:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfZU-0004Jy-JK for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfZQ-0003Me-Lv for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45554) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfZQ-0003M6-Fi for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:08 -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 67266C057F91; Thu, 28 Sep 2017 20:38:07 +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 C513C18C57; Thu, 28 Sep 2017 20:37:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 67266C057F91 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:53 +0200 Message-Id: <20170928203708.9376-16-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:38:07 +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 15/30] s390x/kvm: drop two debug prints 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_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Preparation for moving it out of kvm.c. Reviewed-by: Thomas Huth Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/kvm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 1aec1e26d4..fbbdca23b2 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1642,7 +1642,6 @@ int kvm_s390_cpu_restart(S390CPU *cpu) SigpInfo si =3D {}; =20 run_on_cpu(CPU(cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); - DPRINTF("DONE: KVM cpu restart: %p\n", &cpu->env); return 0; } =20 @@ -1744,7 +1743,6 @@ static int handle_sigp_single_dst(S390CPU *dst_cpu, u= int8_t order, run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si)); break; default: - DPRINTF("KVM: unknown SIGP: 0x%x\n", order); set_sigp_status(&si, SIGP_STAT_INVALID_ORDER); } =20 --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506632020096122.42281167111241; Thu, 28 Sep 2017 13:53:40 -0700 (PDT) Received: from localhost ([::1]:60835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfoI-0000lH-5C for importer@patchew.org; Thu, 28 Sep 2017 16:53:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfZi-0004VU-0B for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfZd-0003QO-RW for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5462) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfZd-0003QB-GC for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38: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 7F1EEC0587C2; Thu, 28 Sep 2017 20:38:20 +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 C032217F33; Thu, 28 Sep 2017 20:38:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7F1EEC0587C2 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:54 +0200 Message-Id: <20170928203708.9376-17-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:38: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 16/30] s390x/kvm: factor out SIGP code into sigp.c 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" We want to use the same code base for TCG, so let's cleanly factor it out. The sigp mutex is currently not really needed, as everything is protected by the iothread mutex. But this could change later, so leave it in place and initialize it properly from common code. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- hw/s390x/s390-virtio-ccw.c | 3 + target/s390x/Makefile.objs | 1 + target/s390x/cpu.c | 8 - target/s390x/cpu.h | 6 +- target/s390x/internal.h | 4 + target/s390x/kvm-stub.c | 5 - target/s390x/kvm.c | 349 +----------------------------------------- target/s390x/kvm_s390x.h | 1 - target/s390x/sigp.c | 366 +++++++++++++++++++++++++++++++++++++++++= ++++ target/s390x/trace-events | 4 +- 10 files changed, 388 insertions(+), 359 deletions(-) create mode 100644 target/s390x/sigp.c diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index c747b22d66..d188ce17ba 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -265,6 +265,9 @@ static void ccw_init(MachineState *machine) /* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus(machine); =20 + /* init the SIGP facility */ + s390_init_sigp(); + /* get a BUS */ css_bus =3D virtual_css_bus_init(); s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline, diff --git a/target/s390x/Makefile.objs b/target/s390x/Makefile.objs index c88ac81e84..31932de9cf 100644 --- a/target/s390x/Makefile.objs +++ b/target/s390x/Makefile.objs @@ -2,6 +2,7 @@ obj-y +=3D cpu.o cpu_models.o cpu_features.o gdbstub.o inte= rrupt.o helper.o obj-$(CONFIG_TCG) +=3D translate.o cc_helper.o excp_helper.o fpu_helper.o obj-$(CONFIG_TCG) +=3D int_helper.o mem_helper.o misc_helper.o crypto_help= er.o obj-$(CONFIG_SOFTMMU) +=3D machine.o ioinst.o arch_dump.o mmu_helper.o dia= g.o +obj-$(CONFIG_SOFTMMU) +=3D sigp.o obj-$(CONFIG_KVM) +=3D kvm.o obj-$(call lnot,$(CONFIG_KVM)) +=3D kvm-stub.o =20 diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index a0b139056f..e27827afb3 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -386,14 +386,6 @@ void s390_cmma_reset(void) } } =20 -int s390_cpu_restart(S390CPU *cpu) -{ - if (kvm_enabled()) { - return kvm_s390_cpu_restart(cpu); - } - return -ENOSYS; -} - int s390_get_memslot_count(void) { if (kvm_enabled()) { diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 6ae0c7dfc8..f94d7f96e0 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -676,7 +676,6 @@ bool s390_get_squash_mcss(void); int s390_get_memslot_count(void); int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit); void s390_cmma_reset(void); -int s390_cpu_restart(S390CPU *cpu); void s390_enable_css_support(S390CPU *cpu); int s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch_id, int vq, bool assign); @@ -730,6 +729,11 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, ui= nt8_t ar, void *hostbuf, s390_cpu_virt_mem_rw(cpu, laddr, ar, NULL, len, true) =20 =20 +/* sigp.c */ +int s390_cpu_restart(S390CPU *cpu); +void s390_init_sigp(void); + + /* outside of target/s390x/ */ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr); =20 diff --git a/target/s390x/internal.h b/target/s390x/internal.h index fb8ff6b078..d6ab45add4 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -415,4 +415,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, u= int64_t r3); /* translate.c */ void s390x_translate_init(void); =20 + +/* sigp.c */ +int handle_sigp(CPUS390XState *env, uint8_t order, uint64_t r1, uint64_t r= 3); + #endif /* S390X_INTERNAL_H */ diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c index 18b53b2ad6..861b4dedf6 100644 --- a/target/s390x/kvm-stub.c +++ b/target/s390x/kvm-stub.c @@ -83,11 +83,6 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notif= ier, uint32_t sch, return -ENOSYS; } =20 -int kvm_s390_cpu_restart(S390CPU *cpu) -{ - return -ENOSYS; -} - void kvm_s390_cmma_reset(void) { } diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index fbbdca23b2..1174e249ab 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -135,8 +135,6 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[= ] =3D { KVM_CAP_LAST_INFO }; =20 -static QemuMutex qemu_sigp_mutex; - static int cap_sync_regs; static int cap_async_pf; static int cap_mem_op; @@ -316,8 +314,6 @@ int kvm_arch_init(MachineState *ms, KVMState *s) =20 /* The AIS enablement happens in the flic realize */ =20 - qemu_mutex_init(&qemu_sigp_mutex); - return 0; } =20 @@ -1471,355 +1467,22 @@ static int handle_diag(S390CPU *cpu, struct kvm_ru= n *run, uint32_t ipb) return r; } =20 -typedef struct SigpInfo { - uint64_t param; - int cc; - uint64_t *status_reg; -} SigpInfo; - -static void set_sigp_status(SigpInfo *si, uint64_t status) -{ - *si->status_reg &=3D 0xffffffff00000000ULL; - *si->status_reg |=3D status; - si->cc =3D SIGP_CC_STATUS_STORED; -} - -static void sigp_start(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - - if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; - return; - } - - s390_cpu_set_state(CPU_STATE_OPERATING, cpu); - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_stop(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - - if (s390_cpu_get_state(cpu) !=3D CPU_STATE_OPERATING) { - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; - return; - } - - /* disabled wait - sleeping in user space */ - if (cs->halted) { - s390_cpu_set_state(CPU_STATE_STOPPED, cpu); - } else { - /* execute the stop function */ - cpu->env.sigp_order =3D SIGP_STOP; - cpu_inject_stop(cpu); - } - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - - /* disabled wait - sleeping in user space */ - if (s390_cpu_get_state(cpu) =3D=3D CPU_STATE_OPERATING && cs->halted) { - s390_cpu_set_state(CPU_STATE_STOPPED, cpu); - } - - switch (s390_cpu_get_state(cpu)) { - case CPU_STATE_OPERATING: - cpu->env.sigp_order =3D SIGP_STOP_STORE_STATUS; - cpu_inject_stop(cpu); - /* store will be performed when handling the stop intercept */ - break; - case CPU_STATE_STOPPED: - /* already stopped, just store the status */ - cpu_synchronize_state(cs); - s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); - break; - } - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_store_status_at_address(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - uint32_t address =3D si->param & 0x7ffffe00u; - - /* cpu has to be stopped */ - if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { - set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); - return; - } - - cpu_synchronize_state(cs); - - if (s390_store_status(cpu, address, false)) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -#define ADTL_SAVE_LC_MASK 0xfUL -static void sigp_store_adtl_status(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - uint8_t lc =3D si->param & ADTL_SAVE_LC_MASK; - hwaddr addr =3D si->param & ~ADTL_SAVE_LC_MASK; - hwaddr len =3D 1UL << (lc ? lc : 10); - - if (!s390_has_feat(S390_FEAT_VECTOR) && - !s390_has_feat(S390_FEAT_GUARDED_STORAGE)) { - set_sigp_status(si, SIGP_STAT_INVALID_ORDER); - return; - } - - /* cpu has to be stopped */ - if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { - set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); - return; - } - - /* address must be aligned to length */ - if (addr & (len - 1)) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - - /* no GS: only lc =3D=3D 0 is valid */ - if (!s390_has_feat(S390_FEAT_GUARDED_STORAGE) && - lc !=3D 0) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - - /* GS: 0, 10, 11, 12 are valid */ - if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && - lc !=3D 0 && - lc !=3D 10 && - lc !=3D 11 && - lc !=3D 12) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - - cpu_synchronize_state(cs); - - if (s390_store_adtl_status(cpu, addr, len)) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_restart(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - - switch (s390_cpu_get_state(cpu)) { - case CPU_STATE_STOPPED: - /* the restart irq has to be delivered prior to any other pending = irq */ - cpu_synchronize_state(cs); - do_restart_interrupt(&cpu->env); - s390_cpu_set_state(CPU_STATE_OPERATING, cpu); - break; - case CPU_STATE_OPERATING: - cpu_inject_restart(cpu); - break; - } - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -int kvm_s390_cpu_restart(S390CPU *cpu) -{ - SigpInfo si =3D {}; - - run_on_cpu(CPU(cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); - return 0; -} - -static void sigp_initial_cpu_reset(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); - SigpInfo *si =3D arg.host_ptr; - - cpu_synchronize_state(cs); - scc->initial_cpu_reset(cs); - cpu_synchronize_post_reset(cs); - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); - SigpInfo *si =3D arg.host_ptr; - - cpu_synchronize_state(cs); - scc->cpu_reset(cs); - cpu_synchronize_post_reset(cs); - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - uint32_t addr =3D si->param & 0x7fffe000u; - - cpu_synchronize_state(cs); - - if (!address_space_access_valid(&address_space_memory, addr, - sizeof(struct LowCore), false)) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - - /* cpu has to be stopped */ - if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { - set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); - return; - } - - cpu->env.psa =3D addr; - cpu_synchronize_post_init(cs); - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static int handle_sigp_single_dst(S390CPU *dst_cpu, uint8_t order, - uint64_t param, uint64_t *status_reg) -{ - SigpInfo si =3D { - .param =3D param, - .status_reg =3D status_reg, - }; - - /* cpu available? */ - if (dst_cpu =3D=3D NULL) { - return SIGP_CC_NOT_OPERATIONAL; - } - - /* only resets can break pending orders */ - if (dst_cpu->env.sigp_order !=3D 0 && - order !=3D SIGP_CPU_RESET && - order !=3D SIGP_INITIAL_CPU_RESET) { - return SIGP_CC_BUSY; - } - - switch (order) { - case SIGP_START: - run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si)); - break; - case SIGP_STOP: - run_on_cpu(CPU(dst_cpu), sigp_stop, RUN_ON_CPU_HOST_PTR(&si)); - break; - case SIGP_RESTART: - run_on_cpu(CPU(dst_cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); - break; - case SIGP_STOP_STORE_STATUS: - run_on_cpu(CPU(dst_cpu), sigp_stop_and_store_status, RUN_ON_CPU_HO= ST_PTR(&si)); - break; - case SIGP_STORE_STATUS_ADDR: - run_on_cpu(CPU(dst_cpu), sigp_store_status_at_address, RUN_ON_CPU_= HOST_PTR(&si)); - break; - case SIGP_STORE_ADTL_STATUS: - run_on_cpu(CPU(dst_cpu), sigp_store_adtl_status, RUN_ON_CPU_HOST_P= TR(&si)); - break; - case SIGP_SET_PREFIX: - run_on_cpu(CPU(dst_cpu), sigp_set_prefix, RUN_ON_CPU_HOST_PTR(&si)= ); - break; - case SIGP_INITIAL_CPU_RESET: - run_on_cpu(CPU(dst_cpu), sigp_initial_cpu_reset, RUN_ON_CPU_HOST_P= TR(&si)); - break; - case SIGP_CPU_RESET: - run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si)); - break; - default: - set_sigp_status(&si, SIGP_STAT_INVALID_ORDER); - } - - return si.cc; -} - -static int sigp_set_architecture(S390CPU *cpu, uint32_t param, - uint64_t *status_reg) -{ - CPUState *cur_cs; - S390CPU *cur_cpu; - bool all_stopped =3D true; - - CPU_FOREACH(cur_cs) { - cur_cpu =3D S390_CPU(cur_cs); - - if (cur_cpu =3D=3D cpu) { - continue; - } - if (s390_cpu_get_state(cur_cpu) !=3D CPU_STATE_STOPPED) { - all_stopped =3D false; - } - } - - *status_reg &=3D 0xffffffff00000000ULL; - - /* Reject set arch order, with czam we're always in z/Arch mode. */ - *status_reg |=3D (all_stopped ? SIGP_STAT_INVALID_PARAMETER : - SIGP_STAT_INCORRECT_STATE); - return SIGP_CC_STATUS_STORED; -} - -static int handle_sigp(S390CPU *cpu, uint8_t ipa1, uint32_t ipb) +static int kvm_s390_handle_sigp(S390CPU *cpu, uint8_t ipa1, uint32_t ipb) { CPUS390XState *env =3D &cpu->env; const uint8_t r1 =3D ipa1 >> 4; const uint8_t r3 =3D ipa1 & 0x0f; int ret; uint8_t order; - uint64_t *status_reg; - uint64_t param; - S390CPU *dst_cpu =3D NULL; =20 cpu_synchronize_state(CPU(cpu)); =20 /* get order code */ - order =3D decode_basedisp_rs(env, ipb, NULL) - & SIGP_ORDER_MASK; - status_reg =3D &env->regs[r1]; - param =3D (r1 % 2) ? env->regs[r1] : env->regs[r1 + 1]; + order =3D decode_basedisp_rs(env, ipb, NULL) & SIGP_ORDER_MASK; =20 - if (qemu_mutex_trylock(&qemu_sigp_mutex)) { - ret =3D SIGP_CC_BUSY; - goto out; - } - - switch (order) { - case SIGP_SET_ARCH: - ret =3D sigp_set_architecture(cpu, param, status_reg); - break; - default: - /* all other sigp orders target a single vcpu */ - dst_cpu =3D s390_cpu_addr2state(env->regs[r3]); - ret =3D handle_sigp_single_dst(dst_cpu, order, param, status_reg); - } - qemu_mutex_unlock(&qemu_sigp_mutex); - -out: - trace_kvm_sigp_finished(order, CPU(cpu)->cpu_index, - dst_cpu ? CPU(dst_cpu)->cpu_index : -1, ret); - - if (ret >=3D 0) { - setcc(cpu, ret); - return 0; - } - - return ret; + ret =3D handle_sigp(env, order, r1, r3); + setcc(cpu, ret); + return 0; } =20 static int handle_instruction(S390CPU *cpu, struct kvm_run *run) @@ -1847,7 +1510,7 @@ static int handle_instruction(S390CPU *cpu, struct kv= m_run *run) r =3D handle_diag(cpu, run, run->s390_sieic.ipb); break; case IPA0_SIGP: - r =3D handle_sigp(cpu, ipa1, run->s390_sieic.ipb); + r =3D kvm_s390_handle_sigp(cpu, ipa1, run->s390_sieic.ipb); break; } =20 diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h index fd03cd662a..33906a893b 100644 --- a/target/s390x/kvm_s390x.h +++ b/target/s390x/kvm_s390x.h @@ -33,7 +33,6 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_c= lock); void kvm_s390_enable_css_support(S390CPU *cpu); int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, int vq, bool assign); -int kvm_s390_cpu_restart(S390CPU *cpu); int kvm_s390_get_memslot_count(void); int kvm_s390_cmma_active(void); void kvm_s390_cmma_reset(void); diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c new file mode 100644 index 0000000000..4813123aad --- /dev/null +++ b/target/s390x/sigp.c @@ -0,0 +1,366 @@ +/* + * s390x SIGP instruction handling + * + * Copyright (c) 2009 Alexander Graf + * Copyright IBM Corp. 2012 + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "cpu.h" +#include "internal.h" +#include "sysemu/hw_accel.h" +#include "exec/address-spaces.h" +#include "sysemu/sysemu.h" +#include "trace.h" + +QemuMutex qemu_sigp_mutex; + +typedef struct SigpInfo { + uint64_t param; + int cc; + uint64_t *status_reg; +} SigpInfo; + +static void set_sigp_status(SigpInfo *si, uint64_t status) +{ + *si->status_reg &=3D 0xffffffff00000000ULL; + *si->status_reg |=3D status; + si->cc =3D SIGP_CC_STATUS_STORED; +} + +static void sigp_start(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + return; + } + + s390_cpu_set_state(CPU_STATE_OPERATING, cpu); + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_stop(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_OPERATING) { + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + return; + } + + /* disabled wait - sleeping in user space */ + if (cs->halted) { + s390_cpu_set_state(CPU_STATE_STOPPED, cpu); + } else { + /* execute the stop function */ + cpu->env.sigp_order =3D SIGP_STOP; + cpu_inject_stop(cpu); + } + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + + /* disabled wait - sleeping in user space */ + if (s390_cpu_get_state(cpu) =3D=3D CPU_STATE_OPERATING && cs->halted) { + s390_cpu_set_state(CPU_STATE_STOPPED, cpu); + } + + switch (s390_cpu_get_state(cpu)) { + case CPU_STATE_OPERATING: + cpu->env.sigp_order =3D SIGP_STOP_STORE_STATUS; + cpu_inject_stop(cpu); + /* store will be performed when handling the stop intercept */ + break; + case CPU_STATE_STOPPED: + /* already stopped, just store the status */ + cpu_synchronize_state(cs); + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); + break; + } + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_store_status_at_address(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + uint32_t address =3D si->param & 0x7ffffe00u; + + /* cpu has to be stopped */ + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { + set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); + return; + } + + cpu_synchronize_state(cs); + + if (s390_store_status(cpu, address, false)) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +#define ADTL_SAVE_LC_MASK 0xfUL +static void sigp_store_adtl_status(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + uint8_t lc =3D si->param & ADTL_SAVE_LC_MASK; + hwaddr addr =3D si->param & ~ADTL_SAVE_LC_MASK; + hwaddr len =3D 1UL << (lc ? lc : 10); + + if (!s390_has_feat(S390_FEAT_VECTOR) && + !s390_has_feat(S390_FEAT_GUARDED_STORAGE)) { + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + /* cpu has to be stopped */ + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { + set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); + return; + } + + /* address must be aligned to length */ + if (addr & (len - 1)) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + + /* no GS: only lc =3D=3D 0 is valid */ + if (!s390_has_feat(S390_FEAT_GUARDED_STORAGE) && + lc !=3D 0) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + + /* GS: 0, 10, 11, 12 are valid */ + if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && + lc !=3D 0 && + lc !=3D 10 && + lc !=3D 11 && + lc !=3D 12) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + + cpu_synchronize_state(cs); + + if (s390_store_adtl_status(cpu, addr, len)) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_restart(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + + switch (s390_cpu_get_state(cpu)) { + case CPU_STATE_STOPPED: + /* the restart irq has to be delivered prior to any other pending = irq */ + cpu_synchronize_state(cs); + do_restart_interrupt(&cpu->env); + s390_cpu_set_state(CPU_STATE_OPERATING, cpu); + break; + case CPU_STATE_OPERATING: + cpu_inject_restart(cpu); + break; + } + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_initial_cpu_reset(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); + SigpInfo *si =3D arg.host_ptr; + + cpu_synchronize_state(cs); + scc->initial_cpu_reset(cs); + cpu_synchronize_post_reset(cs); + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); + SigpInfo *si =3D arg.host_ptr; + + cpu_synchronize_state(cs); + scc->cpu_reset(cs); + cpu_synchronize_post_reset(cs); + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + uint32_t addr =3D si->param & 0x7fffe000u; + + cpu_synchronize_state(cs); + + if (!address_space_access_valid(&address_space_memory, addr, + sizeof(struct LowCore), false)) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + + /* cpu has to be stopped */ + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { + set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); + return; + } + + cpu->env.psa =3D addr; + cpu_synchronize_post_init(cs); + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static int handle_sigp_single_dst(S390CPU *dst_cpu, uint8_t order, + uint64_t param, uint64_t *status_reg) +{ + SigpInfo si =3D { + .param =3D param, + .status_reg =3D status_reg, + }; + + /* cpu available? */ + if (dst_cpu =3D=3D NULL) { + return SIGP_CC_NOT_OPERATIONAL; + } + + /* only resets can break pending orders */ + if (dst_cpu->env.sigp_order !=3D 0 && + order !=3D SIGP_CPU_RESET && + order !=3D SIGP_INITIAL_CPU_RESET) { + return SIGP_CC_BUSY; + } + + switch (order) { + case SIGP_START: + run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si)); + break; + case SIGP_STOP: + run_on_cpu(CPU(dst_cpu), sigp_stop, RUN_ON_CPU_HOST_PTR(&si)); + break; + case SIGP_RESTART: + run_on_cpu(CPU(dst_cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); + break; + case SIGP_STOP_STORE_STATUS: + run_on_cpu(CPU(dst_cpu), sigp_stop_and_store_status, RUN_ON_CPU_HO= ST_PTR(&si)); + break; + case SIGP_STORE_STATUS_ADDR: + run_on_cpu(CPU(dst_cpu), sigp_store_status_at_address, RUN_ON_CPU_= HOST_PTR(&si)); + break; + case SIGP_STORE_ADTL_STATUS: + run_on_cpu(CPU(dst_cpu), sigp_store_adtl_status, RUN_ON_CPU_HOST_P= TR(&si)); + break; + case SIGP_SET_PREFIX: + run_on_cpu(CPU(dst_cpu), sigp_set_prefix, RUN_ON_CPU_HOST_PTR(&si)= ); + break; + case SIGP_INITIAL_CPU_RESET: + run_on_cpu(CPU(dst_cpu), sigp_initial_cpu_reset, RUN_ON_CPU_HOST_P= TR(&si)); + break; + case SIGP_CPU_RESET: + run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si)); + break; + default: + set_sigp_status(&si, SIGP_STAT_INVALID_ORDER); + } + + return si.cc; +} + +static int sigp_set_architecture(S390CPU *cpu, uint32_t param, + uint64_t *status_reg) +{ + CPUState *cur_cs; + S390CPU *cur_cpu; + bool all_stopped =3D true; + + CPU_FOREACH(cur_cs) { + cur_cpu =3D S390_CPU(cur_cs); + + if (cur_cpu =3D=3D cpu) { + continue; + } + if (s390_cpu_get_state(cur_cpu) !=3D CPU_STATE_STOPPED) { + all_stopped =3D false; + } + } + + *status_reg &=3D 0xffffffff00000000ULL; + + /* Reject set arch order, with czam we're always in z/Arch mode. */ + *status_reg |=3D (all_stopped ? SIGP_STAT_INVALID_PARAMETER : + SIGP_STAT_INCORRECT_STATE); + return SIGP_CC_STATUS_STORED; +} + +int handle_sigp(CPUS390XState *env, uint8_t order, uint64_t r1, uint64_t r= 3) +{ + uint64_t *status_reg =3D &env->regs[r1]; + uint64_t param =3D (r1 % 2) ? env->regs[r1] : env->regs[r1 + 1]; + S390CPU *cpu =3D s390_env_get_cpu(env); + S390CPU *dst_cpu =3D NULL; + int ret; + + if (qemu_mutex_trylock(&qemu_sigp_mutex)) { + ret =3D SIGP_CC_BUSY; + goto out; + } + + switch (order) { + case SIGP_SET_ARCH: + ret =3D sigp_set_architecture(cpu, param, status_reg); + break; + default: + /* all other sigp orders target a single vcpu */ + dst_cpu =3D s390_cpu_addr2state(env->regs[r3]); + ret =3D handle_sigp_single_dst(dst_cpu, order, param, status_reg); + } + qemu_mutex_unlock(&qemu_sigp_mutex); + +out: + trace_sigp_finished(order, CPU(cpu)->cpu_index, + dst_cpu ? CPU(dst_cpu)->cpu_index : -1, ret); + g_assert(ret >=3D 0); + + return ret; +} + +int s390_cpu_restart(S390CPU *cpu) +{ + SigpInfo si =3D {}; + + if (tcg_enabled()) { + /* FIXME TCG */ + return -ENOSYS; + } + + run_on_cpu(CPU(cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); + return 0; +} + +void s390_init_sigp(void) +{ + qemu_mutex_init(&qemu_sigp_mutex); +} diff --git a/target/s390x/trace-events b/target/s390x/trace-events index 4d871f5087..a84e316e49 100644 --- a/target/s390x/trace-events +++ b/target/s390x/trace-events @@ -14,9 +14,11 @@ ioinst_chsc_cmd(uint16_t cmd, uint16_t len) "IOINST: chs= c command 0x%04x, len 0x kvm_enable_cmma(int rc) "CMMA: enabling with result code %d" kvm_clear_cmma(int rc) "CMMA: clearing with result code %d" kvm_failed_cpu_state_set(int cpu_index, uint8_t state, const char *msg) "W= arning: Unable to set cpu %d state %" PRIu8 " to KVM: %s" -kvm_sigp_finished(uint8_t order, int cpu_index, int dst_index, int cc) "SI= GP: Finished order %u on cpu %d -> cpu %d with cc=3D%d" =20 # target/s390x/cpu.c cpu_set_state(int cpu_index, uint8_t state) "setting cpu %d state to %" PR= Iu8 cpu_halt(int cpu_index) "halting cpu %d" cpu_unhalt(int cpu_index) "unhalting cpu %d" + +# target/s390x/sigp.c +sigp_finished(uint8_t order, int cpu_index, int dst_index, int cc) "SIGP: = Finished order %u on cpu %d -> cpu %d with cc=3D%d" --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1506631637656592.0829599395371; Thu, 28 Sep 2017 13:47:17 -0700 (PDT) Received: from localhost ([::1]:60810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfi1-0003Jh-Tg for importer@patchew.org; Thu, 28 Sep 2017 16:47:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfZq-0004cs-SE for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfZm-0003U3-UB for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59211) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfZm-0003Tf-Nw for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:30 -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 C2B65C04AC42; Thu, 28 Sep 2017 20:38:29 +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 D84F76E506; Thu, 28 Sep 2017 20:38:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C2B65C04AC42 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.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:55 +0200 Message-Id: <20170928203708.9376-18-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.31]); Thu, 28 Sep 2017 20:38:29 +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 17/30] MAINTAINERS: use s390 KVM maintainers for target/s390x/sigp.c 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_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" All code in target/s390x/sigp.c was factored out from target/s390x/kvm.c, so let's also copy the entry in the MAINTAINERS file. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 772ac209e1..d34a72320c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -303,6 +303,7 @@ F: target/s390x/kvm_s390x.h F: target/s390x/kvm-stub.c F: target/s390x/ioinst.[ch] F: target/s390x/machine.c +F: target/s390x/sigp.c F: hw/intc/s390_flic.c F: hw/intc/s390_flic_kvm.c F: include/hw/s390x/s390_flic.h --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506631804115694.363042462543; Thu, 28 Sep 2017 13:50:04 -0700 (PDT) Received: from localhost ([::1]:60819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfkh-0005b9-TK for importer@patchew.org; Thu, 28 Sep 2017 16:49:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfa2-0004lP-1h for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfZy-0003Y9-4R for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55500) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfZx-0003Xr-Rw for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:42 -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 D5B432BA922; Thu, 28 Sep 2017 20:38:40 +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 240B86E506; Thu, 28 Sep 2017 20:38:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D5B432BA922 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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:56 +0200 Message-Id: <20170928203708.9376-19-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.29]); Thu, 28 Sep 2017 20:38:41 +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 18/30] s390x/kvm: factor out actual handling of STOP interrupts 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" For KVM, the KVM module decides when a STOP can be performed (when the STOP interrupt can be processed). Factor it out so we can use it later for TCG. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/internal.h | 1 + target/s390x/kvm.c | 8 +------- target/s390x/sigp.c | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/target/s390x/internal.h b/target/s390x/internal.h index d6ab45add4..2c3fc3fce0 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -418,5 +418,6 @@ void s390x_translate_init(void); =20 /* sigp.c */ int handle_sigp(CPUS390XState *env, uint8_t order, uint64_t r1, uint64_t r= 3); +void do_stop_interrupt(CPUS390XState *env); =20 #endif /* S390X_INTERNAL_H */ diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 1174e249ab..72008e436f 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1597,13 +1597,7 @@ static int handle_intercept(S390CPU *cpu) r =3D EXCP_HALTED; break; case ICPT_CPU_STOP: - if (s390_cpu_set_state(CPU_STATE_STOPPED, cpu) =3D=3D 0) { - qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN= ); - } - if (cpu->env.sigp_order =3D=3D SIGP_STOP_STORE_STATUS) { - s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); - } - cpu->env.sigp_order =3D 0; + do_stop_interrupt(&cpu->env); r =3D EXCP_HALTED; break; case ICPT_OPEREXC: diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 4813123aad..9587c3d319 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -81,7 +81,7 @@ static void sigp_stop_and_store_status(CPUState *cs, run_= on_cpu_data arg) case CPU_STATE_OPERATING: cpu->env.sigp_order =3D SIGP_STOP_STORE_STATUS; cpu_inject_stop(cpu); - /* store will be performed when handling the stop intercept */ + /* store will be performed in do_stop_interrup() */ break; case CPU_STATE_STOPPED: /* already stopped, just store the status */ @@ -360,6 +360,19 @@ int s390_cpu_restart(S390CPU *cpu) return 0; } =20 +void do_stop_interrupt(CPUS390XState *env) +{ + S390CPU *cpu =3D s390_env_get_cpu(env); + + if (s390_cpu_set_state(CPU_STATE_STOPPED, cpu) =3D=3D 0) { + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } + if (cpu->env.sigp_order =3D=3D SIGP_STOP_STORE_STATUS) { + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); + } + env->sigp_order =3D 0; +} + void s390_init_sigp(void) { qemu_mutex_init(&qemu_sigp_mutex); --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506631953585768.7322828715396; Thu, 28 Sep 2017 13:52:33 -0700 (PDT) Received: from localhost ([::1]:60833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfnI-0008IF-Ns for importer@patchew.org; Thu, 28 Sep 2017 16:52:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfa4-0004nR-5f for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfa0-0003Yv-7q for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37202) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfa0-0003YV-1Y for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:44 -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 15264859FA; Thu, 28 Sep 2017 20:38:43 +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 3CE9E18C57; Thu, 28 Sep 2017 20:38:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 15264859FA Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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:57 +0200 Message-Id: <20170928203708.9376-20-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.26]); Thu, 28 Sep 2017 20:38:43 +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 19/30] s390x/tcg: implement SIGP SENSE RUNNING STATUS 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 TCG, for KVM is this is completely handled in the kernel. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.h | 2 ++ target/s390x/sigp.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index f94d7f96e0..6b92b0751a 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -590,6 +590,7 @@ struct sysib_322 { #define SIGP_SET_PREFIX 0x0d #define SIGP_STORE_STATUS_ADDR 0x0e #define SIGP_SET_ARCH 0x12 +#define SIGP_SENSE_RUNNING 0x15 #define SIGP_STORE_ADTL_STATUS 0x17 =20 /* SIGP condition codes */ @@ -600,6 +601,7 @@ struct sysib_322 { =20 /* SIGP status bits */ #define SIGP_STAT_EQUIPMENT_CHECK 0x80000000UL +#define SIGP_STAT_NOT_RUNNING 0x00000400UL #define SIGP_STAT_INCORRECT_STATE 0x00000200UL #define SIGP_STAT_INVALID_PARAMETER 0x00000100UL #define SIGP_STAT_EXT_CALL_PENDING 0x00000080UL diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 9587c3d319..c57312b743 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -234,6 +234,28 @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_d= ata arg) si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } =20 +static void sigp_sense_running(S390CPU *dst_cpu, SigpInfo *si) +{ + if (!tcg_enabled()) { + /* handled in KVM */ + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + /* sensing without locks is racy, but it's the same for real hw */ + if (!s390_has_feat(S390_FEAT_SENSE_RUNNING_STATUS)) { + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + /* If halted (which includes also STOPPED), it is not running */ + if (CPU(dst_cpu)->halted) { + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + } else { + set_sigp_status(si, SIGP_STAT_NOT_RUNNING); + } +} + static int handle_sigp_single_dst(S390CPU *dst_cpu, uint8_t order, uint64_t param, uint64_t *status_reg) { @@ -282,6 +304,9 @@ static int handle_sigp_single_dst(S390CPU *dst_cpu, uin= t8_t order, case SIGP_CPU_RESET: run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si)); break; + case SIGP_SENSE_RUNNING: + sigp_sense_running(dst_cpu, &si); + break; default: set_sigp_status(&si, SIGP_STAT_INVALID_ORDER); } --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 150663196155090.96427841388538; Thu, 28 Sep 2017 13:52:41 -0700 (PDT) Received: from localhost ([::1]:60834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfnK-0008KB-O4 for importer@patchew.org; Thu, 28 Sep 2017 16:52:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfa4-0004nQ-5n for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfa2-0003Zg-CY for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57708) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfa2-0003ZR-6i for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:46 -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 3C1F83680B; Thu, 28 Sep 2017 20:38:45 +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 72A326E506; Thu, 28 Sep 2017 20:38:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C1F83680B Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.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:58 +0200 Message-Id: <20170928203708.9376-21-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.30]); Thu, 28 Sep 2017 20:38:45 +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 20/30] s390x/tcg: implement SIGP SENSE 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" Add it as preparation for TCG. Sensing coul later be done completely lockless. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/sigp.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index c57312b743..063a34ccc7 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -32,6 +32,32 @@ static void set_sigp_status(SigpInfo *si, uint64_t statu= s) si->cc =3D SIGP_CC_STATUS_STORED; } =20 +static void sigp_sense(S390CPU *dst_cpu, SigpInfo *si) +{ + uint8_t state =3D s390_cpu_get_state(dst_cpu); + bool ext_call =3D dst_cpu->env.pending_int & INTERRUPT_EXTERNAL_CALL; + uint64_t status =3D 0; + + if (!tcg_enabled()) { + /* handled in KVM */ + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + /* sensing without locks is racy, but it's the same for real hw */ + if (state !=3D CPU_STATE_STOPPED && !ext_call) { + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + } else { + if (ext_call) { + status |=3D SIGP_STAT_EXT_CALL_PENDING; + } + if (state =3D=3D CPU_STATE_STOPPED) { + status |=3D SIGP_STAT_STOPPED; + } + set_sigp_status(si, status); + } +} + static void sigp_start(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -277,6 +303,9 @@ static int handle_sigp_single_dst(S390CPU *dst_cpu, uin= t8_t order, } =20 switch (order) { + case SIGP_SENSE: + sigp_sense(dst_cpu, &si); + break; case SIGP_START: run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si)); break; --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1506632182306839.4472275061859; Thu, 28 Sep 2017 13:56:22 -0700 (PDT) Received: from localhost ([::1]:60852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfqp-0003FE-Fo for importer@patchew.org; Thu, 28 Sep 2017 16:56:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfa5-0004oh-BT for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfa4-0003af-HS for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39708) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfa4-0003aF-Bs for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:48 -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 5C4314E4D4; Thu, 28 Sep 2017 20:38:47 +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 9268F17F33; Thu, 28 Sep 2017 20:38:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5C4314E4D4 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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:59 +0200 Message-Id: <20170928203708.9376-22-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.38]); Thu, 28 Sep 2017 20:38:47 +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 21/30] s390x/tcg: implement SIGP EXTERNAL CALL 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_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As preparation for TCG. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/sigp.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 063a34ccc7..080bce3fba 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -58,6 +58,24 @@ static void sigp_sense(S390CPU *dst_cpu, SigpInfo *si) } } =20 +static void sigp_external_call(S390CPU *src_cpu, S390CPU *dst_cpu, SigpInf= o *si) +{ + int ret; + + if (!tcg_enabled()) { + /* handled in KVM */ + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + ret =3D cpu_inject_external_call(dst_cpu, src_cpu->env.core_id); + if (!ret) { + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + } else { + set_sigp_status(si, SIGP_STAT_EXT_CALL_PENDING); + } +} + static void sigp_start(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -282,7 +300,7 @@ static void sigp_sense_running(S390CPU *dst_cpu, SigpIn= fo *si) } } =20 -static int handle_sigp_single_dst(S390CPU *dst_cpu, uint8_t order, +static int handle_sigp_single_dst(S390CPU *cpu, S390CPU *dst_cpu, uint8_t = order, uint64_t param, uint64_t *status_reg) { SigpInfo si =3D { @@ -306,6 +324,9 @@ static int handle_sigp_single_dst(S390CPU *dst_cpu, uin= t8_t order, case SIGP_SENSE: sigp_sense(dst_cpu, &si); break; + case SIGP_EXTERNAL_CALL: + sigp_external_call(cpu, dst_cpu, &si); + break; case SIGP_START: run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si)); break; @@ -389,7 +410,7 @@ int handle_sigp(CPUS390XState *env, uint8_t order, uint= 64_t r1, uint64_t r3) default: /* all other sigp orders target a single vcpu */ dst_cpu =3D s390_cpu_addr2state(env->regs[r3]); - ret =3D handle_sigp_single_dst(dst_cpu, order, param, status_reg); + ret =3D handle_sigp_single_dst(cpu, dst_cpu, order, param, status_= reg); } qemu_mutex_unlock(&qemu_sigp_mutex); =20 --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506631645684944.3522563340065; Thu, 28 Sep 2017 13:47:25 -0700 (PDT) Received: from localhost ([::1]:60812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfiD-0003Sr-SY for importer@patchew.org; Thu, 28 Sep 2017 16:47:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfa7-0004rA-EC for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfa6-0003bi-LO for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37398) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfa6-0003bU-Ff for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:50 -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 7A7F4883B1; Thu, 28 Sep 2017 20:38:49 +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 B49EE17F33; Thu, 28 Sep 2017 20:38:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7A7F4883B1 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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:37:00 +0200 Message-Id: <20170928203708.9376-23-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.26]); Thu, 28 Sep 2017 20:38:49 +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 22/30] s390x/tcg: implement SIGP EMERGENCY SIGNAL 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" As preparation for TCG. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/sigp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 080bce3fba..d492885787 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -76,6 +76,18 @@ static void sigp_external_call(S390CPU *src_cpu, S390CPU= *dst_cpu, SigpInfo *si) } } =20 +static void sigp_emergency(S390CPU *src_cpu, S390CPU *dst_cpu, SigpInfo *s= i) +{ + if (!tcg_enabled()) { + /* handled in KVM */ + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + cpu_inject_emergency_signal(dst_cpu, src_cpu->env.core_id); + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + static void sigp_start(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -327,6 +339,9 @@ static int handle_sigp_single_dst(S390CPU *cpu, S390CPU= *dst_cpu, uint8_t order, case SIGP_EXTERNAL_CALL: sigp_external_call(cpu, dst_cpu, &si); break; + case SIGP_EMERGENCY: + sigp_emergency(cpu, dst_cpu, &si); + break; case SIGP_START: run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si)); break; --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506632108916376.8878194783298; Thu, 28 Sep 2017 13:55:08 -0700 (PDT) Received: from localhost ([::1]:60845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfpm-0002Bj-UK for importer@patchew.org; Thu, 28 Sep 2017 16:55:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaC-0004wi-W0 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfa9-0003d1-1x for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfa8-0003cY-PG for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:52 -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 9EC3681DE8; Thu, 28 Sep 2017 20:38:51 +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 D284C17F33; Thu, 28 Sep 2017 20:38:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9EC3681DE8 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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:37:01 +0200 Message-Id: <20170928203708.9376-24-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.25]); Thu, 28 Sep 2017 20:38:51 +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 23/30] s390x/tcg: implement SIGP CONDITIONAL EMERGENCY SIGNAL 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" Mostly analogous to the kernel/KVM version (so I assume the checks are correct :) ). As a preparation for TCG. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.h | 1 + target/s390x/sigp.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 6b92b0751a..7f4f03f410 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -590,6 +590,7 @@ struct sysib_322 { #define SIGP_SET_PREFIX 0x0d #define SIGP_STORE_STATUS_ADDR 0x0e #define SIGP_SET_ARCH 0x12 +#define SIGP_COND_EMERGENCY 0x13 #define SIGP_SENSE_RUNNING 0x15 #define SIGP_STORE_ADTL_STATUS 0x17 =20 diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index d492885787..ce8fda9d01 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -290,6 +290,40 @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_d= ata arg) si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } =20 +static void sigp_cond_emergency(S390CPU *src_cpu, S390CPU *dst_cpu, + SigpInfo *si) +{ + const uint64_t psw_int_mask =3D PSW_MASK_IO | PSW_MASK_EXT; + uint16_t p_asn, s_asn, asn; + uint64_t psw_addr, psw_mask; + bool idle; + + if (!tcg_enabled()) { + /* handled in KVM */ + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + /* this looks racy, but these values are only used when STOPPED */ + idle =3D CPU(dst_cpu)->halted; + psw_addr =3D dst_cpu->env.psw.addr; + psw_mask =3D dst_cpu->env.psw.mask; + asn =3D si->param; + p_asn =3D dst_cpu->env.cregs[4] & 0xffff; /* Primary ASN */ + s_asn =3D dst_cpu->env.cregs[3] & 0xffff; /* Secondary ASN */ + + if (s390_cpu_get_state(dst_cpu) !=3D CPU_STATE_STOPPED || + (psw_mask & psw_int_mask) !=3D psw_int_mask || + (idle && psw_addr !=3D 0) || + (!idle && (asn =3D=3D p_asn || asn =3D=3D s_asn))) { + cpu_inject_emergency_signal(dst_cpu, src_cpu->env.core_id); + } else { + set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); + } + + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + static void sigp_sense_running(S390CPU *dst_cpu, SigpInfo *si) { if (!tcg_enabled()) { @@ -369,6 +403,9 @@ static int handle_sigp_single_dst(S390CPU *cpu, S390CPU= *dst_cpu, uint8_t order, case SIGP_CPU_RESET: run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si)); break; + case SIGP_COND_EMERGENCY: + sigp_cond_emergency(cpu, dst_cpu, &si); + break; case SIGP_SENSE_RUNNING: sigp_sense_running(dst_cpu, &si); break; --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506631871699483.42950405328827; Thu, 28 Sep 2017 13:51:11 -0700 (PDT) Received: from localhost ([::1]:60828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxflw-0006ql-Rh for importer@patchew.org; Thu, 28 Sep 2017 16:51:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaF-0004yj-Bc for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfaB-0003e8-6P for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33724) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfaA-0003de-Tr for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:55 -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 D10CF81DE2; Thu, 28 Sep 2017 20:38:53 +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 F256617F33; Thu, 28 Sep 2017 20:38:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D10CF81DE2 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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:37:02 +0200 Message-Id: <20170928203708.9376-25-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.25]); Thu, 28 Sep 2017 20:38:53 +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 24/30] s390x/tcg: implement STOP and RESET interrupts for TCG 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" Implement them like KVM implements/handles them. Both can only be triggered via SIGP instructions. RESET has (almos)the lowest priority if the CPU is running, and the highest if the CPU is STOPPED. This is handled in SIGP code already. On delivery, we only have to care about the "CPU running" scenario. STOP is defined to be delivered after all other interrupts have been delivered. Therefore it has the actual lowest priority. As both can wake up a CPU if sleeping, indicate them correctly to external code (e.g. cpu_has_work()). Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.h | 4 ++++ target/s390x/excp_helper.c | 16 +++++++++++++++- target/s390x/helper.c | 1 + target/s390x/internal.h | 2 ++ target/s390x/interrupt.c | 32 +++++++++++++++++++++++++++----- target/s390x/sigp.c | 2 ++ 6 files changed, 51 insertions(+), 6 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 7f4f03f410..b684502900 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -400,6 +400,8 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState* = env, target_ulong *pc, #define EXCP_EXT 1 /* external interrupt */ #define EXCP_SVC 2 /* supervisor call (syscall) */ #define EXCP_PGM 3 /* program interruption */ +#define EXCP_RESTART 4 /* restart interrupt */ +#define EXCP_STOP 5 /* stop interrupt */ #define EXCP_IO 7 /* I/O interrupt */ #define EXCP_MCHK 8 /* machine check */ =20 @@ -410,6 +412,8 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState* = env, target_ulong *pc, #define INTERRUPT_EXT_CLOCK_COMPARATOR (1 << 4) #define INTERRUPT_EXTERNAL_CALL (1 << 5) #define INTERRUPT_EMERGENCY_SIGNAL (1 << 6) +#define INTERRUPT_RESTART (1 << 7) +#define INTERRUPT_STOP (1 << 8) =20 /* Program Status Word. */ #define S390_PSWM_REGNUM 0 diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 1a0d0770a9..e04b670663 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -449,6 +449,14 @@ void s390_cpu_do_interrupt(CPUState *cs) if (cs->exception_index =3D=3D -1 && s390_cpu_has_io_int(cpu)) { cs->exception_index =3D EXCP_IO; } + /* RESTART interrupt */ + if (cs->exception_index =3D=3D -1 && s390_cpu_has_restart_int(cpu)) { + cs->exception_index =3D EXCP_RESTART; + } + /* STOP interrupt has least priority */ + if (cs->exception_index =3D=3D -1 && s390_cpu_has_stop_int(cpu)) { + cs->exception_index =3D EXCP_STOP; + } =20 switch (cs->exception_index) { case EXCP_PGM: @@ -466,9 +474,15 @@ void s390_cpu_do_interrupt(CPUState *cs) case EXCP_MCHK: do_mchk_interrupt(env); break; + case EXCP_RESTART: + do_restart_interrupt(env); + break; + case EXCP_STOP: + do_stop_interrupt(env); + break; } =20 - /* WAIT PSW during interrupt injection */ + /* WAIT PSW during interrupt injection or STOP interrupt */ if (cs->exception_index =3D=3D EXCP_HLT) { /* don't trigger a cpu_loop_exit(), use an interrupt instead */ cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HALT); diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 2505f3aec0..c41aa4c4ff 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -202,6 +202,7 @@ void do_restart_interrupt(CPUS390XState *env) addr =3D be64_to_cpu(lowcore->restart_new_psw.addr); =20 cpu_unmap_lowcore(lowcore); + env->pending_int &=3D ~INTERRUPT_RESTART; =20 load_psw(env, mask, addr); } diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 2c3fc3fce0..3aff54ada4 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -372,6 +372,8 @@ bool s390_cpu_has_io_int(S390CPU *cpu); bool s390_cpu_has_ext_int(S390CPU *cpu); bool s390_cpu_has_mcck_int(S390CPU *cpu); bool s390_cpu_has_int(S390CPU *cpu); +bool s390_cpu_has_restart_int(S390CPU *cpu); +bool s390_cpu_has_stop_int(S390CPU *cpu); void cpu_inject_restart(S390CPU *cpu); void cpu_inject_stop(S390CPU *cpu); =20 diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index 64b3f519ef..f2ca881bed 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -109,22 +109,28 @@ int cpu_inject_external_call(S390CPU *cpu, uint16_t s= rc_cpu_addr) =20 void cpu_inject_restart(S390CPU *cpu) { + CPUS390XState *env =3D &cpu->env; + if (kvm_enabled()) { kvm_s390_restart_interrupt(cpu); return; } - /* FIXME TCG */ - g_assert_not_reached(); + + env->pending_int |=3D INTERRUPT_RESTART; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); } =20 void cpu_inject_stop(S390CPU *cpu) { + CPUS390XState *env =3D &cpu->env; + if (kvm_enabled()) { kvm_s390_stop_interrupt(cpu); return; } - /* FIXME TCG */ - g_assert_not_reached(); + + env->pending_int |=3D INTERRUPT_STOP; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); } =20 static void cpu_inject_io(S390CPU *cpu, uint16_t subchannel_id, @@ -272,6 +278,20 @@ bool s390_cpu_has_io_int(S390CPU *cpu) =20 return env->pending_int & INTERRUPT_IO; } + +bool s390_cpu_has_restart_int(S390CPU *cpu) +{ + CPUS390XState *env =3D &cpu->env; + + return env->pending_int & INTERRUPT_RESTART; +} + +bool s390_cpu_has_stop_int(S390CPU *cpu) +{ + CPUS390XState *env =3D &cpu->env; + + return env->pending_int & INTERRUPT_STOP; +} #endif =20 bool s390_cpu_has_int(S390CPU *cpu) @@ -282,7 +302,9 @@ bool s390_cpu_has_int(S390CPU *cpu) } return s390_cpu_has_mcck_int(cpu) || s390_cpu_has_ext_int(cpu) || - s390_cpu_has_io_int(cpu); + s390_cpu_has_io_int(cpu) || + s390_cpu_has_restart_int(cpu) || + s390_cpu_has_stop_int(cpu); #else return false; #endif diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index ce8fda9d01..d70f5cb0ba 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -14,6 +14,7 @@ #include "internal.h" #include "sysemu/hw_accel.h" #include "exec/address-spaces.h" +#include "exec/exec-all.h" #include "sysemu/sysemu.h" #include "trace.h" =20 @@ -498,6 +499,7 @@ void do_stop_interrupt(CPUS390XState *env) s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); } env->sigp_order =3D 0; + env->pending_int &=3D ~INTERRUPT_STOP; } =20 void s390_init_sigp(void) --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 150663225751248.5528382691715; Thu, 28 Sep 2017 13:57:37 -0700 (PDT) Received: from localhost ([::1]:60867 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfs7-0004em-R2 for importer@patchew.org; Thu, 28 Sep 2017 16:57:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaF-0004yi-BI for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfaD-0003f8-7A for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40312) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfaD-0003es-1I for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:57 -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 18CD84E33E; Thu, 28 Sep 2017 20:38:56 +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 3488F18C67; Thu, 28 Sep 2017 20:38:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 18CD84E33E Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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:37:03 +0200 Message-Id: <20170928203708.9376-26-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.38]); Thu, 28 Sep 2017 20:38:56 +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 25/30] s390x/tcg: flush the tlb on SIGP SET PREFIX 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" Thanks to Aurelien Jarno for doing this in his prototype. We can flush the whole TLB as this should happen really rarely. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/sigp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index d70f5cb0ba..c5a5dac911 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -287,6 +287,7 @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_da= ta arg) } =20 cpu->env.psa =3D addr; + tlb_flush(cs); cpu_synchronize_post_init(cs); si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506632111329372.0114789504487; Thu, 28 Sep 2017 13:55:11 -0700 (PDT) Received: from localhost ([::1]:60846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfpp-0002Dl-Hx for importer@patchew.org; Thu, 28 Sep 2017 16:55:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaM-000532-10 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfaI-0003it-1P for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48998) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfaH-0003iN-O9 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:01 -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 BBB18C057FA8; Thu, 28 Sep 2017 20:39:00 +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 6DB7C18C75; Thu, 28 Sep 2017 20:38:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BBB18C057FA8 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:37:04 +0200 Message-Id: <20170928203708.9376-27-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:39: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 v2 26/30] s390x/tcg: switch to new SIGP handling code 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" This effectively enables experimental SMP support. Floating interrupts are still a mess, so allow it but print a big warning. There also seems to be a problem with CPU hotplug (after the main loop started). Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- hw/s390x/s390-virtio-ccw.c | 4 +--- target/s390x/helper.h | 2 +- target/s390x/misc_helper.c | 42 ++++++------------------------------------ target/s390x/translate.c | 5 +++-- 4 files changed, 11 insertions(+), 42 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index d188ce17ba..3a23fd3f27 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -58,9 +58,7 @@ static void s390_init_cpus(MachineState *machine) int i; =20 if (tcg_enabled() && max_cpus > 1) { - error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " - "supported by TCG (1) on s390x", max_cpus); - exit(1); + error_report("WARNING: SMP support on s390x is experimental!"); } =20 /* initialize possible_cpus */ diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 52c2963baa..81c5727168 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -138,7 +138,7 @@ DEF_HELPER_FLAGS_3(sske, TCG_CALL_NO_RWG, void, env, i6= 4, i64) DEF_HELPER_FLAGS_2(rrbe, TCG_CALL_NO_RWG, i32, env, i64) DEF_HELPER_4(mvcs, i32, env, i64, i64, i64) DEF_HELPER_4(mvcp, i32, env, i64, i64, i64) -DEF_HELPER_4(sigp, i32, env, i64, i32, i64) +DEF_HELPER_4(sigp, i32, env, i64, i32, i32) DEF_HELPER_FLAGS_2(sacf, TCG_CALL_NO_WG, void, env, i64) DEF_HELPER_FLAGS_4(idte, TCG_CALL_NO_RWG, void, env, i64, i64, i32) DEF_HELPER_FLAGS_4(ipte, TCG_CALL_NO_RWG, void, env, i64, i64, i32) diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index 0b93381188..0b3613ea5f 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -319,44 +319,14 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, } =20 uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1, - uint64_t cpu_addr) + uint32_t r3) { - int cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + int cc; =20 - HELPER_LOG("%s: %016" PRIx64 " %08x %016" PRIx64 "\n", - __func__, order_code, r1, cpu_addr); - - /* Remember: Use "R1 or R1 + 1, whichever is the odd-numbered register" - as parameter (input). Status (output) is always R1. */ - - switch (order_code & SIGP_ORDER_MASK) { - case SIGP_SET_ARCH: - /* switch arch */ - break; - case SIGP_SENSE: - /* enumerate CPU status */ - if (cpu_addr) { - /* XXX implement when SMP comes */ - return 3; - } - env->regs[r1] &=3D 0xffffffff00000000ULL; - cc =3D 1; - break; -#if !defined(CONFIG_USER_ONLY) - case SIGP_RESTART: - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); - cpu_loop_exit(CPU(s390_env_get_cpu(env))); - break; - case SIGP_STOP: - qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); - cpu_loop_exit(CPU(s390_env_get_cpu(env))); - break; -#endif - default: - /* unknown sigp */ - fprintf(stderr, "XXX unknown sigp: 0x%" PRIx64 "\n", order_code); - cc =3D SIGP_CC_NOT_OPERATIONAL; - } + /* TODO: needed to inject interrupts - push further down */ + qemu_mutex_lock_iothread(); + cc =3D handle_sigp(env, order_code & SIGP_ORDER_MASK, r1, r3); + qemu_mutex_unlock_iothread(); =20 return cc; } diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 405d94b87d..6a2e084f87 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3710,11 +3710,12 @@ static ExitStatus op_servc(DisasContext *s, DisasOp= s *o) static ExitStatus op_sigp(DisasContext *s, DisasOps *o) { TCGv_i32 r1 =3D tcg_const_i32(get_field(s->fields, r1)); + TCGv_i32 r3 =3D tcg_const_i32(get_field(s->fields, r3)); check_privileged(s); - potential_page_fault(s); - gen_helper_sigp(cc_op, cpu_env, o->in2, r1, o->in1); + gen_helper_sigp(cc_op, cpu_env, o->in2, r1, r3); set_cc_static(s); tcg_temp_free_i32(r1); + tcg_temp_free_i32(r3); return NO_EXIT; } #endif --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506632027979919.5686386354615; Thu, 28 Sep 2017 13:53:47 -0700 (PDT) Received: from localhost ([::1]:60837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfoU-0000vZ-8x for importer@patchew.org; Thu, 28 Sep 2017 16:53:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaP-00057I-Nc for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfaL-0003lA-QN for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49560) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfaL-0003kw-KD for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:05 -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 9E1115D689; Thu, 28 Sep 2017 20:39:04 +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 2059917F33; Thu, 28 Sep 2017 20:39:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9E1115D689 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.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:37:05 +0200 Message-Id: <20170928203708.9376-28-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.39]); Thu, 28 Sep 2017 20:39:04 +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 27/30] s390x/cpumodel: allow to enable SENSE RUNNING STATUS for qemu 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" As we properly implement it, allow to enable it. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu_models.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 07ef8a3b6e..095a11cbca 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -823,6 +823,7 @@ static void add_qemu_cpu_model_features(S390FeatBitmap = fbm) S390_FEAT_DAT_ENH, S390_FEAT_IDTE_SEGMENT, S390_FEAT_STFLE, + S390_FEAT_SENSE_RUNNING_STATUS, S390_FEAT_EXTENDED_IMMEDIATE, S390_FEAT_EXTENDED_TRANSLATION_2, S390_FEAT_MSA, --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506632372681380.0465608718034; Thu, 28 Sep 2017 13:59:32 -0700 (PDT) Received: from localhost ([::1]:60877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxftu-00067r-Fh for importer@patchew.org; Thu, 28 Sep 2017 16:59:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaP-00057H-Nd for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfaO-0003mA-2Q for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfaN-0003lq-T5 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:08 -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 DFC6A4DD7C; Thu, 28 Sep 2017 20:39:06 +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 020BF17F33; Thu, 28 Sep 2017 20:39:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DFC6A4DD7C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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:37:06 +0200 Message-Id: <20170928203708.9376-29-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.38]); Thu, 28 Sep 2017 20:39:07 +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 28/30] s390x/tcg: unlock NMI 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" Nothing hindering us anymore from unlocking the restart code (used for NMI). Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- hw/s390x/s390-virtio-ccw.c | 4 +--- target/s390x/sigp.c | 5 ----- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 3a23fd3f27..7f7e4908b1 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -402,9 +402,7 @@ static void s390_nmi(NMIState *n, int cpu_index, Error = **errp) { CPUState *cs =3D qemu_get_cpu(cpu_index); =20 - if (s390_cpu_restart(S390_CPU(cs))) { - error_setg(errp, QERR_UNSUPPORTED); - } + s390_cpu_restart(S390_CPU(cs)); } =20 static void ccw_machine_class_init(ObjectClass *oc, void *data) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index c5a5dac911..964c75a736 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -480,11 +480,6 @@ int s390_cpu_restart(S390CPU *cpu) { SigpInfo si =3D {}; =20 - if (tcg_enabled()) { - /* FIXME TCG */ - return -ENOSYS; - } - run_on_cpu(CPU(cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); return 0; } --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 1506632260836861.8212839478279; Thu, 28 Sep 2017 13:57:40 -0700 (PDT) Received: from localhost ([::1]:60868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfsB-0004mC-3G for importer@patchew.org; Thu, 28 Sep 2017 16:57:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaR-00059H-L9 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfaQ-0003n9-Eo for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7028) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfaQ-0003me-6G for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:10 -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 2FEC081DEE; Thu, 28 Sep 2017 20:39:09 +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 433576E506; Thu, 28 Sep 2017 20:39:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2FEC081DEE Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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:37:07 +0200 Message-Id: <20170928203708.9376-30-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.25]); Thu, 28 Sep 2017 20:39:09 +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 29/30] s390x/tcg: refactor stfl(e) to use s390_get_feat_block() 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" Refactor it to use s390_get_feat_block(). Directly write into the mapped lowcore with stfl and make sure it is really only compiled if needed. While at it, add an alignment check for STFLE and avoid potential_page_fault() by properly restoring the CPU state. Due to s390_get_feat_block(), we will now also indicate the "Configuration-z-architectural-mode", which is with new SIGP code the right thing to do. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/misc_helper.c | 67 ++++++++++++++++++++----------------------= ---- target/s390x/translate.c | 1 - 2 files changed, 29 insertions(+), 39 deletions(-) diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index 0b3613ea5f..4afd90b969 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -475,66 +475,57 @@ void HELPER(per_ifetch)(CPUS390XState *env, uint64_t = addr) } #endif =20 -/* The maximum bit defined at the moment is 129. */ -#define MAX_STFL_WORDS 3 +static uint8_t stfl_bytes[2048]; +static unsigned int used_stfl_bytes; =20 -/* Canonicalize the current cpu's features into the 64-bit words required - by STFLE. Return the index-1 of the max word that is non-zero. */ -static unsigned do_stfle(CPUS390XState *env, uint64_t words[MAX_STFL_WORDS= ]) +static void prepare_stfl(void) { - S390CPU *cpu =3D s390_env_get_cpu(env); - const unsigned long *features =3D cpu->model->features; - unsigned max_bit =3D 0; - S390Feat feat; - - memset(words, 0, sizeof(uint64_t) * MAX_STFL_WORDS); + static bool initialized; + int i; =20 - if (test_bit(S390_FEAT_ZARCH, features)) { - /* z/Architecture is always active if around */ - words[0] =3D 1ull << (63 - 2); + /* racy, but we don't care, the same values are always written */ + if (initialized) { + return; } =20 - for (feat =3D find_first_bit(features, S390_FEAT_MAX); - feat < S390_FEAT_MAX; - feat =3D find_next_bit(features, S390_FEAT_MAX, feat + 1)) { - const S390FeatDef *def =3D s390_feat_def(feat); - if (def->type =3D=3D S390_FEAT_TYPE_STFL) { - unsigned bit =3D def->bit; - if (bit > max_bit) { - max_bit =3D bit; - } - assert(bit / 64 < MAX_STFL_WORDS); - words[bit / 64] |=3D 1ULL << (63 - bit % 64); + s390_get_feat_block(S390_FEAT_TYPE_STFL, stfl_bytes); + for (i =3D 0; i < sizeof(stfl_bytes); i++) { + if (stfl_bytes[i]) { + used_stfl_bytes =3D i + 1; } } - - return max_bit / 64; + initialized =3D true; } =20 #ifndef CONFIG_USER_ONLY void HELPER(stfl)(CPUS390XState *env) { - uint64_t words[MAX_STFL_WORDS]; LowCore *lowcore; =20 lowcore =3D cpu_map_lowcore(env); - do_stfle(env, words); - lowcore->stfl_fac_list =3D cpu_to_be32(words[0] >> 32); + prepare_stfl(); + memcpy(&lowcore->stfl_fac_list, stfl_bytes, sizeof(lowcore->stfl_fac_l= ist)); cpu_unmap_lowcore(lowcore); } #endif =20 uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr) { - uint64_t words[MAX_STFL_WORDS]; - unsigned count_m1 =3D env->regs[0] & 0xff; - unsigned max_m1 =3D do_stfle(env, words); - unsigned i; + const uintptr_t ra =3D GETPC(); + const int count_bytes =3D ((env->regs[0] & 0xff) + 1) * 8; + const int max_bytes =3D ROUND_UP(used_stfl_bytes, 8); + int i; + + if (addr & 0x7) { + cpu_restore_state(ENV_GET_CPU(env), ra); + program_interrupt(env, PGM_SPECIFICATION, 4); + } =20 - for (i =3D 0; i <=3D count_m1; ++i) { - cpu_stq_data(env, addr + 8 * i, words[i]); + prepare_stfl(); + for (i =3D 0; i < count_bytes; ++i) { + cpu_stb_data_ra(env, addr + i, stfl_bytes[i], ra); } =20 - env->regs[0] =3D deposit64(env->regs[0], 0, 8, max_m1); - return (count_m1 >=3D max_m1 ? 0 : 3); + env->regs[0] =3D deposit64(env->regs[0], 0, 8, (max_bytes / 8) - 1); + return count_bytes >=3D max_bytes ? 0 : 3; } diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 6a2e084f87..6fad20f75d 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -4143,7 +4143,6 @@ static ExitStatus op_sturg(DisasContext *s, DisasOps = *o) =20 static ExitStatus op_stfle(DisasContext *s, DisasOps *o) { - potential_page_fault(s); gen_helper_stfle(cc_op, cpu_env, o->in2); set_cc_static(s); return NO_EXIT; --=20 2.13.5 From nobody Tue May 7 18:53:18 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506632469043869.9655748518417; Thu, 28 Sep 2017 14:01:09 -0700 (PDT) Received: from localhost ([::1]:60887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfvW-0007Iu-1j for importer@patchew.org; Thu, 28 Sep 2017 17:00:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfaY-0005G7-Vh for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfaU-0003os-Vg for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37984) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfaU-0003oT-Pg for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:39:14 -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 C132F859F7; Thu, 28 Sep 2017 20:39:13 +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 87E1F18C79; Thu, 28 Sep 2017 20:39:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C132F859F7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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:37:08 +0200 Message-Id: <20170928203708.9376-31-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.26]); Thu, 28 Sep 2017 20:39:13 +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 30/30] target/s390x: special handling when starting a CPU with WAIT PSW 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" When we try to start a CPU with a WAIT PSW, we have to take care that TCG will actually try to continue executing instructions. We must therefore really only unhalt the CPU if we don't have a WAIT PSW. Also document the special order for restart interrupts, which load a new PSW and change the state to operating. To keep KVM working, simply don't have a look at the WAIT bit when loading the PSW. Otherwise the behavior of a restart interrupt when a CPU stopped would be changed. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.c | 11 +++++++++-- target/s390x/sigp.c | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index e27827afb3..981f5d4f39 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -335,8 +335,15 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, S39= 0CPU *cpu) break; case CPU_STATE_OPERATING: case CPU_STATE_LOAD: - /* unhalt the cpu for common infrastructure */ - s390_cpu_unhalt(cpu); + /* + * Starting a CPU with a PSW WAIT bit set: + * KVM: handles this internally and triggers another WAIT exit. + * TCG: will actually try to continue to run. Don't unhalt, will + * be done when the CPU actually has work (an interrupt). + */ + if (!tcg_enabled() || !(cpu->env.psw.mask & PSW_MASK_WAIT)) { + s390_cpu_unhalt(cpu); + } break; default: error_report("Requested CPU state is not a valid S390 CPU state: %= u", diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 964c75a736..ac3f8e7dc2 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -232,8 +232,12 @@ static void sigp_restart(CPUState *cs, run_on_cpu_data= arg) case CPU_STATE_STOPPED: /* the restart irq has to be delivered prior to any other pending = irq */ cpu_synchronize_state(cs); - do_restart_interrupt(&cpu->env); + /* + * Set OPERATING (and unhalting) before loading the restart PSW. + * load_psw() will then properly halt the CPU again if necessary (= TCG). + */ s390_cpu_set_state(CPU_STATE_OPERATING, cpu); + do_restart_interrupt(&cpu->env); break; case CPU_STATE_OPERATING: cpu_inject_restart(cpu); --=20 2.13.5