From patchwork Fri Oct 20 11:53:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 10020015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4888E60234 for ; Fri, 20 Oct 2017 12:07:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4086228E91 for ; Fri, 20 Oct 2017 12:07:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 356A028ECF; Fri, 20 Oct 2017 12:07:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 88C8F28E91 for ; Fri, 20 Oct 2017 12:07:26 +0000 (UTC) Received: from localhost ([::1]:53348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5W5F-0004RK-AO for patchwork-qemu-devel@patchwork.kernel.org; Fri, 20 Oct 2017 08:07:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5VtR-0002Zl-4J for qemu-devel@nongnu.org; Fri, 20 Oct 2017 07:55:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5VtP-0003Bo-PA for qemu-devel@nongnu.org; Fri, 20 Oct 2017 07:55:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e5VtP-0003Am-Gh; Fri, 20 Oct 2017 07:55:11 -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 6D04F33A178; Fri, 20 Oct 2017 11:55:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6D04F33A178 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=cohuck@redhat.com Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8FFBA18784; Fri, 20 Oct 2017 11:55:09 +0000 (UTC) From: Cornelia Huck To: peter.maydell@linaro.org Date: Fri, 20 Oct 2017 13:53:46 +0200 Message-Id: <20171020115418.2050-15-cohuck@redhat.com> In-Reply-To: <20171020115418.2050-1-cohuck@redhat.com> References: <20171020115418.2050-1-cohuck@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]); Fri, 20 Oct 2017 11:55:10 +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] [PULL 14/46] s390x/kvm: generalize SIGP stop and restart interrupt injection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, david@redhat.com, Cornelia Huck , agraf@suse.de, qemu-devel@nongnu.org, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: David Hildenbrand Preparation for factoring it out into !kvm code. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand Message-Id: <20170928203708.9376-13-david@redhat.com> Signed-off-by: Cornelia Huck --- 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); /* ioinst.c */ diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index 83a0f194f8..462d45e95f 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -107,6 +107,26 @@ int cpu_inject_external_call(S390CPU *cpu, uint16_t src_cpu_addr) return 0; } +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 43f02c2d69..b27ed2927a 100644 --- a/target/s390x/kvm-stub.c +++ b/target/s390x/kvm-stub.c @@ -119,3 +119,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 2e75bda31a..98fa1c59a9 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1539,9 +1539,6 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu = S390_CPU(cs); SigpInfo *si = arg.host_ptr; - struct kvm_s390_irq irq = { - .type = KVM_S390_SIGP_STOP, - }; if (s390_cpu_get_state(cpu) != CPU_STATE_OPERATING) { si->cc = SIGP_CC_ORDER_CODE_ACCEPTED; @@ -1554,7 +1551,7 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data arg) } else { /* execute the stop function */ cpu->env.sigp_order = SIGP_STOP; - kvm_s390_vcpu_interrupt(cpu, &irq); + cpu_inject_stop(cpu); } si->cc = SIGP_CC_ORDER_CODE_ACCEPTED; } @@ -1653,9 +1650,6 @@ static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu = S390_CPU(cs); SigpInfo *si = arg.host_ptr; - struct kvm_s390_irq irq = { - .type = KVM_S390_SIGP_STOP, - }; /* disabled wait - sleeping in user space */ if (s390_cpu_get_state(cpu) == CPU_STATE_OPERATING && cs->halted) { @@ -1665,7 +1659,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 = 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: @@ -1755,9 +1749,6 @@ static void sigp_restart(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu = S390_CPU(cs); SigpInfo *si = arg.host_ptr; - struct kvm_s390_irq irq = { - .type = KVM_S390_RESTART, - }; switch (s390_cpu_get_state(cpu)) { case CPU_STATE_STOPPED: @@ -1767,7 +1758,7 @@ static void sigp_restart(CPUState *cs, run_on_cpu_data 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 = SIGP_CC_ORDER_CODE_ACCEPTED; @@ -2818,3 +2809,21 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp) kvm_s390_enable_cmma(); } } + +void kvm_s390_restart_interrupt(S390CPU *cpu) +{ + struct kvm_s390_irq irq = { + .type = KVM_S390_RESTART, + }; + + kvm_s390_vcpu_interrupt(cpu, &irq); +} + +void kvm_s390_stop_interrupt(S390CPU *cpu) +{ + struct kvm_s390_irq irq = { + .type = 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 501fc5aabd..46dbb742f0 100644 --- a/target/s390x/kvm_s390x.h +++ b/target/s390x/kvm_s390x.h @@ -42,6 +42,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); /* implemented outside of target/s390x/ */ int kvm_s390_inject_flic(struct kvm_s390_irq *irq);