From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da1qf-0000LG-9T for qemu-devel@nongnu.org; Tue, 25 Jul 2017 11:34:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da1qe-0008Kz-9L for qemu-devel@nongnu.org; Tue, 25 Jul 2017 11:34:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43464) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da1qe-0008JT-0g for qemu-devel@nongnu.org; Tue, 25 Jul 2017 11:34:12 -0400 From: Cornelia Huck Date: Tue, 25 Jul 2017 17:33:28 +0200 Message-Id: <20170725153330.14966-8-cohuck@redhat.com> In-Reply-To: <20170725153330.14966-1-cohuck@redhat.com> References: <20170725153330.14966-1-cohuck@redhat.com> Subject: [Qemu-devel] [PATCH v3 7/9] s390x/pci: fence off instructions for non-pci List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: borntraeger@de.ibm.com, agraf@suse.de, thuth@redhat.com, david@redhat.com, pmorel@linux.vnet.ibm.com, zyimin@linux.vnet.ibm.com, Cornelia Huck If a guest running on a machine without zpci issues a pci instruction, throw them an exception. Reviewed-by: Thomas Huth Signed-off-by: Cornelia Huck --- target/s390x/kvm.c | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 866ac3d414..dc3f940b95 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1191,7 +1191,11 @@ static int kvm_clp_service_call(S390CPU *cpu, struct kvm_run *run) { uint8_t r2 = (run->s390_sieic.ipb & 0x000f0000) >> 16; - return clp_service_call(cpu, r2); + if (s390_has_feat(S390_FEAT_ZPCI)) { + return clp_service_call(cpu, r2); + } else { + return -1; + } } static int kvm_pcilg_service_call(S390CPU *cpu, struct kvm_run *run) @@ -1199,7 +1203,11 @@ static int kvm_pcilg_service_call(S390CPU *cpu, struct kvm_run *run) uint8_t r1 = (run->s390_sieic.ipb & 0x00f00000) >> 20; uint8_t r2 = (run->s390_sieic.ipb & 0x000f0000) >> 16; - return pcilg_service_call(cpu, r1, r2); + if (s390_has_feat(S390_FEAT_ZPCI)) { + return pcilg_service_call(cpu, r1, r2); + } else { + return -1; + } } static int kvm_pcistg_service_call(S390CPU *cpu, struct kvm_run *run) @@ -1207,7 +1215,11 @@ static int kvm_pcistg_service_call(S390CPU *cpu, struct kvm_run *run) uint8_t r1 = (run->s390_sieic.ipb & 0x00f00000) >> 20; uint8_t r2 = (run->s390_sieic.ipb & 0x000f0000) >> 16; - return pcistg_service_call(cpu, r1, r2); + if (s390_has_feat(S390_FEAT_ZPCI)) { + return pcistg_service_call(cpu, r1, r2); + } else { + return -1; + } } static int kvm_stpcifc_service_call(S390CPU *cpu, struct kvm_run *run) @@ -1216,10 +1228,14 @@ static int kvm_stpcifc_service_call(S390CPU *cpu, struct kvm_run *run) uint64_t fiba; uint8_t ar; - cpu_synchronize_state(CPU(cpu)); - fiba = get_base_disp_rxy(cpu, run, &ar); + if (s390_has_feat(S390_FEAT_ZPCI)) { + cpu_synchronize_state(CPU(cpu)); + fiba = get_base_disp_rxy(cpu, run, &ar); - return stpcifc_service_call(cpu, r1, fiba, ar); + return stpcifc_service_call(cpu, r1, fiba, ar); + } else { + return -1; + } } static int kvm_sic_service_call(S390CPU *cpu, struct kvm_run *run) @@ -1247,7 +1263,11 @@ static int kvm_rpcit_service_call(S390CPU *cpu, struct kvm_run *run) uint8_t r1 = (run->s390_sieic.ipb & 0x00f00000) >> 20; uint8_t r2 = (run->s390_sieic.ipb & 0x000f0000) >> 16; - return rpcit_service_call(cpu, r1, r2); + if (s390_has_feat(S390_FEAT_ZPCI)) { + return rpcit_service_call(cpu, r1, r2); + } else { + return -1; + } } static int kvm_pcistb_service_call(S390CPU *cpu, struct kvm_run *run) @@ -1257,10 +1277,14 @@ static int kvm_pcistb_service_call(S390CPU *cpu, struct kvm_run *run) uint64_t gaddr; uint8_t ar; - cpu_synchronize_state(CPU(cpu)); - gaddr = get_base_disp_rsy(cpu, run, &ar); + if (s390_has_feat(S390_FEAT_ZPCI)) { + cpu_synchronize_state(CPU(cpu)); + gaddr = get_base_disp_rsy(cpu, run, &ar); - return pcistb_service_call(cpu, r1, r3, gaddr, ar); + return pcistb_service_call(cpu, r1, r3, gaddr, ar); + } else { + return -1; + } } static int kvm_mpcifc_service_call(S390CPU *cpu, struct kvm_run *run) @@ -1269,10 +1293,14 @@ static int kvm_mpcifc_service_call(S390CPU *cpu, struct kvm_run *run) uint64_t fiba; uint8_t ar; - cpu_synchronize_state(CPU(cpu)); - fiba = get_base_disp_rxy(cpu, run, &ar); + if (s390_has_feat(S390_FEAT_ZPCI)) { + cpu_synchronize_state(CPU(cpu)); + fiba = get_base_disp_rxy(cpu, run, &ar); - return mpcifc_service_call(cpu, r1, fiba, ar); + return mpcifc_service_call(cpu, r1, fiba, ar); + } else { + return -1; + } } static int handle_b9(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) -- 2.13.3