From 44699e1c94bad41bbeb0c96f9ed344eb8e325413 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Wed, 6 Feb 2019 13:41:33 +0100 Subject: [PATCH 01/10] s390x: Fix the confusing contributions-after-2012 license statements The license information in these files is rather confusing. The text declares LGPL first, but then says that contributions after 2012 are licensed under the GPL instead. How should the average user who just downloaded the release tarball know which part is now GPL and which is LGPL? Looking at the text of the LGPL (see COPYING.LIB in the top directory), the license clearly states how this should be done instead: "3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License." Thus let's clean up the confusing statements and use the proper GPL text only. Signed-off-by: Thomas Huth Message-Id: <1549456893-16589-1-git-send-email-thuth@redhat.com> Acked-by: Laurent Vivier Acked-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- linux-user/s390x/target_cpu.h | 19 ++++++++----------- target/s390x/cpu.c | 19 ++++++++----------- target/s390x/cpu.h | 19 ++++++++----------- target/s390x/kvm.c | 19 ++++++++----------- 4 files changed, 32 insertions(+), 44 deletions(-) diff --git a/linux-user/s390x/target_cpu.h b/linux-user/s390x/target_cpu.h index 66ef8aa8c2..aa181ceaee 100644 --- a/linux-user/s390x/target_cpu.h +++ b/linux-user/s390x/target_cpu.h @@ -3,21 +3,18 @@ * * Copyright (c) 2009 Ulrich Hecht * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This library is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * General Public License for more details. * - * Contributions after 2012-10-29 are licensed under the terms of the - * GNU GPL, version 2 or (at your option) any later version. - * - * You should have received a copy of the GNU (Lesser) General Public - * License along with this library; if not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . */ #ifndef S390X_TARGET_CPU_H #define S390X_TARGET_CPU_H diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 18ba7f85a5..698dd9cb82 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -6,21 +6,18 @@ * Copyright (c) 2012 SUSE LINUX Products GmbH * Copyright (c) 2012 IBM Corp. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This library is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see - * - * Contributions after 2012-12-11 are licensed under the terms of the - * GNU GPL, version 2 or (at your option) any later version. + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . */ #include "qemu/osdep.h" diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 47d2c2e9cf..b71ac5183d 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -4,21 +4,18 @@ * Copyright (c) 2009 Ulrich Hecht * Copyright IBM Corp. 2012, 2018 * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This library is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * General Public License for more details. * - * Contributions after 2012-10-29 are licensed under the terms of the - * GNU GPL, version 2 or (at your option) any later version. - * - * You should have received a copy of the GNU (Lesser) General Public - * License along with this library; if not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . */ #ifndef S390X_CPU_H diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 8613e19d11..9ff80c8461 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -4,21 +4,18 @@ * Copyright (c) 2009 Alexander Graf * Copyright IBM Corp. 2012 * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This library is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * General Public License for more details. * - * Contributions after 2012-10-29 are licensed under the terms of the - * GNU GPL, version 2 or (at your option) any later version. - * - * You should have received a copy of the GNU (Lesser) General Public - * License along with this library; if not, see . + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . */ #include "qemu/osdep.h" From 09ced81aac76e1adfa0d4b9868f7dc4b38e66f19 Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Mon, 11 Feb 2019 12:32:55 +0100 Subject: [PATCH 02/10] s390x: always provide pci support We tried to make pci support optional on s390x in the past; unfortunately, we still require the s390 phb to be created unconditionally due to backwards compatibility issues. Instead of sinking more effort into this (including compat handling for older machines etc.) for non-obvious gains, let's just make CONFIG_PCI something that is always set on s390x. Note that you can still fence off pci for the _guest_ if you provide a cpu model without the zpci feature. Message-Id: <20190211113255.3837-1-cohuck@redhat.com> Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand Acked-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- hw/s390x/Makefile.objs | 3 +- hw/s390x/s390-pci-stub.c | 77 ------------------------------------- hw/s390x/s390-virtio-ccw.c | 4 -- target/s390x/cpu_models.c | 5 --- target/s390x/gen-features.c | 1 - target/s390x/kvm.c | 4 +- 6 files changed, 2 insertions(+), 92 deletions(-) delete mode 100644 hw/s390x/s390-pci-stub.c diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs index a18c471913..bfd5326d7c 100644 --- a/hw/s390x/Makefile.objs +++ b/hw/s390x/Makefile.objs @@ -21,8 +21,7 @@ obj-$(call land,$(CONFIG_VIRTIO_9P),$(CONFIG_VIRTFS)) += virtio-ccw-9p.o obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-ccw.o obj-y += css-bridge.o obj-y += ccw-device.o -obj-$(CONFIG_PCI) += s390-pci-bus.o s390-pci-inst.o -obj-$(call lnot,$(CONFIG_PCI)) += s390-pci-stub.o +obj-y += s390-pci-bus.o s390-pci-inst.o obj-y += s390-skeys.o obj-y += s390-stattrib.o obj-y += tod.o diff --git a/hw/s390x/s390-pci-stub.c b/hw/s390x/s390-pci-stub.c deleted file mode 100644 index ad4c5a7719..0000000000 --- a/hw/s390x/s390-pci-stub.c +++ /dev/null @@ -1,77 +0,0 @@ -/* stubs for non-pci builds */ - -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "cpu.h" -#include "s390-pci-inst.h" -#include "s390-pci-bus.h" - -/* target/s390x/ioinst.c */ -int pci_chsc_sei_nt2_get_event(void *res) -{ - return 1; -} - -int pci_chsc_sei_nt2_have_event(void) -{ - return 0; -} - -/* hw/s390x/sclp.c */ -void s390_pci_sclp_configure(SCCB *sccb) -{ - sccb->h.response_code = cpu_to_be16(SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED); -} - -void s390_pci_sclp_deconfigure(SCCB *sccb) -{ - sccb->h.response_code = cpu_to_be16(SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED); -} - -/* target/s390x/kvm.c */ -int clp_service_call(S390CPU *cpu, uint8_t r2) -{ - return -1; -} - -int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2) -{ - return -1; -} - -int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2) -{ - return -1; -} - -int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar) -{ - return -1; -} - -int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2) -{ - return -1; -} - -int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr, - uint8_t ar) -{ - return -1; -} - -int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar) -{ - return -1; -} - -S390pciState *s390_get_phb(void) -{ - return NULL; -} - -S390PCIBusDevice *s390_pci_find_dev_by_target(S390pciState *s, - const char *target) -{ - return NULL; -} diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 811fdf913d..3fb5c88af9 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -272,10 +272,6 @@ static void ccw_init(MachineState *machine) machine->initrd_filename, "s390-ccw.img", "s390-netboot.img", true); - /* - * We cannot easily make the pci host bridge conditional as older QEMUs - * always created it. Doing so would break migration across QEMU versions. - */ dev = qdev_create(NULL, TYPE_S390_PCI_HOST_BRIDGE); object_property_add_child(qdev_get_machine(), TYPE_S390_PCI_HOST_BRIDGE, OBJECT(dev), NULL); diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 7c253ff308..249011fd62 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -1314,11 +1314,6 @@ static void register_types(void) /* init all bitmaps from gnerated data initially */ s390_init_feat_bitmap(qemu_max_cpu_feat_init, qemu_max_cpu_feat); -#ifndef CONFIG_USER_ONLY - if (!pci_available) { - clear_bit(S390_FEAT_ZPCI, qemu_max_cpu_feat); - } -#endif for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) { s390_init_feat_bitmap(s390_cpu_defs[i].base_init, s390_cpu_defs[i].base_feat); diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index 70015eaaf5..b0e9b271e2 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -598,7 +598,6 @@ static uint16_t qemu_MAX[] = { S390_FEAT_STFLE_53, /* generates a dependency warning, leave it out for now */ S390_FEAT_MSA_EXT_5, - /* only with CONFIG_PCI */ S390_FEAT_ZPCI, }; diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 9ff80c8461..15fdc168e1 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2278,9 +2278,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) } /* We emulate a zPCI bus and AEN, therefore we don't need HW support */ - if (pci_available) { - set_bit(S390_FEAT_ZPCI, model->features); - } + set_bit(S390_FEAT_ZPCI, model->features); set_bit(S390_FEAT_ADAPTER_EVENT_NOTIFICATION, model->features); if (s390_known_cpu_type(cpu_type)) { From 4037c39ba5d0507fa9e1ee302013b4b35e2526f5 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 11 Feb 2019 21:30:43 -0800 Subject: [PATCH 03/10] target/s390x: Split out s390-tod.h We will need these from CONFIG_USER_ONLY as well, which cannot access include/hw/. Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson Message-Id: <20190212053044.29015-2-richard.henderson@linaro.org> Signed-off-by: Cornelia Huck --- include/hw/s390x/tod.h | 16 +--------------- target/s390x/s390-tod.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 target/s390x/s390-tod.h diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h index 47ef9de869..9c4a6000c3 100644 --- a/include/hw/s390x/tod.h +++ b/include/hw/s390x/tod.h @@ -12,6 +12,7 @@ #define HW_S390_TOD_H #include "hw/qdev.h" +#include "s390-tod.h" typedef struct S390TOD { uint8_t high; @@ -50,21 +51,6 @@ typedef struct S390TODClass { void (*set)(S390TODState *td, const S390TOD *tod, Error **errp); } S390TODClass; -/* The value of the TOD clock for 1.1.1970. */ -#define TOD_UNIX_EPOCH 0x7d91048bca000000ULL - -/* Converts ns to s390's clock format */ -static inline uint64_t time2tod(uint64_t ns) -{ - return (ns << 9) / 125 + (((ns & 0xff80000000000000ull) / 125) << 9); -} - -/* Converts s390's clock format to ns */ -static inline uint64_t tod2time(uint64_t t) -{ - return ((t >> 9) * 125) + (((t & 0x1ff) * 125) >> 9); -} - void s390_init_tod(void); S390TODState *s390_get_todstate(void); diff --git a/target/s390x/s390-tod.h b/target/s390x/s390-tod.h new file mode 100644 index 0000000000..8b74d6a6d8 --- /dev/null +++ b/target/s390x/s390-tod.h @@ -0,0 +1,29 @@ +/* + * TOD (Time Of Day) clock + * + * Copyright 2018 Red Hat, Inc. + * Author(s): David Hildenbrand + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef TARGET_S390_TOD_H +#define TARGET_S390_TOD_H + +/* The value of the TOD clock for 1.1.1970. */ +#define TOD_UNIX_EPOCH 0x7d91048bca000000ULL + +/* Converts ns to s390's clock format */ +static inline uint64_t time2tod(uint64_t ns) +{ + return (ns << 9) / 125 + (((ns & 0xff80000000000000ull) / 125) << 9); +} + +/* Converts s390's clock format to ns */ +static inline uint64_t tod2time(uint64_t t) +{ + return ((t >> 9) * 125) + (((t & 0x1ff) * 125) >> 9); +} + +#endif From 965018bea7ce79e1987b50ba9160cba957f015df Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 11 Feb 2019 21:30:44 -0800 Subject: [PATCH 04/10] target/s390x: Implement STCK et al for CONFIG_USER_ONLY This is a non-privileged instruction that was only implemented for system mode. However, the stck instruction is used by glibc, so this was causing SIGILL for programs run under debian stretch. Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson Message-Id: <20190212053044.29015-3-richard.henderson@linaro.org> Signed-off-by: Cornelia Huck --- target/s390x/helper.h | 2 +- target/s390x/insn-data.def | 11 ++++++----- target/s390x/misc_helper.c | 34 ++++++++++++++++++++++------------ target/s390x/translate.c | 2 ++ 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 018e9dd414..6260b50496 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -121,13 +121,13 @@ DEF_HELPER_4(cu41, i32, env, i32, i32, i32) DEF_HELPER_4(cu42, i32, env, i32, i32, i32) DEF_HELPER_5(msa, i32, env, i32, i32, i32, i32) DEF_HELPER_FLAGS_1(stpt, TCG_CALL_NO_RWG, i64, env) +DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env) #ifndef CONFIG_USER_ONLY DEF_HELPER_3(servc, i32, env, i64, i64) DEF_HELPER_4(diag, void, env, i32, i32, i32) DEF_HELPER_3(load_psw, noreturn, env, i64, i64) DEF_HELPER_FLAGS_2(spx, TCG_CALL_NO_RWG, void, env, i64) -DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env) DEF_HELPER_FLAGS_2(sck, TCG_CALL_NO_RWG, i32, env, i64) DEF_HELPER_FLAGS_2(sckc, TCG_CALL_NO_RWG, void, env, i64) DEF_HELPER_FLAGS_2(sckpf, TCG_CALL_NO_RWG, void, env, i64) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index dab805fd90..61582372ab 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -837,6 +837,12 @@ C(0xe33e, STRV, RXY_a, Z, la2, r1_32u, new, m1_32, rev32, 0) C(0xe32f, STRVG, RXY_a, Z, la2, r1_o, new, m1_64, rev64, 0) +/* STORE CLOCK */ + C(0xb205, STCK, S, Z, la2, 0, new, m1_64, stck, 0) + C(0xb27c, STCKF, S, SCF, la2, 0, new, m1_64, stck, 0) +/* STORE CLOCK EXTENDED */ + C(0xb278, STCKE, S, Z, 0, a2, 0, 0, stcke, 0) + /* STORE FACILITY LIST EXTENDED */ C(0xb2b0, STFLE, S, SFLE, 0, a2, 0, 0, stfle, 0) /* STORE FPC */ @@ -1020,11 +1026,6 @@ F(0x8000, SSM, S, Z, 0, m2_8u, 0, 0, ssm, 0, IF_PRIV) /* SIGNAL PROCESSOR */ F(0xae00, SIGP, RS_a, Z, 0, a2, 0, 0, sigp, 0, IF_PRIV) -/* STORE CLOCK */ - C(0xb205, STCK, S, Z, la2, 0, new, m1_64, stck, 0) - C(0xb27c, STCKF, S, SCF, la2, 0, new, m1_64, stck, 0) -/* STORE CLOCK EXTENDED */ - C(0xb278, STCKE, S, Z, 0, a2, 0, 0, stcke, 0) /* STORE CLOCK COMPARATOR */ F(0xb207, STCKC, S, Z, la2, 0, new, m1_64a, stckc, 0, IF_PRIV) /* STORE CONTROL */ diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index 52262f62df..ee67c1fa0c 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -30,6 +30,7 @@ #include "exec/cpu_ldst.h" #include "qapi/error.h" #include "tcg_s390x.h" +#include "s390-tod.h" #if !defined(CONFIG_USER_ONLY) #include "sysemu/cpus.h" @@ -76,8 +77,28 @@ uint64_t HELPER(stpt)(CPUS390XState *env) #endif } -#ifndef CONFIG_USER_ONLY +/* Store Clock */ +uint64_t HELPER(stck)(CPUS390XState *env) +{ +#ifdef CONFIG_USER_ONLY + struct timespec ts; + uint64_t ns; + clock_gettime(CLOCK_REALTIME, &ts); + ns = ts.tv_sec * NANOSECONDS_PER_SECOND + ts.tv_nsec; + + return TOD_UNIX_EPOCH + time2tod(ns); +#else + S390TODState *td = s390_get_todstate(); + S390TODClass *tdc = S390_TOD_GET_CLASS(td); + S390TOD tod; + + tdc->get(td, &tod, &error_abort); + return tod.low; +#endif +} + +#ifndef CONFIG_USER_ONLY /* SCLP service call */ uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2) { @@ -138,17 +159,6 @@ void HELPER(spx)(CPUS390XState *env, uint64_t a1) tlb_flush_page(cs, TARGET_PAGE_SIZE); } -/* Store Clock */ -uint64_t HELPER(stck)(CPUS390XState *env) -{ - S390TODState *td = s390_get_todstate(); - S390TODClass *tdc = S390_TOD_GET_CLASS(td); - S390TOD tod; - - tdc->get(td, &tod, &error_abort); - return tod.low; -} - static void update_ckc_timer(CPUS390XState *env) { S390TODState *td = s390_get_todstate(); diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 639084af07..19072efec6 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -4060,6 +4060,7 @@ static DisasJumpType op_stap(DisasContext *s, DisasOps *o) tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, core_id)); return DISAS_NEXT; } +#endif static DisasJumpType op_stck(DisasContext *s, DisasOps *o) { @@ -4096,6 +4097,7 @@ static DisasJumpType op_stcke(DisasContext *s, DisasOps *o) return DISAS_NEXT; } +#ifndef CONFIG_USER_ONLY static DisasJumpType op_sck(DisasContext *s, DisasOps *o) { tcg_gen_qemu_ld_i64(o->in1, o->addr1, get_mem_index(s), MO_TEQ | MO_ALIGN); From d646b16b21eca8d586dcbbd15bb47ed0387546c6 Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Tue, 12 Feb 2019 12:23:23 +0100 Subject: [PATCH 05/10] s390x: add zPCI feature to "qemu" CPU model As we now always have PCI support, let's add it to the "qemu" CPU model, taking care of backwards compatibility. Signed-off-by: David Hildenbrand Message-Id: <20190212112323.15904-1-david@redhat.com> Signed-off-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 3 +++ target/s390x/gen-features.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 3fb5c88af9..1a3414b642 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -657,7 +657,10 @@ DEFINE_CCW_MACHINE(4_0, "4.0", true); static void ccw_machine_3_1_instance_options(MachineState *machine) { + static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V3_1 }; ccw_machine_4_0_instance_options(machine); + + s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat); } static void ccw_machine_3_1_class_options(MachineClass *mc) diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index b0e9b271e2..19bb8ac7f8 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -560,7 +560,7 @@ static uint16_t qemu_V2_11[] = { S390_FEAT_ZARCH, }; -static uint16_t qemu_LATEST[] = { +static uint16_t qemu_V3_1[] = { S390_FEAT_DAT_ENH, S390_FEAT_IDTE_SEGMENT, S390_FEAT_STFLE, @@ -592,13 +592,16 @@ static uint16_t qemu_LATEST[] = { S390_FEAT_MSA_EXT_4, }; +static uint16_t qemu_LATEST[] = { + S390_FEAT_ZPCI, +}; + /* add all new definitions before this point */ static uint16_t qemu_MAX[] = { /* z13+ features */ S390_FEAT_STFLE_53, /* generates a dependency warning, leave it out for now */ S390_FEAT_MSA_EXT_5, - S390_FEAT_ZPCI, }; /****** END FEATURE DEFS ******/ @@ -708,6 +711,7 @@ static FeatGroupDefSpec FeatGroupDef[] = { *******************************/ static FeatGroupDefSpec QemuFeatDef[] = { QEMU_FEAT_INITIALIZER(V2_11), + QEMU_FEAT_INITIALIZER(V3_1), QEMU_FEAT_INITIALIZER(LATEST), QEMU_FEAT_INITIALIZER(MAX), }; From ddf5d18af3ce3029d5b93222af5a9e8160d4c34b Mon Sep 17 00:00:00 2001 From: Collin Walling Date: Mon, 11 Feb 2019 20:16:55 -0500 Subject: [PATCH 06/10] s390x/cpumodel: mepochptff: warn when no mepoch and re-align group init The extended PTFF features (qsie, qtoue, stoe, stoue) are dependent on the multiple-epoch facility (mepoch). Let's print a warning if these features are enabled without mepoch. While we're at it, let's move the FEAT_GROUP_INIT for mepochptff down the s390_feature_groups list so it can be properly indexed with its generated S390FeatGroup enum. Signed-off-by: Collin Walling Message-Id: <20190212011657.18324-1-walling@linux.ibm.com> Reviewed-by: Christian Borntraeger Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- target/s390x/cpu_features.c | 2 +- target/s390x/cpu_models.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c index 60cfeba48f..1843c84aaa 100644 --- a/target/s390x/cpu_features.c +++ b/target/s390x/cpu_features.c @@ -456,7 +456,6 @@ static S390FeatGroupDef s390_feature_groups[] = { FEAT_GROUP_INIT("plo", PLO, "Perform-locked-operation facility"), FEAT_GROUP_INIT("tods", TOD_CLOCK_STEERING, "Tod-clock-steering facility"), FEAT_GROUP_INIT("gen13ptff", GEN13_PTFF, "PTFF enhancements introduced with z13"), - FEAT_GROUP_INIT("mepochptff", MULTIPLE_EPOCH_PTFF, "PTFF enhancements introduced with Multiple-epoch facility"), FEAT_GROUP_INIT("msa", MSA, "Message-security-assist facility"), FEAT_GROUP_INIT("msa1", MSA_EXT_1, "Message-security-assist-extension 1 facility"), FEAT_GROUP_INIT("msa2", MSA_EXT_2, "Message-security-assist-extension 2 facility"), @@ -466,6 +465,7 @@ static S390FeatGroupDef s390_feature_groups[] = { FEAT_GROUP_INIT("msa6", MSA_EXT_6, "Message-security-assist-extension 6 facility"), FEAT_GROUP_INIT("msa7", MSA_EXT_7, "Message-security-assist-extension 7 facility"), FEAT_GROUP_INIT("msa8", MSA_EXT_8, "Message-security-assist-extension 8 facility"), + FEAT_GROUP_INIT("mepochptff", MULTIPLE_EPOCH_PTFF, "PTFF enhancements introduced with Multiple-epoch facility"), }; const S390FeatGroupDef *s390_feat_group_def(S390FeatGroup group) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 249011fd62..8002412f9a 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -788,6 +788,10 @@ static void check_consistency(const S390CPUModel *model) { S390_FEAT_SIE_KSS, S390_FEAT_SIE_F2 }, { S390_FEAT_AP_QUERY_CONFIG_INFO, S390_FEAT_AP }, { S390_FEAT_AP_FACILITIES_TEST, S390_FEAT_AP }, + { S390_FEAT_PTFF_QSIE, S390_FEAT_MULTIPLE_EPOCH }, + { S390_FEAT_PTFF_QTOUE, S390_FEAT_MULTIPLE_EPOCH }, + { S390_FEAT_PTFF_STOE, S390_FEAT_MULTIPLE_EPOCH }, + { S390_FEAT_PTFF_STOUE, S390_FEAT_MULTIPLE_EPOCH }, }; int i; From 84176c7906ffaf59457bd7dff25a3ea32e00c3d8 Mon Sep 17 00:00:00 2001 From: Collin Walling Date: Mon, 11 Feb 2019 20:16:56 -0500 Subject: [PATCH 07/10] s390x/cpumodel: default enable mepoch for z14 and later Latest systems and host kernels support mepoch, which is a feature that was meant to be supported for z14 GA1 from the get-go. Let's copy it to the z14 GA1 default CPU model. Machines s390-ccw-virtio-3.1 and older will retain the old CPU models and will not provide this bit nor the extended PTFF functions in the default model. Signed-off-by: Collin Walling Message-Id: <20190212011657.18324-2-walling@linux.ibm.com> Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 3 ++- target/s390x/cpu_models.c | 24 ++++++++++++++++++++++++ target/s390x/cpu_models.h | 2 ++ target/s390x/gen-features.c | 2 ++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 1a3414b642..d11069b860 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -659,7 +659,8 @@ static void ccw_machine_3_1_instance_options(MachineState *machine) { static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V3_1 }; ccw_machine_4_0_instance_options(machine); - + s390_cpudef_featoff_greater(14, 1, S390_FEAT_MULTIPLE_EPOCH); + s390_cpudef_group_featoff_greater(14, 1, S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF); s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat); } diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 8002412f9a..4e7e8cab01 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -117,6 +117,30 @@ void s390_cpudef_featoff_greater(uint8_t gen, uint8_t ec_ga, S390Feat feat) } } +void s390_cpudef_group_featoff_greater(uint8_t gen, uint8_t ec_ga, + S390FeatGroup group) +{ + const S390FeatGroupDef *group_def = s390_feat_group_def(group); + S390FeatBitmap group_def_off; + int i; + + bitmap_complement(group_def_off, group_def->feat, S390_FEAT_MAX); + + for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) { + const S390CPUDef *cpu_def = &s390_cpu_defs[i]; + + if (cpu_def->gen < gen) { + continue; + } + if (cpu_def->gen == gen && cpu_def->ec_ga < ec_ga) { + continue; + } + + bitmap_and((unsigned long *)&cpu_def->default_feat, + cpu_def->default_feat, group_def_off, S390_FEAT_MAX); + } +} + uint32_t s390_get_hmfai(void) { static S390CPU *cpu; diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index 11cf5386fb..174a99e561 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -75,6 +75,8 @@ struct S390CPUModel { void s390_cpudef_featoff(uint8_t gen, uint8_t ec_ga, S390Feat feat); void s390_cpudef_featoff_greater(uint8_t gen, uint8_t ec_ga, S390Feat feat); +void s390_cpudef_group_featoff_greater(uint8_t gen, uint8_t ec_ga, + S390FeatGroup group); uint32_t s390_get_hmfai(void); uint8_t s390_get_mha_pow(void); uint32_t s390_get_ibc_val(void); diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index 19bb8ac7f8..dd6e8458ef 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -550,6 +550,8 @@ static uint16_t default_GEN14_GA1[] = { S390_FEAT_GROUP_MSA_EXT_6, S390_FEAT_GROUP_MSA_EXT_7, S390_FEAT_GROUP_MSA_EXT_8, + S390_FEAT_MULTIPLE_EPOCH, + S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF, }; /* QEMU (CPU model) features */ From f2a7d1577115bda770d619ff5bc45db1f656edc3 Mon Sep 17 00:00:00 2001 From: Collin Walling Date: Mon, 11 Feb 2019 20:16:57 -0500 Subject: [PATCH 08/10] s390x/cpumodel: add z14 GA2 model Introduce the z14 GA2 cpu model for QEMU. There are no new features introduced with this model, and will inherit the same feature set as z14 GA1. Signed-off-by: Collin Walling Acked-by: Christian Borntraeger Reviewed-by: David Hildenbrand Message-Id: <20190212011657.18324-3-walling@linux.ibm.com> Signed-off-by: Cornelia Huck --- target/s390x/cpu_models.c | 1 + target/s390x/gen-features.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 4e7e8cab01..54026c3c00 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -79,6 +79,7 @@ static S390CPUDef s390_cpu_defs[] = { CPUDEF_INIT(0x2964, 13, 2, 47, 0x08000000U, "z13.2", "IBM z13 GA2"), CPUDEF_INIT(0x2965, 13, 2, 47, 0x08000000U, "z13s", "IBM z13s GA1"), CPUDEF_INIT(0x3906, 14, 1, 47, 0x08000000U, "z14", "IBM z14 GA1"), + CPUDEF_INIT(0x3906, 14, 2, 47, 0x08000000U, "z14.2", "IBM z14 GA2"), CPUDEF_INIT(0x3907, 14, 1, 47, 0x08000000U, "z14ZR1", "IBM z14 Model ZR1 GA1"), }; diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index dd6e8458ef..44eca45474 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -353,6 +353,8 @@ static uint16_t base_GEN14_GA1[] = { S390_FEAT_ORDER_PRESERVING_COMPRESSION, }; +#define base_GEN14_GA2 EmptyFeat + /* Full features (in order of release) * Automatically includes corresponding base features. * Full features are all features this hardware supports even if kvm/QEMU do not @@ -480,6 +482,8 @@ static uint16_t full_GEN14_GA1[] = { S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF, }; +#define full_GEN14_GA2 EmptyFeat + /* Default features (in order of release) * Automatically includes corresponding base features. * Default features are all features this version of QEMU supports for this @@ -554,6 +558,8 @@ static uint16_t default_GEN14_GA1[] = { S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF, }; +#define default_GEN14_GA2 EmptyFeat + /* QEMU (CPU model) features */ static uint16_t qemu_V2_11[] = { @@ -664,6 +670,7 @@ static CpuFeatDefSpec CpuFeatDef[] = { CPU_FEAT_INITIALIZER(GEN13_GA1), CPU_FEAT_INITIALIZER(GEN13_GA2), CPU_FEAT_INITIALIZER(GEN14_GA1), + CPU_FEAT_INITIALIZER(GEN14_GA2), }; #define FEAT_GROUP_INITIALIZER(_name) \ From 747c432f1e63dab75e5ea6184d8e844a6d7e67f8 Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Tue, 12 Feb 2019 15:50:00 +0100 Subject: [PATCH 09/10] s390x/kvm: add tracepoint to ioeventfd interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trace when assigning/unassigning. Message-Id: <20190212153025.25425-1-cohuck@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cornelia Huck --- target/s390x/kvm.c | 2 ++ target/s390x/trace-events | 1 + 2 files changed, 3 insertions(+) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 15fdc168e1..19530fb94e 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1886,6 +1886,8 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, .addr = sch, .len = 8, }; + trace_kvm_assign_subch_ioeventfd(kick.fd, kick.addr, assign, + kick.datamatch); if (!kvm_check_extension(kvm_state, KVM_CAP_IOEVENTFD)) { return -ENOSYS; } diff --git a/target/s390x/trace-events b/target/s390x/trace-events index a84e316e49..e509b08799 100644 --- a/target/s390x/trace-events +++ b/target/s390x/trace-events @@ -14,6 +14,7 @@ ioinst_chsc_cmd(uint16_t cmd, uint16_t len) "IOINST: chsc 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) "Warning: Unable to set cpu %d state %" PRIu8 " to KVM: %s" +kvm_assign_subch_ioeventfd(int fd, uint32_t addr, bool assign, int datamatch) "fd: %d sch: @0x%x assign: %d vq: %d" # target/s390x/cpu.c cpu_set_state(int cpu_index, uint8_t state) "setting cpu %d state to %" PRIu8 From 0922e8c093a564219fcb7f43b18ceb12714dd931 Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Wed, 13 Feb 2019 11:31:59 +0100 Subject: [PATCH 10/10] s390x: upgrade status of KVM cores to "supported" We are actually paid to look after this. Message-Id: <20190213103519.32585-1-cohuck@redhat.com> Acked-by: Christian Borntraeger Acked-by: Halil Pasic Signed-off-by: Cornelia Huck --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index ffb029f63a..b1d786cfd8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -375,7 +375,7 @@ S390 M: Halil Pasic M: Cornelia Huck M: Christian Borntraeger -S: Maintained +S: Supported F: target/s390x/kvm.c F: target/s390x/kvm_s390x.h F: target/s390x/kvm-stub.c