[PATCH v7 11/14] target/s390x: use kvm_enabled() to wrap call to kvm_s390_get_hpage_1m
this will allow to remove the kvm stubs. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Reviewed-by: Thomas Huth --- target/s390x/diag.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/s390x/diag.c b/target/s390x/diag.c index c17a2498a7..8405f69df0 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -20,6 +20,7 @@ #include "hw/s390x/ipl.h" #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/pv.h" +#include "sysemu/kvm.h" #include "kvm_s390x.h" int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3) @@ -168,7 +169,7 @@ out: return; } -if (kvm_s390_get_hpage_1m()) { +if (kvm_enabled() && kvm_s390_get_hpage_1m()) { error_report("Protected VMs can currently not be backed with " "huge pages"); env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV; -- 2.32.0
[PATCH v7 14/14] target/s390x: split sysemu part of cpu models
split sysemu part of cpu models, also create a tiny _user.c with just the (at least for now), empty implementation of apply_cpu_model. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Reviewed-by: Thomas Huth --- MAINTAINERS | 1 + target/s390x/cpu_models.c| 417 +- target/s390x/cpu_models_sysemu.c | 426 +++ target/s390x/cpu_models_user.c | 20 ++ target/s390x/meson.build | 4 + target/s390x/s390x-internal.h| 2 + 6 files changed, 454 insertions(+), 416 deletions(-) create mode 100644 target/s390x/cpu_models_sysemu.c create mode 100644 target/s390x/cpu_models_user.c diff --git a/MAINTAINERS b/MAINTAINERS index 11d9ce72aa..af1edb3e6e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -298,6 +298,7 @@ M: David Hildenbrand S: Maintained F: target/s390x/ F: target/s390x/tcg +F: target/s390x/cpu_models_*.[ch] F: hw/s390x/ F: disas/s390.c F: tests/tcg/s390x/ diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index ba8f6a55ac..ef82e833b5 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -18,18 +18,11 @@ #include "sysemu/tcg.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/qemu-print.h" -#include "qapi/qmp/qerror.h" -#include "qapi/qobject-input-visitor.h" -#include "qapi/qmp/qdict.h" #ifndef CONFIG_USER_ONLY -#include "sysemu/arch_init.h" #include "sysemu/sysemu.h" -#include "hw/pci/pci.h" #endif -#include "qapi/qapi-commands-machine-target.h" #include "hw/s390x/pv.h" #define CPUDEF_INIT(_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \ @@ -414,381 +407,6 @@ void s390_cpu_list(void) } } -static S390CPUModel *get_max_cpu_model(Error **errp); - -#ifndef CONFIG_USER_ONLY -static void list_add_feat(const char *name, void *opaque); - -static void check_unavailable_features(const S390CPUModel *max_model, - const S390CPUModel *model, - strList **unavailable) -{ -S390FeatBitmap missing; - -/* check general model compatibility */ -if (max_model->def->gen < model->def->gen || -(max_model->def->gen == model->def->gen && - max_model->def->ec_ga < model->def->ec_ga)) { -list_add_feat("type", unavailable); -} - -/* detect missing features if any to properly report them */ -bitmap_andnot(missing, model->features, max_model->features, - S390_FEAT_MAX); -if (!bitmap_empty(missing, S390_FEAT_MAX)) { -s390_feat_bitmap_to_ascii(missing, unavailable, list_add_feat); -} -} - -struct CpuDefinitionInfoListData { -CpuDefinitionInfoList *list; -S390CPUModel *model; -}; - -static void create_cpu_model_list(ObjectClass *klass, void *opaque) -{ -struct CpuDefinitionInfoListData *cpu_list_data = opaque; -CpuDefinitionInfoList **cpu_list = _list_data->list; -CpuDefinitionInfo *info; -char *name = g_strdup(object_class_get_name(klass)); -S390CPUClass *scc = S390_CPU_CLASS(klass); - -/* strip off the -s390x-cpu */ -g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0; -info = g_new0(CpuDefinitionInfo, 1); -info->name = name; -info->has_migration_safe = true; -info->migration_safe = scc->is_migration_safe; -info->q_static = scc->is_static; -info->q_typename = g_strdup(object_class_get_name(klass)); -/* check for unavailable features */ -if (cpu_list_data->model) { -Object *obj; -S390CPU *sc; -obj = object_new_with_class(klass); -sc = S390_CPU(obj); -if (sc->model) { -info->has_unavailable_features = true; -check_unavailable_features(cpu_list_data->model, sc->model, - >unavailable_features); -} -object_unref(obj); -} - -QAPI_LIST_PREPEND(*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ -struct CpuDefinitionInfoListData list_data = { -.list = NULL, -}; - -list_data.model = get_max_cpu_model(NULL); - -object_class_foreach(create_cpu_model_list, TYPE_S390_CPU, false, - _data); - -return list_data.list; -} - -static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, -Error **errp) -{ -Error *err = NULL; -const QDict *qdict = NULL; -const QDictEntry *e; -Visitor *visitor; -ObjectClass *oc; -S390CPU *cpu; -Object *obj; - -if (info->props) { -qdict = qobject_to(QDict, info->props); -if (!qdict) { -
[PATCH v7 10/14] target/s390x: make helper.c sysemu-only
Now that we have moved cpu-dump functionality out of helper.c, we can make the module sysemu-only. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck Reviewed-by: Thomas Huth --- target/s390x/helper.c| 9 + target/s390x/meson.build | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index c72e990f4d..6e35473c7f 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -1,5 +1,5 @@ /* - * S/390 helpers + * S/390 helpers - sysemu only * * Copyright (c) 2009 Ulrich Hecht * Copyright (c) 2011 Alexander Graf @@ -27,11 +27,8 @@ #include "hw/s390x/pv.h" #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" -#ifndef CONFIG_USER_ONLY #include "sysemu/tcg.h" -#endif -#ifndef CONFIG_USER_ONLY void s390x_tod_timer(void *opaque) { cpu_inject_clock_comparator((S390CPU *) opaque); @@ -284,7 +281,3 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) cpu_physical_memory_unmap(sa, len, 1, len); return 0; } -#else -/* For user-only, tcg is always enabled. */ -#define tcg_enabled() true -#endif /* CONFIG_USER_ONLY */ diff --git a/target/s390x/meson.build b/target/s390x/meson.build index 6e1aa3b0cd..bbcaede384 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -4,7 +4,6 @@ s390x_ss.add(files( 'cpu_features.c', 'cpu_models.c', 'gdbstub.c', - 'helper.c', 'interrupt.c', 'cpu-dump.c', )) @@ -23,6 +22,7 @@ s390x_ss.add(gen_features_h) s390x_softmmu_ss = ss.source_set() s390x_softmmu_ss.add(files( + 'helper.c', 'arch_dump.c', 'diag.c', 'ioinst.c', -- 2.32.0
[PATCH v7 04/14] hw/s390x: only build tod-tcg from the CONFIG_TCG build
this will allow in later patches to remove unneeded stubs in target/s390x. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth --- hw/s390x/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index 02e81a9467..28484256ec 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -16,7 +16,6 @@ s390x_ss.add(files( 'sclp.c', 'sclpcpu.c', 'sclpquiesce.c', - 'tod-tcg.c', 'tod.c', )) s390x_ss.add(when: 'CONFIG_KVM', if_true: files( @@ -25,6 +24,9 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files( 's390-stattrib-kvm.c', 'pv.c', )) +s390x_ss.add(when: 'CONFIG_TCG', if_true: files( + 'tod-tcg.c', +)) s390x_ss.add(when: 'CONFIG_S390_CCW_VIRTIO', if_true: files('s390-virtio-ccw.c')) s390x_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('3270-ccw.c')) s390x_ss.add(when: 'CONFIG_VFIO', if_true: files('s390-pci-vfio.c')) -- 2.32.0
[PATCH v7 09/14] target/s390x: split cpu-dump from helper.c
Splitting this functionality also allows us to make helper.c sysemu-only. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck --- target/s390x/cpu-dump.c | 134 ++ target/s390x/cpu.c | 43 +++ target/s390x/helper.c| 151 --- target/s390x/meson.build | 1 + 4 files changed, 178 insertions(+), 151 deletions(-) create mode 100644 target/s390x/cpu-dump.c diff --git a/target/s390x/cpu-dump.c b/target/s390x/cpu-dump.c new file mode 100644 index 00..0f5c062994 --- /dev/null +++ b/target/s390x/cpu-dump.c @@ -0,0 +1,134 @@ +/* + * S/390 CPU dump to FILE + * + * Copyright (c) 2009 Ulrich Hecht + * Copyright (c) 2011 Alexander Graf + * + * 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 library 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. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "s390x-internal.h" +#include "qemu/qemu-print.h" +#include "sysemu/tcg.h" + +void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags) +{ +S390CPU *cpu = S390_CPU(cs); +CPUS390XState *env = >env; +int i; + +qemu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64, + s390_cpu_get_psw_mask(env), env->psw.addr); +if (!tcg_enabled()) { +qemu_fprintf(f, "\n"); +} else if (env->cc_op > 3) { +qemu_fprintf(f, " cc %15s\n", cc_name(env->cc_op)); +} else { +qemu_fprintf(f, " cc %02x\n", env->cc_op); +} + +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "R%02d=%016" PRIx64, i, env->regs[i]); +if ((i % 4) == 3) { +qemu_fprintf(f, "\n"); +} else { +qemu_fprintf(f, " "); +} +} + +if (flags & CPU_DUMP_FPU) { +if (s390_has_feat(S390_FEAT_VECTOR)) { +for (i = 0; i < 32; i++) { +qemu_fprintf(f, "V%02d=%016" PRIx64 "%016" PRIx64 "%c", + i, env->vregs[i][0], env->vregs[i][1], + i % 2 ? '\n' : ' '); +} +} else { +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "F%02d=%016" PRIx64 "%c", + i, *get_freg(env, i), + (i % 4) == 3 ? '\n' : ' '); +} +} +} + +#ifndef CONFIG_USER_ONLY +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "C%02d=%016" PRIx64, i, env->cregs[i]); +if ((i % 4) == 3) { +qemu_fprintf(f, "\n"); +} else { +qemu_fprintf(f, " "); +} +} +#endif + +#ifdef DEBUG_INLINE_BRANCHES +for (i = 0; i < CC_OP_MAX; i++) { +qemu_fprintf(f, " %15s = %10ld\t%10ld\n", cc_name(i), + inline_branch_miss[i], inline_branch_hit[i]); +} +#endif + +qemu_fprintf(f, "\n"); +} + +const char *cc_name(enum cc_op cc_op) +{ +static const char * const cc_names[] = { +[CC_OP_CONST0]= "CC_OP_CONST0", +[CC_OP_CONST1]= "CC_OP_CONST1", +[CC_OP_CONST2]= "CC_OP_CONST2", +[CC_OP_CONST3]= "CC_OP_CONST3", +[CC_OP_DYNAMIC] = "CC_OP_DYNAMIC", +[CC_OP_STATIC]= "CC_OP_STATIC", +[CC_OP_NZ]= "CC_OP_NZ", +[CC_OP_ADDU] = "CC_OP_ADDU", +[CC_OP_SUBU] = "CC_OP_SUBU", +[CC_OP_LTGT_32] = "CC_OP_LTGT_32", +[CC_OP_LTGT_64] = "CC_OP_LTGT_64", +[CC_OP_LTUGTU_32] = "CC_OP_LTUGTU_32", +[CC_OP_LTUGTU_64] = "CC_OP_LTUGTU_64", +[CC_OP_LTGT0_32] = "CC_OP_LTGT0_32", +[CC_OP_LTGT0_64] = "CC_OP_LTGT0_64", +[CC_OP_ADD_64]= "CC_OP_ADD_64", +[CC_OP_SUB_64]= "CC_OP_SUB_64", +[CC_OP_ABS_64]= "CC_OP_ABS_64", +[CC_OP_NABS_64] = "CC_OP_NABS_64", +[CC_OP_ADD_32]= "CC_OP_ADD_32", +[CC_OP_SUB_32]= "CC_OP_SUB_32", +[CC_OP_ABS_3
[PATCH v7 06/14] target/s390x: rename internal.h to s390x-internal.h
The internal.h file is renamed to s390x-internal.h, because of the risk of collision with other files with the same name. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: David Hildenbrand Acked-by: Cornelia Huck --- target/s390x/arch_dump.c | 2 +- target/s390x/cc_helper.c | 2 +- target/s390x/cpu.c| 2 +- target/s390x/cpu_models.c | 2 +- target/s390x/crypto_helper.c | 2 +- target/s390x/diag.c | 2 +- target/s390x/excp_helper.c| 2 +- target/s390x/fpu_helper.c | 2 +- target/s390x/gdbstub.c| 2 +- target/s390x/helper.c | 2 +- target/s390x/int_helper.c | 2 +- target/s390x/interrupt.c | 2 +- target/s390x/ioinst.c | 2 +- target/s390x/kvm.c| 2 +- target/s390x/machine.c| 2 +- target/s390x/mem_helper.c | 2 +- target/s390x/misc_helper.c| 2 +- target/s390x/mmu_helper.c | 2 +- target/s390x/{internal.h => s390x-internal.h} | 0 target/s390x/sigp.c | 2 +- target/s390x/translate.c | 2 +- target/s390x/vec_fpu_helper.c | 2 +- target/s390x/vec_helper.c | 2 +- target/s390x/vec_string_helper.c | 2 +- 24 files changed, 23 insertions(+), 23 deletions(-) rename target/s390x/{internal.h => s390x-internal.h} (100%) diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c index cc1330876b..08daf93ae1 100644 --- a/target/s390x/arch_dump.c +++ b/target/s390x/arch_dump.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "internal.h" +#include "s390x-internal.h" #include "elf.h" #include "sysemu/dump.h" diff --git a/target/s390x/cc_helper.c b/target/s390x/cc_helper.c index e7a74d66dd..c2c96c3a3c 100644 --- a/target/s390x/cc_helper.c +++ b/target/s390x/cc_helper.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "internal.h" +#include "s390x-internal.h" #include "tcg_s390x.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 890f382a36..1795042e97 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -23,7 +23,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "cpu.h" -#include "internal.h" +#include "s390x-internal.h" #include "kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 94090a6e22..94789c7280 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -12,7 +12,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "internal.h" +#include "s390x-internal.h" #include "kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h" diff --git a/target/s390x/crypto_helper.c b/target/s390x/crypto_helper.c index ff3fbc3950..138d9e7ad9 100644 --- a/target/s390x/crypto_helper.c +++ b/target/s390x/crypto_helper.c @@ -12,7 +12,7 @@ #include "qemu/osdep.h" #include "qemu/main-loop.h" -#include "internal.h" +#include "s390x-internal.h" #include "tcg_s390x.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" diff --git a/target/s390x/diag.c b/target/s390x/diag.c index d620cd4bd4..c17a2498a7 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -14,7 +14,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "internal.h" +#include "s390x-internal.h" #include "hw/watchdog/wdt_diag288.h" #include "sysemu/cpus.h" #include "hw/s390x/ipl.h" diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 9c361428c8..a61917d04f 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "internal.h" +#include "s390x-internal.h" #include "exec/helper-proto.h" #include "qemu/timer.h" #include "exec/exec-all.h" diff --git a/target/s390x/fpu_helper.c b/target/s390x/fpu_helper.c index 13af158748..04517fbf9c 100644 --- a/target/s390x/fpu_helper.c +++ b/target/s390x/fpu_helper.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "internal.h" +#include "s390x-internal.h" #include "tcg_s39
[PATCH v7 03/14] hw/s390x: tod: make explicit checks for accelerators when initializing
replace general "else" with specific checks for each possible accelerator. Handle qtest as a NOP, and error out for an unknown accelerator used in combination with tod. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth --- hw/s390x/tod.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/s390x/tod.c b/hw/s390x/tod.c index 3c2979175e..fd5a36bf24 100644 --- a/hw/s390x/tod.c +++ b/hw/s390x/tod.c @@ -14,6 +14,8 @@ #include "qemu/error-report.h" #include "qemu/module.h" #include "sysemu/kvm.h" +#include "sysemu/tcg.h" +#include "sysemu/qtest.h" #include "migration/qemu-file-types.h" #include "migration/register.h" @@ -23,8 +25,13 @@ void s390_init_tod(void) if (kvm_enabled()) { obj = object_new(TYPE_KVM_S390_TOD); -} else { +} else if (tcg_enabled()) { obj = object_new(TYPE_QEMU_S390_TOD); +} else if (qtest_enabled()) { +return; +} else { +error_report("current accelerator not handled in s390_init_tod!"); +abort(); } object_property_add_child(qdev_get_machine(), TYPE_S390_TOD, obj); object_unref(obj); -- 2.32.0
[PATCH v7 13/14] target/s390x: move kvm files into kvm/
move kvm files into kvm/ After the reshuffling, update MAINTAINERS accordingly. Make use of the new directory: target/s390x/kvm/ Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Reviewed-by: Cornelia Huck --- MAINTAINERS| 3 +-- hw/intc/s390_flic_kvm.c| 2 +- hw/s390x/s390-stattrib-kvm.c | 2 +- hw/s390x/tod-kvm.c | 2 +- hw/vfio/ap.c | 2 +- meson.build| 1 + target/s390x/cpu-sysemu.c | 2 +- target/s390x/cpu.c | 2 +- target/s390x/cpu_models.c | 2 +- target/s390x/diag.c| 2 +- target/s390x/interrupt.c | 2 +- target/s390x/{ => kvm}/kvm.c | 0 target/s390x/{ => kvm}/kvm_s390x.h | 0 target/s390x/kvm/meson.build | 17 + target/s390x/kvm/trace-events | 7 +++ target/s390x/kvm/trace.h | 1 + target/s390x/machine.c | 2 +- target/s390x/meson.build | 16 +--- target/s390x/mmu_helper.c | 2 +- target/s390x/trace-events | 6 -- 20 files changed, 39 insertions(+), 34 deletions(-) rename target/s390x/{ => kvm}/kvm.c (100%) rename target/s390x/{ => kvm}/kvm_s390x.h (100%) create mode 100644 target/s390x/kvm/meson.build create mode 100644 target/s390x/kvm/trace-events create mode 100644 target/s390x/kvm/trace.h diff --git a/MAINTAINERS b/MAINTAINERS index 4e04800576..11d9ce72aa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -394,8 +394,7 @@ M: Halil Pasic M: Cornelia Huck M: Christian Borntraeger S: Supported -F: target/s390x/kvm.c -F: target/s390x/kvm_s390x.h +F: target/s390x/kvm/ F: target/s390x/ioinst.[ch] F: target/s390x/machine.c F: target/s390x/sigp.c diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 929cfa3a68..efe5054182 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -11,7 +11,7 @@ */ #include "qemu/osdep.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include #include "qemu/error-report.h" #include "qemu/module.h" diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c index f0b11a74e4..24cd01382e 100644 --- a/hw/s390x/s390-stattrib-kvm.c +++ b/hw/s390x/s390-stattrib-kvm.c @@ -16,7 +16,7 @@ #include "qemu/error-report.h" #include "sysemu/kvm.h" #include "exec/ram_addr.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" Object *kvm_s390_stattrib_create(void) { diff --git a/hw/s390x/tod-kvm.c b/hw/s390x/tod-kvm.c index 0b94477486..ec855811ae 100644 --- a/hw/s390x/tod-kvm.c +++ b/hw/s390x/tod-kvm.c @@ -13,7 +13,7 @@ #include "qemu/module.h" #include "sysemu/runstate.h" #include "hw/s390x/tod.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" static void kvm_s390_get_tod_raw(S390TOD *tod, Error **errp) { diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 4b32aca1a0..e0dd561e85 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -21,7 +21,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" #include "hw/s390x/ap-bridge.h" diff --git a/meson.build b/meson.build index 7e12de01be..b458cd33b8 100644 --- a/meson.build +++ b/meson.build @@ -2102,6 +2102,7 @@ if have_system or have_user 'target/ppc', 'target/riscv', 'target/s390x', +'target/s390x/kvm', 'target/sparc', ] endif diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c index 16e5301084..df2c6bf694 100644 --- a/target/s390x/cpu-sysemu.c +++ b/target/s390x/cpu-sysemu.c @@ -24,7 +24,7 @@ #include "qapi/error.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "qemu/timer.h" diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 5c456f6014..7b7b05f1d3 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -24,7 +24,7 @@ #include "qapi/error.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "qemu/module.h" diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 94789c7280..ba8f6a55ac 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390
[PATCH v7 08/14] target/s390x: move sysemu-only code out to cpu-sysemu.c
move sysemu-only code out to cpu-sysemu.c Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck Reviewed-by: Thomas Huth --- target/s390x/cpu-sysemu.c | 309 ++ target/s390x/cpu.c| 285 +-- target/s390x/meson.build | 1 + target/s390x/s390x-internal.h | 6 + target/s390x/trace-events | 2 +- 5 files changed, 326 insertions(+), 277 deletions(-) create mode 100644 target/s390x/cpu-sysemu.c diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c new file mode 100644 index 00..16e5301084 --- /dev/null +++ b/target/s390x/cpu-sysemu.c @@ -0,0 +1,309 @@ +/* + * QEMU S/390 CPU - System Emulation-only code + * + * Copyright (c) 2009 Ulrich Hecht + * Copyright (c) 2011 Alexander Graf + * Copyright (c) 2012 SUSE LINUX Products GmbH + * Copyright (c) 2012 IBM Corp. + * + * 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 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "cpu.h" +#include "s390x-internal.h" +#include "kvm_s390x.h" +#include "sysemu/kvm.h" +#include "sysemu/reset.h" +#include "qemu/timer.h" +#include "trace.h" +#include "qapi/qapi-visit-run-state.h" +#include "sysemu/hw_accel.h" + +#include "hw/s390x/pv.h" +#include "hw/boards.h" +#include "sysemu/arch_init.h" +#include "sysemu/sysemu.h" +#include "sysemu/tcg.h" +#include "hw/core/sysemu-cpu-ops.h" + +/* S390CPUClass::load_normal() */ +static void s390_cpu_load_normal(CPUState *s) +{ +S390CPU *cpu = S390_CPU(s); +uint64_t spsw; + +if (!s390_is_pv()) { +spsw = ldq_phys(s->as, 0); +cpu->env.psw.mask = spsw & PSW_MASK_SHORT_CTRL; +/* + * Invert short psw indication, so SIE will report a specification + * exception if it was not set. + */ +cpu->env.psw.mask ^= PSW_MASK_SHORTPSW; +cpu->env.psw.addr = spsw & PSW_MASK_SHORT_ADDR; +} else { +/* + * Firmware requires us to set the load state before we set + * the cpu to operating on protected guests. + */ +s390_cpu_set_state(S390_CPU_STATE_LOAD, cpu); +} +s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); +} + +void s390_cpu_machine_reset_cb(void *opaque) +{ +S390CPU *cpu = opaque; + +run_on_cpu(CPU(cpu), s390_do_cpu_full_reset, RUN_ON_CPU_NULL); +} + +static GuestPanicInformation *s390_cpu_get_crash_info(CPUState *cs) +{ +GuestPanicInformation *panic_info; +S390CPU *cpu = S390_CPU(cs); + +cpu_synchronize_state(cs); +panic_info = g_malloc0(sizeof(GuestPanicInformation)); + +panic_info->type = GUEST_PANIC_INFORMATION_TYPE_S390; +panic_info->u.s390.core = cpu->env.core_id; +panic_info->u.s390.psw_mask = cpu->env.psw.mask; +panic_info->u.s390.psw_addr = cpu->env.psw.addr; +panic_info->u.s390.reason = cpu->env.crash_reason; + +return panic_info; +} + +static void s390_cpu_get_crash_info_qom(Object *obj, Visitor *v, +const char *name, void *opaque, +Error **errp) +{ +CPUState *cs = CPU(obj); +GuestPanicInformation *panic_info; + +if (!cs->crash_occurred) { +error_setg(errp, "No crash occurred"); +return; +} + +panic_info = s390_cpu_get_crash_info(cs); + +visit_type_GuestPanicInformation(v, "crash-information", _info, + errp); +qapi_free_GuestPanicInformation(panic_info); +} + +void s390_cpu_init_sysemu(Object *obj) +{ +CPUState *cs = CPU(obj); +S390CPU *cpu = S390_CPU(obj); + +cs->start_powered_off = true; +object_property_add(obj, "crash-information", "GuestPanicInformation", +s390_cpu_get_crash_info_qom, NULL, NULL, NULL); +cpu->env.tod_timer = +timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_tod_timer, cpu); +cpu->env.cpu_timer = +timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu); +s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); +} + +bool s390_cpu_realize_sysemu(Device
[PATCH v7 05/14] target/s390x: remove tcg-stub.c
now that we protect all calls to the tcg-specific functions with if (tcg_enabled()), we do not need the TCG stub anymore. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth --- target/s390x/meson.build | 2 +- target/s390x/tcg-stub.c | 30 -- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 target/s390x/tcg-stub.c diff --git a/target/s390x/meson.build b/target/s390x/meson.build index 1219f64112..a5e1ded93f 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -21,7 +21,7 @@ s390x_ss.add(when: 'CONFIG_TCG', if_true: files( 'vec_helper.c', 'vec_int_helper.c', 'vec_string_helper.c', -), if_false: files('tcg-stub.c')) +)) s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c')) diff --git a/target/s390x/tcg-stub.c b/target/s390x/tcg-stub.c deleted file mode 100644 index d22c898802..00 --- a/target/s390x/tcg-stub.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * QEMU TCG support -- s390x specific function stubs. - * - * Copyright (C) 2018 Red Hat Inc - * - * Authors: - * 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. - */ - -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "cpu.h" -#include "tcg_s390x.h" - -void tcg_s390_tod_updated(CPUState *cs, run_on_cpu_data opaque) -{ -} -void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, - uint32_t code, uintptr_t ra) -{ -g_assert_not_reached(); -} -void QEMU_NORETURN tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc, - uintptr_t ra) -{ -g_assert_not_reached(); -} -- 2.32.0
[PATCH v7 02/14] hw/s390x: rename tod-qemu.c to tod-tcg.c
we stop short of renaming the actual qom object though, so type remains TYPE_QEMU_S390_TOD, ie "s390-tod-qemu". Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth --- hw/s390x/meson.build | 2 +- hw/s390x/{tod-qemu.c => tod-tcg.c} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename hw/s390x/{tod-qemu.c => tod-tcg.c} (97%) diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index 327e9c93af..02e81a9467 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -16,7 +16,7 @@ s390x_ss.add(files( 'sclp.c', 'sclpcpu.c', 'sclpquiesce.c', - 'tod-qemu.c', + 'tod-tcg.c', 'tod.c', )) s390x_ss.add(when: 'CONFIG_KVM', if_true: files( diff --git a/hw/s390x/tod-qemu.c b/hw/s390x/tod-tcg.c similarity index 97% rename from hw/s390x/tod-qemu.c rename to hw/s390x/tod-tcg.c index e91b9590f5..aa44deb809 100644 --- a/hw/s390x/tod-qemu.c +++ b/hw/s390x/tod-tcg.c @@ -1,5 +1,5 @@ /* - * TOD (Time Of Day) clock - QEMU implementation + * TOD (Time Of Day) clock - TCG implementation * * Copyright 2018 Red Hat, Inc. * Author(s): David Hildenbrand -- 2.32.0
[PATCH v7 12/14] target/s390x: remove kvm-stub.c
all function calls are protected by kvm_enabled(), so we do not need the stubs. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth --- MAINTAINERS | 1 - target/s390x/kvm-stub.c | 121 --- target/s390x/meson.build | 2 +- 3 files changed, 1 insertion(+), 123 deletions(-) delete mode 100644 target/s390x/kvm-stub.c diff --git a/MAINTAINERS b/MAINTAINERS index 8ec845f4e0..4e04800576 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -396,7 +396,6 @@ M: Christian Borntraeger S: Supported F: target/s390x/kvm.c 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 diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c deleted file mode 100644 index 8a308cfebb..00 --- a/target/s390x/kvm-stub.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * QEMU KVM support -- s390x specific function stubs. - * - * Copyright (c) 2009 Ulrich Hecht - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#include "qemu/osdep.h" -#include "cpu.h" -#include "kvm_s390x.h" - -void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code) -{ -} - -int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf, -int len, bool is_write) -{ -return -ENOSYS; -} - -void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code) -{ -} - -int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state) -{ -return -ENOSYS; -} - -void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu) -{ -} - -int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu) -{ -return 0; -} - -int kvm_s390_get_hpage_1m(void) -{ -return 0; -} - -int kvm_s390_get_ri(void) -{ -return 0; -} - -int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_set_clock(uint8_t tod_high, uint64_t tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_low) -{ -return -ENOSYS; -} - -void kvm_s390_enable_css_support(S390CPU *cpu) -{ -} - -int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, -int vq, bool assign) -{ -return -ENOSYS; -} - -void kvm_s390_cmma_reset(void) -{ -} - -void kvm_s390_reset_vcpu_initial(S390CPU *cpu) -{ -} - -void kvm_s390_reset_vcpu_clear(S390CPU *cpu) -{ -} - -void kvm_s390_reset_vcpu_normal(S390CPU *cpu) -{ -} - -int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_t *hw_limit) -{ -return 0; -} - -void kvm_s390_set_max_pagesize(uint64_t pagesize, Error **errp) -{ -} - -void kvm_s390_crypto_reset(void) -{ -} - -void kvm_s390_stop_interrupt(S390CPU *cpu) -{ -} - -void kvm_s390_restart_interrupt(S390CPU *cpu) -{ -} - -void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info) -{ -} diff --git a/target/s390x/meson.build b/target/s390x/meson.build index bbcaede384..6c8e03b8fb 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -8,7 +8,7 @@ s390x_ss.add(files( 'cpu-dump.c', )) -s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c')) +s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) gen_features = executable('gen-features', 'gen-features.c', native: true, build_by_default: false) -- 2.32.0
[PATCH v7 01/14] target/s390x: meson: add target_user_arch
the lack of target_user_arch makes it hard to fully leverage the build system in order to separate user code from sysemu code. Provide it, so that we can avoid the proliferation of #ifdef in target code. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck Reviewed-by: Richard Henderson --- target/s390x/meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/s390x/meson.build b/target/s390x/meson.build index c42eadb7d2..1219f64112 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -58,5 +58,8 @@ if host_machine.cpu_family() == 's390x' and cc.has_link_argument('-Wl,--s390-pgs if_true: declare_dependency(link_args: ['-Wl,--s390-pgste'])) endif +s390x_user_ss = ss.source_set() + target_arch += {'s390x': s390x_ss} target_softmmu_arch += {'s390x': s390x_softmmu_ss} +target_user_arch += {'s390x': s390x_user_ss} -- 2.32.0
[PATCH v7 00/14] s390x cleanup
this is the next version of a cleanup series for s390x. v6 -> v7: * "hw/s390x: rename tod-qemu.c to tod-tcg.c" #2 - change the comment at the top of the file: "TCG implementation" instead of "QEMU implementation" (Thomas) * "hw/s390x: only build tod-tcg from the CONFIG_TCG build" #3 - swap the order of the patch 03 to 04 (Thomas) * "hw/s390x: tod: make explicit checks for accelerators when initializing" #4 - swap the order of the patch 04 to 03 (Thomas) * "target/s390x: rename internal.h to s390x-internal.h" - Separate from "target/s390x: start moving TCG-only code to tcg/" (Thomas) * "target/s390x: start moving TCG-only code to tcg/" #6->#7 - remove the part of rename internal.h to s390x-internal.h - remove s390_cpu_*() in s390x-internal.h to next patch (Thomas) * "target/s390x: move sysemu-only code out to cpu-sysemu.c" #7->#8 - add s390_cpu_*() to s390x-internal.h (Thomas) * "target/s390x: split cpu-dump from helper.c" #8->#9 - move s390_cpu_set_psw and s390_cpu_get_psw_mask() to cpu.c (Thomas) * "target/s390x: make helper.c sysemu-only" #9->#10 - fixed typo: s/systemu/sysemu/ * "target/s390x: move kvm files into kvm/" #12->#13 - remove the include header change in target/s390x/kvm/kvm.c (Thomas) v5 -> v6: * "target/s390x: start moving TCG-only code to tcg/" - keep the old pattern in MAINTAINERS (Cornelia) * "target/s390x: make helper.c sysemu-only" - fixed typo v4 -> v5: * "target/s390x: start moving TCG-only code to tcg/" - add change to MAINTAINERS file * "target/s390x: move sysemu-only code out to cpu-sysemu.c" - make use of SysemuCPUOps s390_sysemu_ops to handle * "target/s390x: split cpu-dump from helper.c" - add description to explain why split cpu-dump from helper.c * "target/s390x: make helper.c sysemu-only" - mention at the beginning of this file that this is sysemu only (Cornelia) * "target/s390x: remove kvm-stub.c" - add additional comment to explain the function can be removed (Thomas) * "target/s390x: move kvm files into kvm/" - add change to MAINTAINERS file * "target/s390x: split sysemu part of cpu models" - add change to MAINTAINERS file * "MAINTAINERS: update s390x directories" - removed, squash this in respectively: #6 target/s390x: start moving TCG-only code to tcg/ #12 target/s390x: move kvm files into kvm/ #13 target/s390x: split sysemu part of cpu models v3 -> v4: take s390x part from Claudio and modify for the current master * "target/s390x: meson: add target_user_arch" - new patch, add target_user_arch to avoid the proliferation of #ifdef in target code. v2 -> v3: minor changes * "hw/s390x: rename tod-qemu.c to tod-tcg.c": move to the front (David) * "hw/s390x: only build tod-qemu from the CONFIG_TCG build" - move just after, use "tod-tcg" instead * "hw/s390x: tod: make explicit checks for accelerators when initializing" - removed a line break in commit message * "target/s390x: start moving TCG-only code to tcg/" - split the rename s390x-internal.h rename part, do it before the move * "target/s390x: move kvm files into kvm/" - fix broken/missing move of trace events Cho, Yu-Chen (14): target/s390x: meson: add target_user_arch hw/s390x: rename tod-qemu.c to tod-tcg.c hw/s390x: tod: make explicit checks for accelerators when initializing hw/s390x: only build tod-tcg from the CONFIG_TCG build target/s390x: remove tcg-stub.c target/s390x: rename internal.h to s390x-internal.h target/s390x: start moving TCG-only code to tcg/ target/s390x: move sysemu-only code out to cpu-sysemu.c target/s390x: split cpu-dump from helper.c target/s390x: make helper.c sysemu-only target/s390x: use kvm_enabled() to wrap call to kvm_s390_get_hpage_1m target/s390x: remove kvm-stub.c target/s390x: move kvm files into kvm/ target/s390x: split sysemu part of cpu models MAINTAINERS | 6 +- hw/intc/s390_flic_kvm.c | 2 +- hw/s390x/meson.build | 4 +- hw/s390x/s390-stattrib-kvm.c | 2 +- hw/s390x/tod-kvm.c| 2 +- hw/s390x/{tod-qemu.c => tod-tcg.c}| 4 +- hw/s390x/tod.c| 9 +- hw/vfio/ap.c | 2 +- include/hw/s390x/tod.h| 2 +- meson.build | 1 + target/s390x/arch_dump.c | 2 +- target/s390x/cpu-dump.c | 134 ++ target/s390x/cpu-sysemu.c | 309 + target/s390x/cpu.c
[PATCH v7 07/14] target/s390x: start moving TCG-only code to tcg/
move everything related to translate, as well as HELPER code in tcg/ mmu_helper.c stays put for now, as it contains both TCG and KVM code. After the reshuffling, update MAINTAINERS accordingly. Make use of the new directory: target/s390x/tcg/ Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: David Hildenbrand Acked-by: Cornelia Huck --- MAINTAINERS| 1 + hw/s390x/tod-tcg.c | 2 +- include/hw/s390x/tod.h | 2 +- target/s390x/interrupt.c | 2 +- target/s390x/machine.c | 2 +- target/s390x/meson.build | 17 ++--- target/s390x/{ => tcg}/cc_helper.c | 0 target/s390x/{ => tcg}/crypto_helper.c | 0 target/s390x/{ => tcg}/excp_helper.c | 0 target/s390x/{ => tcg}/fpu_helper.c| 0 target/s390x/{ => tcg}/insn-data.def | 0 target/s390x/{ => tcg}/insn-format.def | 0 target/s390x/{ => tcg}/int_helper.c| 0 target/s390x/{ => tcg}/mem_helper.c| 0 target/s390x/tcg/meson.build | 14 ++ target/s390x/{ => tcg}/misc_helper.c | 0 target/s390x/{ => tcg}/s390-tod.h | 0 target/s390x/{ => tcg}/tcg_s390x.h | 0 target/s390x/{ => tcg}/translate.c | 0 target/s390x/{ => tcg}/translate_vx.c.inc | 0 target/s390x/{ => tcg}/vec.h | 0 target/s390x/{ => tcg}/vec_fpu_helper.c| 0 target/s390x/{ => tcg}/vec_helper.c| 0 target/s390x/{ => tcg}/vec_int_helper.c| 0 target/s390x/{ => tcg}/vec_string_helper.c | 0 25 files changed, 21 insertions(+), 19 deletions(-) rename target/s390x/{ => tcg}/cc_helper.c (100%) rename target/s390x/{ => tcg}/crypto_helper.c (100%) rename target/s390x/{ => tcg}/excp_helper.c (100%) rename target/s390x/{ => tcg}/fpu_helper.c (100%) rename target/s390x/{ => tcg}/insn-data.def (100%) rename target/s390x/{ => tcg}/insn-format.def (100%) rename target/s390x/{ => tcg}/int_helper.c (100%) rename target/s390x/{ => tcg}/mem_helper.c (100%) create mode 100644 target/s390x/tcg/meson.build rename target/s390x/{ => tcg}/misc_helper.c (100%) rename target/s390x/{ => tcg}/s390-tod.h (100%) rename target/s390x/{ => tcg}/tcg_s390x.h (100%) rename target/s390x/{ => tcg}/translate.c (100%) rename target/s390x/{ => tcg}/translate_vx.c.inc (100%) rename target/s390x/{ => tcg}/vec.h (100%) rename target/s390x/{ => tcg}/vec_fpu_helper.c (100%) rename target/s390x/{ => tcg}/vec_helper.c (100%) rename target/s390x/{ => tcg}/vec_int_helper.c (100%) rename target/s390x/{ => tcg}/vec_string_helper.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 684142e12e..8ec845f4e0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -297,6 +297,7 @@ M: Richard Henderson M: David Hildenbrand S: Maintained F: target/s390x/ +F: target/s390x/tcg F: hw/s390x/ F: disas/s390.c F: tests/tcg/s390x/ diff --git a/hw/s390x/tod-tcg.c b/hw/s390x/tod-tcg.c index aa44deb809..9bb94ff72b 100644 --- a/hw/s390x/tod-tcg.c +++ b/hw/s390x/tod-tcg.c @@ -16,7 +16,7 @@ #include "qemu/cutils.h" #include "qemu/module.h" #include "cpu.h" -#include "tcg_s390x.h" +#include "tcg/tcg_s390x.h" static void qemu_s390_tod_get(const S390TODState *td, S390TOD *tod, Error **errp) diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h index ff3195a4bf..0935e85089 100644 --- a/include/hw/s390x/tod.h +++ b/include/hw/s390x/tod.h @@ -12,7 +12,7 @@ #define HW_S390_TOD_H #include "hw/qdev-core.h" -#include "target/s390x/s390-tod.h" +#include "tcg/s390-tod.h" #include "qom/object.h" typedef struct S390TOD { diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index 3fde18ba46..734f0c62de 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -15,7 +15,7 @@ #include "sysemu/kvm.h" #include "sysemu/tcg.h" #include "hw/s390x/ioinst.h" -#include "tcg_s390x.h" +#include "tcg/tcg_s390x.h" #if !defined(CONFIG_USER_ONLY) #include "hw/s390x/s390_flic.h" #endif diff --git a/target/s390x/machine.c b/target/s390x/machine.c index 4f11f6ac6e..81a8a7ff99 100644 --- a/target/s390x/machine.c +++ b/target/s390x/machine.c @@ -19,7 +19,7 @@ #include "s390x-internal.h" #include "kvm_s390x.h" #include "migration/vmstate.h" -#include "tcg_s390x.h" +#include "tcg/tcg_s390x.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h" diff --git a/target/s390x/meson.build b/target/s390x/meson.build index a5e1ded93f..60d7f1b908 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -8,21 +8,6 @@ s390x_ss.add(files( 'interrupt.c'
[RFC v6 13/13] target/s390x: split sysemu part of cpu models
split sysemu part of cpu models, also create a tiny _user.c with just the (at least for now), empty implementation of apply_cpu_model. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- MAINTAINERS | 1 + target/s390x/cpu_models.c| 417 +- target/s390x/cpu_models_sysemu.c | 426 +++ target/s390x/cpu_models_user.c | 20 ++ target/s390x/meson.build | 4 + target/s390x/s390x-internal.h| 2 + 6 files changed, 454 insertions(+), 416 deletions(-) create mode 100644 target/s390x/cpu_models_sysemu.c create mode 100644 target/s390x/cpu_models_user.c diff --git a/MAINTAINERS b/MAINTAINERS index 5a482d65da..8c6d88cddc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -297,6 +297,7 @@ M: David Hildenbrand S: Maintained F: target/s390x/ F: target/s390x/tcg +F: target/s390x/cpu_models_*.[ch] F: hw/s390x/ F: disas/s390.c F: tests/tcg/s390x/ diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index ba8f6a55ac..ef82e833b5 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -18,18 +18,11 @@ #include "sysemu/tcg.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/qemu-print.h" -#include "qapi/qmp/qerror.h" -#include "qapi/qobject-input-visitor.h" -#include "qapi/qmp/qdict.h" #ifndef CONFIG_USER_ONLY -#include "sysemu/arch_init.h" #include "sysemu/sysemu.h" -#include "hw/pci/pci.h" #endif -#include "qapi/qapi-commands-machine-target.h" #include "hw/s390x/pv.h" #define CPUDEF_INIT(_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \ @@ -414,381 +407,6 @@ void s390_cpu_list(void) } } -static S390CPUModel *get_max_cpu_model(Error **errp); - -#ifndef CONFIG_USER_ONLY -static void list_add_feat(const char *name, void *opaque); - -static void check_unavailable_features(const S390CPUModel *max_model, - const S390CPUModel *model, - strList **unavailable) -{ -S390FeatBitmap missing; - -/* check general model compatibility */ -if (max_model->def->gen < model->def->gen || -(max_model->def->gen == model->def->gen && - max_model->def->ec_ga < model->def->ec_ga)) { -list_add_feat("type", unavailable); -} - -/* detect missing features if any to properly report them */ -bitmap_andnot(missing, model->features, max_model->features, - S390_FEAT_MAX); -if (!bitmap_empty(missing, S390_FEAT_MAX)) { -s390_feat_bitmap_to_ascii(missing, unavailable, list_add_feat); -} -} - -struct CpuDefinitionInfoListData { -CpuDefinitionInfoList *list; -S390CPUModel *model; -}; - -static void create_cpu_model_list(ObjectClass *klass, void *opaque) -{ -struct CpuDefinitionInfoListData *cpu_list_data = opaque; -CpuDefinitionInfoList **cpu_list = _list_data->list; -CpuDefinitionInfo *info; -char *name = g_strdup(object_class_get_name(klass)); -S390CPUClass *scc = S390_CPU_CLASS(klass); - -/* strip off the -s390x-cpu */ -g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0; -info = g_new0(CpuDefinitionInfo, 1); -info->name = name; -info->has_migration_safe = true; -info->migration_safe = scc->is_migration_safe; -info->q_static = scc->is_static; -info->q_typename = g_strdup(object_class_get_name(klass)); -/* check for unavailable features */ -if (cpu_list_data->model) { -Object *obj; -S390CPU *sc; -obj = object_new_with_class(klass); -sc = S390_CPU(obj); -if (sc->model) { -info->has_unavailable_features = true; -check_unavailable_features(cpu_list_data->model, sc->model, - >unavailable_features); -} -object_unref(obj); -} - -QAPI_LIST_PREPEND(*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ -struct CpuDefinitionInfoListData list_data = { -.list = NULL, -}; - -list_data.model = get_max_cpu_model(NULL); - -object_class_foreach(create_cpu_model_list, TYPE_S390_CPU, false, - _data); - -return list_data.list; -} - -static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, -Error **errp) -{ -Error *err = NULL; -const QDict *qdict = NULL; -const QDictEntry *e; -Visitor *visitor; -ObjectClass *oc; -S390CPU *cpu; -Object *obj; - -if (info->props) { -qdict = qobject_to(QDict, info->props); -if (!qdict) { -error_se
[RFC v6 08/13] target/s390x: split cpu-dump from helper.c
Splitting this functionality also allows us to make helper.c sysemu-only. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck --- target/s390x/cpu-dump.c | 176 +++ target/s390x/helper.c| 151 - target/s390x/meson.build | 1 + 3 files changed, 177 insertions(+), 151 deletions(-) create mode 100644 target/s390x/cpu-dump.c diff --git a/target/s390x/cpu-dump.c b/target/s390x/cpu-dump.c new file mode 100644 index 00..6f559c1913 --- /dev/null +++ b/target/s390x/cpu-dump.c @@ -0,0 +1,176 @@ +/* + * S/390 CPU dump to FILE + * + * Copyright (c) 2009 Ulrich Hecht + * Copyright (c) 2011 Alexander Graf + * + * 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 library 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. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "s390x-internal.h" +#include "qemu/qemu-print.h" +#include "sysemu/tcg.h" + +void s390_cpu_set_psw(CPUS390XState *env, uint64_t mask, uint64_t addr) +{ +#ifndef CONFIG_USER_ONLY +uint64_t old_mask = env->psw.mask; +#endif + +env->psw.addr = addr; +env->psw.mask = mask; + +/* KVM will handle all WAITs and trigger a WAIT exit on disabled_wait */ +if (!tcg_enabled()) { +return; +} +env->cc_op = (mask >> 44) & 3; + +#ifndef CONFIG_USER_ONLY +if ((old_mask ^ mask) & PSW_MASK_PER) { +s390_cpu_recompute_watchpoints(env_cpu(env)); +} + +if (mask & PSW_MASK_WAIT) { +s390_handle_wait(env_archcpu(env)); +} +#endif +} + +uint64_t s390_cpu_get_psw_mask(CPUS390XState *env) +{ +uint64_t r = env->psw.mask; + +if (tcg_enabled()) { +uint64_t cc = calc_cc(env, env->cc_op, env->cc_src, + env->cc_dst, env->cc_vr); + +assert(cc <= 3); +r &= ~PSW_MASK_CC; +r |= cc << 44; +} + +return r; +} + +void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags) +{ +S390CPU *cpu = S390_CPU(cs); +CPUS390XState *env = >env; +int i; + +qemu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64, + s390_cpu_get_psw_mask(env), env->psw.addr); +if (!tcg_enabled()) { +qemu_fprintf(f, "\n"); +} else if (env->cc_op > 3) { +qemu_fprintf(f, " cc %15s\n", cc_name(env->cc_op)); +} else { +qemu_fprintf(f, " cc %02x\n", env->cc_op); +} + +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "R%02d=%016" PRIx64, i, env->regs[i]); +if ((i % 4) == 3) { +qemu_fprintf(f, "\n"); +} else { +qemu_fprintf(f, " "); +} +} + +if (flags & CPU_DUMP_FPU) { +if (s390_has_feat(S390_FEAT_VECTOR)) { +for (i = 0; i < 32; i++) { +qemu_fprintf(f, "V%02d=%016" PRIx64 "%016" PRIx64 "%c", + i, env->vregs[i][0], env->vregs[i][1], + i % 2 ? '\n' : ' '); +} +} else { +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "F%02d=%016" PRIx64 "%c", + i, *get_freg(env, i), + (i % 4) == 3 ? '\n' : ' '); +} +} +} + +#ifndef CONFIG_USER_ONLY +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "C%02d=%016" PRIx64, i, env->cregs[i]); +if ((i % 4) == 3) { +qemu_fprintf(f, "\n"); +} else { +qemu_fprintf(f, " "); +} +} +#endif + +#ifdef DEBUG_INLINE_BRANCHES +for (i = 0; i < CC_OP_MAX; i++) { +qemu_fprintf(f, " %15s = %10ld\t%10ld\n", cc_name(i), + inline_branch_miss[i], inline_branch_hit[i]); +} +#endif + +qemu_fprintf(f, "\n"); +} + +const char *cc_name(enum cc_op cc_op) +{ +static const char * const cc_names[] = { +[CC_OP_CONST0]= "CC_OP_CONST0", +[CC_OP_CONST1]= "CC_OP_CONST1", +[CC_OP_CONST2]= "CC_OP_CONST2", +[CC_OP_CONST3]= "CC_OP_CONST3",
[RFC v6 07/13] target/s390x: move sysemu-only code out to cpu-sysemu.c
move sysemu-only code out to cpu-sysemu.c Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/cpu-sysemu.c | 309 ++ target/s390x/cpu.c| 285 ++- target/s390x/meson.build | 1 + target/s390x/trace-events | 2 +- 4 files changed, 320 insertions(+), 277 deletions(-) create mode 100644 target/s390x/cpu-sysemu.c diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c new file mode 100644 index 00..16e5301084 --- /dev/null +++ b/target/s390x/cpu-sysemu.c @@ -0,0 +1,309 @@ +/* + * QEMU S/390 CPU - System Emulation-only code + * + * Copyright (c) 2009 Ulrich Hecht + * Copyright (c) 2011 Alexander Graf + * Copyright (c) 2012 SUSE LINUX Products GmbH + * Copyright (c) 2012 IBM Corp. + * + * 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 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "cpu.h" +#include "s390x-internal.h" +#include "kvm_s390x.h" +#include "sysemu/kvm.h" +#include "sysemu/reset.h" +#include "qemu/timer.h" +#include "trace.h" +#include "qapi/qapi-visit-run-state.h" +#include "sysemu/hw_accel.h" + +#include "hw/s390x/pv.h" +#include "hw/boards.h" +#include "sysemu/arch_init.h" +#include "sysemu/sysemu.h" +#include "sysemu/tcg.h" +#include "hw/core/sysemu-cpu-ops.h" + +/* S390CPUClass::load_normal() */ +static void s390_cpu_load_normal(CPUState *s) +{ +S390CPU *cpu = S390_CPU(s); +uint64_t spsw; + +if (!s390_is_pv()) { +spsw = ldq_phys(s->as, 0); +cpu->env.psw.mask = spsw & PSW_MASK_SHORT_CTRL; +/* + * Invert short psw indication, so SIE will report a specification + * exception if it was not set. + */ +cpu->env.psw.mask ^= PSW_MASK_SHORTPSW; +cpu->env.psw.addr = spsw & PSW_MASK_SHORT_ADDR; +} else { +/* + * Firmware requires us to set the load state before we set + * the cpu to operating on protected guests. + */ +s390_cpu_set_state(S390_CPU_STATE_LOAD, cpu); +} +s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); +} + +void s390_cpu_machine_reset_cb(void *opaque) +{ +S390CPU *cpu = opaque; + +run_on_cpu(CPU(cpu), s390_do_cpu_full_reset, RUN_ON_CPU_NULL); +} + +static GuestPanicInformation *s390_cpu_get_crash_info(CPUState *cs) +{ +GuestPanicInformation *panic_info; +S390CPU *cpu = S390_CPU(cs); + +cpu_synchronize_state(cs); +panic_info = g_malloc0(sizeof(GuestPanicInformation)); + +panic_info->type = GUEST_PANIC_INFORMATION_TYPE_S390; +panic_info->u.s390.core = cpu->env.core_id; +panic_info->u.s390.psw_mask = cpu->env.psw.mask; +panic_info->u.s390.psw_addr = cpu->env.psw.addr; +panic_info->u.s390.reason = cpu->env.crash_reason; + +return panic_info; +} + +static void s390_cpu_get_crash_info_qom(Object *obj, Visitor *v, +const char *name, void *opaque, +Error **errp) +{ +CPUState *cs = CPU(obj); +GuestPanicInformation *panic_info; + +if (!cs->crash_occurred) { +error_setg(errp, "No crash occurred"); +return; +} + +panic_info = s390_cpu_get_crash_info(cs); + +visit_type_GuestPanicInformation(v, "crash-information", _info, + errp); +qapi_free_GuestPanicInformation(panic_info); +} + +void s390_cpu_init_sysemu(Object *obj) +{ +CPUState *cs = CPU(obj); +S390CPU *cpu = S390_CPU(obj); + +cs->start_powered_off = true; +object_property_add(obj, "crash-information", "GuestPanicInformation", +s390_cpu_get_crash_info_qom, NULL, NULL, NULL); +cpu->env.tod_timer = +timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_tod_timer, cpu); +cpu->env.cpu_timer = +timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu); +s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); +} + +bool s390_cpu_realize_sysemu(DeviceState *dev, Error **errp) +{ +S390CPU *cpu = S390_CPU(dev); +MachineState *ms = MACHINE(qdev_get_machine()); +
[RFC v6 06/13] target/s390x: start moving TCG-only code to tcg/
move everything related to translate, as well as HELPER code in tcg/ mmu_helper.c stays put for now, as it contains both TCG and KVM code. The internal.h file is renamed to s390x-internal.h, because of the risk of collision with other files with the same name. After the reshuffling, update MAINTAINERS accordingly. Make use of the new directory: target/s390x/tcg/ Signed-off-by: Claudio Fontana Acked-by: David Hildenbrand Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck --- MAINTAINERS | 1 + hw/s390x/tod-tcg.c| 2 +- include/hw/s390x/tod.h| 2 +- target/s390x/arch_dump.c | 2 +- target/s390x/cpu.c| 2 +- target/s390x/cpu_models.c | 2 +- target/s390x/diag.c | 2 +- target/s390x/gdbstub.c| 2 +- target/s390x/helper.c | 2 +- target/s390x/interrupt.c | 4 ++-- target/s390x/ioinst.c | 2 +- target/s390x/kvm.c| 2 +- target/s390x/machine.c| 4 ++-- target/s390x/meson.build | 17 ++--- target/s390x/mmu_helper.c | 2 +- target/s390x/{internal.h => s390x-internal.h} | 6 ++ target/s390x/sigp.c | 2 +- target/s390x/{ => tcg}/cc_helper.c| 2 +- target/s390x/{ => tcg}/crypto_helper.c| 2 +- target/s390x/{ => tcg}/excp_helper.c | 2 +- target/s390x/{ => tcg}/fpu_helper.c | 2 +- target/s390x/{ => tcg}/insn-data.def | 0 target/s390x/{ => tcg}/insn-format.def| 0 target/s390x/{ => tcg}/int_helper.c | 2 +- target/s390x/{ => tcg}/mem_helper.c | 2 +- target/s390x/tcg/meson.build | 14 ++ target/s390x/{ => tcg}/misc_helper.c | 2 +- target/s390x/{ => tcg}/s390-tod.h | 0 target/s390x/{ => tcg}/tcg_s390x.h| 0 target/s390x/{ => tcg}/translate.c| 2 +- target/s390x/{ => tcg}/translate_vx.c.inc | 0 target/s390x/{ => tcg}/vec.h | 0 target/s390x/{ => tcg}/vec_fpu_helper.c | 2 +- target/s390x/{ => tcg}/vec_helper.c | 2 +- target/s390x/{ => tcg}/vec_int_helper.c | 0 target/s390x/{ => tcg}/vec_string_helper.c| 2 +- 36 files changed, 50 insertions(+), 42 deletions(-) rename target/s390x/{internal.h => s390x-internal.h} (98%) rename target/s390x/{ => tcg}/cc_helper.c (99%) rename target/s390x/{ => tcg}/crypto_helper.c (98%) rename target/s390x/{ => tcg}/excp_helper.c (99%) rename target/s390x/{ => tcg}/fpu_helper.c (99%) rename target/s390x/{ => tcg}/insn-data.def (100%) rename target/s390x/{ => tcg}/insn-format.def (100%) rename target/s390x/{ => tcg}/int_helper.c (99%) rename target/s390x/{ => tcg}/mem_helper.c (99%) create mode 100644 target/s390x/tcg/meson.build rename target/s390x/{ => tcg}/misc_helper.c (99%) rename target/s390x/{ => tcg}/s390-tod.h (100%) rename target/s390x/{ => tcg}/tcg_s390x.h (100%) rename target/s390x/{ => tcg}/translate.c (99%) rename target/s390x/{ => tcg}/translate_vx.c.inc (100%) rename target/s390x/{ => tcg}/vec.h (100%) rename target/s390x/{ => tcg}/vec_fpu_helper.c (99%) rename target/s390x/{ => tcg}/vec_helper.c (99%) rename target/s390x/{ => tcg}/vec_int_helper.c (100%) rename target/s390x/{ => tcg}/vec_string_helper.c (99%) diff --git a/MAINTAINERS b/MAINTAINERS index cfbf7ef79b..082ed2b643 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -296,6 +296,7 @@ M: Richard Henderson M: David Hildenbrand S: Maintained F: target/s390x/ +F: target/s390x/tcg F: hw/s390x/ F: disas/s390.c F: tests/tcg/s390x/ diff --git a/hw/s390x/tod-tcg.c b/hw/s390x/tod-tcg.c index e91b9590f5..4b3e65050a 100644 --- a/hw/s390x/tod-tcg.c +++ b/hw/s390x/tod-tcg.c @@ -16,7 +16,7 @@ #include "qemu/cutils.h" #include "qemu/module.h" #include "cpu.h" -#include "tcg_s390x.h" +#include "tcg/tcg_s390x.h" static void qemu_s390_tod_get(const S390TODState *td, S390TOD *tod, Error **errp) diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h index ff3195a4bf..0935e85089 100644 --- a/include/hw/s390x/tod.h +++ b/include/hw/s390x/tod.h @@ -12,7 +12,7 @@ #define HW_S390_TOD_H #include "hw/qdev-core.h" -#include "target/s390x/s390-tod.h" +#include "tcg/s390-tod.h" #include "qom/object.h" typedef struct S390TOD { diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c index cc1330876b..08daf93ae1 100644 --- a/target/s390x/arch_dump.c +++ b/target/s390x/arch_dump.c @@ -13,7 +13,7 @@ #include "qe
[RFC v6 12/13] target/s390x: move kvm files into kvm/
move kvm files into kvm/ After the reshuffling, update MAINTAINERS accordingly. Make use of the new directory: target/s390x/kvm/ Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- MAINTAINERS| 3 +-- hw/intc/s390_flic_kvm.c| 2 +- hw/s390x/s390-stattrib-kvm.c | 2 +- hw/s390x/tod-kvm.c | 2 +- hw/vfio/ap.c | 2 +- meson.build| 1 + target/s390x/cpu-sysemu.c | 2 +- target/s390x/cpu.c | 2 +- target/s390x/cpu_models.c | 2 +- target/s390x/diag.c| 2 +- target/s390x/interrupt.c | 2 +- target/s390x/{ => kvm}/kvm.c | 2 +- target/s390x/{ => kvm}/kvm_s390x.h | 0 target/s390x/kvm/meson.build | 17 + target/s390x/kvm/trace-events | 7 +++ target/s390x/kvm/trace.h | 1 + target/s390x/machine.c | 2 +- target/s390x/meson.build | 16 +--- target/s390x/mmu_helper.c | 2 +- target/s390x/trace-events | 6 -- 20 files changed, 40 insertions(+), 35 deletions(-) rename target/s390x/{ => kvm}/kvm.c (99%) rename target/s390x/{ => kvm}/kvm_s390x.h (100%) create mode 100644 target/s390x/kvm/meson.build create mode 100644 target/s390x/kvm/trace-events create mode 100644 target/s390x/kvm/trace.h diff --git a/MAINTAINERS b/MAINTAINERS index 4e172540c0..5a482d65da 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -393,8 +393,7 @@ M: Halil Pasic M: Cornelia Huck M: Christian Borntraeger S: Supported -F: target/s390x/kvm.c -F: target/s390x/kvm_s390x.h +F: target/s390x/kvm/ F: target/s390x/ioinst.[ch] F: target/s390x/machine.c F: target/s390x/sigp.c diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 929cfa3a68..efe5054182 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -11,7 +11,7 @@ */ #include "qemu/osdep.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include #include "qemu/error-report.h" #include "qemu/module.h" diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c index f0b11a74e4..24cd01382e 100644 --- a/hw/s390x/s390-stattrib-kvm.c +++ b/hw/s390x/s390-stattrib-kvm.c @@ -16,7 +16,7 @@ #include "qemu/error-report.h" #include "sysemu/kvm.h" #include "exec/ram_addr.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" Object *kvm_s390_stattrib_create(void) { diff --git a/hw/s390x/tod-kvm.c b/hw/s390x/tod-kvm.c index 0b94477486..ec855811ae 100644 --- a/hw/s390x/tod-kvm.c +++ b/hw/s390x/tod-kvm.c @@ -13,7 +13,7 @@ #include "qemu/module.h" #include "sysemu/runstate.h" #include "hw/s390x/tod.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" static void kvm_s390_get_tod_raw(S390TOD *tod, Error **errp) { diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 4b32aca1a0..e0dd561e85 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -21,7 +21,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" #include "hw/s390x/ap-bridge.h" diff --git a/meson.build b/meson.build index a91b39465c..293d509c7e 100644 --- a/meson.build +++ b/meson.build @@ -1886,6 +1886,7 @@ if have_system or have_user 'target/ppc', 'target/riscv', 'target/s390x', +'target/s390x/kvm', 'target/sparc', ] endif diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c index 16e5301084..df2c6bf694 100644 --- a/target/s390x/cpu-sysemu.c +++ b/target/s390x/cpu-sysemu.c @@ -24,7 +24,7 @@ #include "qapi/error.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "qemu/timer.h" diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 2b2b70e1c6..9574bc9305 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -24,7 +24,7 @@ #include "qapi/error.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "qemu/module.h" diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 94789c7280..ba8f6a55ac 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #includ
[RFC v6 04/13] hw/s390x: tod: make explicit checks for accelerators when initializing
replace general "else" with specific checks for each possible accelerator. Handle qtest as a NOP, and error out for an unknown accelerator used in combination with tod. Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- hw/s390x/tod.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/s390x/tod.c b/hw/s390x/tod.c index 3c2979175e..fd5a36bf24 100644 --- a/hw/s390x/tod.c +++ b/hw/s390x/tod.c @@ -14,6 +14,8 @@ #include "qemu/error-report.h" #include "qemu/module.h" #include "sysemu/kvm.h" +#include "sysemu/tcg.h" +#include "sysemu/qtest.h" #include "migration/qemu-file-types.h" #include "migration/register.h" @@ -23,8 +25,13 @@ void s390_init_tod(void) if (kvm_enabled()) { obj = object_new(TYPE_KVM_S390_TOD); -} else { +} else if (tcg_enabled()) { obj = object_new(TYPE_QEMU_S390_TOD); +} else if (qtest_enabled()) { +return; +} else { +error_report("current accelerator not handled in s390_init_tod!"); +abort(); } object_property_add_child(qdev_get_machine(), TYPE_S390_TOD, obj); object_unref(obj); -- 2.32.0
[RFC v6 10/13] target/s390x: use kvm_enabled() to wrap call to kvm_s390_get_hpage_1m
this will allow to remove the kvm stubs. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/diag.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/s390x/diag.c b/target/s390x/diag.c index c17a2498a7..8405f69df0 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -20,6 +20,7 @@ #include "hw/s390x/ipl.h" #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/pv.h" +#include "sysemu/kvm.h" #include "kvm_s390x.h" int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3) @@ -168,7 +169,7 @@ out: return; } -if (kvm_s390_get_hpage_1m()) { +if (kvm_enabled() && kvm_s390_get_hpage_1m()) { error_report("Protected VMs can currently not be backed with " "huge pages"); env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV; -- 2.32.0
[RFC v6 11/13] target/s390x: remove kvm-stub.c
all function calls are protected by kvm_enabled(), so we do not need the stubs. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- MAINTAINERS | 1 - target/s390x/kvm-stub.c | 121 --- target/s390x/meson.build | 2 +- 3 files changed, 1 insertion(+), 123 deletions(-) delete mode 100644 target/s390x/kvm-stub.c diff --git a/MAINTAINERS b/MAINTAINERS index 082ed2b643..4e172540c0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -395,7 +395,6 @@ M: Christian Borntraeger S: Supported F: target/s390x/kvm.c 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 diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c deleted file mode 100644 index 8a308cfebb..00 --- a/target/s390x/kvm-stub.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * QEMU KVM support -- s390x specific function stubs. - * - * Copyright (c) 2009 Ulrich Hecht - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#include "qemu/osdep.h" -#include "cpu.h" -#include "kvm_s390x.h" - -void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code) -{ -} - -int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf, -int len, bool is_write) -{ -return -ENOSYS; -} - -void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code) -{ -} - -int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state) -{ -return -ENOSYS; -} - -void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu) -{ -} - -int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu) -{ -return 0; -} - -int kvm_s390_get_hpage_1m(void) -{ -return 0; -} - -int kvm_s390_get_ri(void) -{ -return 0; -} - -int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_set_clock(uint8_t tod_high, uint64_t tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_low) -{ -return -ENOSYS; -} - -void kvm_s390_enable_css_support(S390CPU *cpu) -{ -} - -int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, -int vq, bool assign) -{ -return -ENOSYS; -} - -void kvm_s390_cmma_reset(void) -{ -} - -void kvm_s390_reset_vcpu_initial(S390CPU *cpu) -{ -} - -void kvm_s390_reset_vcpu_clear(S390CPU *cpu) -{ -} - -void kvm_s390_reset_vcpu_normal(S390CPU *cpu) -{ -} - -int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_t *hw_limit) -{ -return 0; -} - -void kvm_s390_set_max_pagesize(uint64_t pagesize, Error **errp) -{ -} - -void kvm_s390_crypto_reset(void) -{ -} - -void kvm_s390_stop_interrupt(S390CPU *cpu) -{ -} - -void kvm_s390_restart_interrupt(S390CPU *cpu) -{ -} - -void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info) -{ -} diff --git a/target/s390x/meson.build b/target/s390x/meson.build index bbcaede384..6c8e03b8fb 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -8,7 +8,7 @@ s390x_ss.add(files( 'cpu-dump.c', )) -s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c')) +s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) gen_features = executable('gen-features', 'gen-features.c', native: true, build_by_default: false) -- 2.32.0
[RFC v6 03/13] hw/s390x: only build tod-tcg from the CONFIG_TCG build
this will allow in later patches to remove unneeded stubs in target/s390x. Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- hw/s390x/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index 02e81a9467..28484256ec 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -16,7 +16,6 @@ s390x_ss.add(files( 'sclp.c', 'sclpcpu.c', 'sclpquiesce.c', - 'tod-tcg.c', 'tod.c', )) s390x_ss.add(when: 'CONFIG_KVM', if_true: files( @@ -25,6 +24,9 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files( 's390-stattrib-kvm.c', 'pv.c', )) +s390x_ss.add(when: 'CONFIG_TCG', if_true: files( + 'tod-tcg.c', +)) s390x_ss.add(when: 'CONFIG_S390_CCW_VIRTIO', if_true: files('s390-virtio-ccw.c')) s390x_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('3270-ccw.c')) s390x_ss.add(when: 'CONFIG_VFIO', if_true: files('s390-pci-vfio.c')) -- 2.32.0
[RFC v6 05/13] target/s390x: remove tcg-stub.c
now that we protect all calls to the tcg-specific functions with if (tcg_enabled()), we do not need the TCG stub anymore. Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- target/s390x/meson.build | 2 +- target/s390x/tcg-stub.c | 30 -- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 target/s390x/tcg-stub.c diff --git a/target/s390x/meson.build b/target/s390x/meson.build index 1219f64112..a5e1ded93f 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -21,7 +21,7 @@ s390x_ss.add(when: 'CONFIG_TCG', if_true: files( 'vec_helper.c', 'vec_int_helper.c', 'vec_string_helper.c', -), if_false: files('tcg-stub.c')) +)) s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c')) diff --git a/target/s390x/tcg-stub.c b/target/s390x/tcg-stub.c deleted file mode 100644 index d22c898802..00 --- a/target/s390x/tcg-stub.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * QEMU TCG support -- s390x specific function stubs. - * - * Copyright (C) 2018 Red Hat Inc - * - * Authors: - * 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. - */ - -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "cpu.h" -#include "tcg_s390x.h" - -void tcg_s390_tod_updated(CPUState *cs, run_on_cpu_data opaque) -{ -} -void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, - uint32_t code, uintptr_t ra) -{ -g_assert_not_reached(); -} -void QEMU_NORETURN tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc, - uintptr_t ra) -{ -g_assert_not_reached(); -} -- 2.32.0
[RFC v6 09/13] target/s390x: make helper.c sysemu-only
Now that we have moved cpu-dump functionality out of helper.c, we can make the module sysemu-only. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck --- target/s390x/helper.c| 9 + target/s390x/meson.build | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index c72e990f4d..a4d4665f67 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -1,5 +1,5 @@ /* - * S/390 helpers + * S/390 helpers - systemu only * * Copyright (c) 2009 Ulrich Hecht * Copyright (c) 2011 Alexander Graf @@ -27,11 +27,8 @@ #include "hw/s390x/pv.h" #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" -#ifndef CONFIG_USER_ONLY #include "sysemu/tcg.h" -#endif -#ifndef CONFIG_USER_ONLY void s390x_tod_timer(void *opaque) { cpu_inject_clock_comparator((S390CPU *) opaque); @@ -284,7 +281,3 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) cpu_physical_memory_unmap(sa, len, 1, len); return 0; } -#else -/* For user-only, tcg is always enabled. */ -#define tcg_enabled() true -#endif /* CONFIG_USER_ONLY */ diff --git a/target/s390x/meson.build b/target/s390x/meson.build index 6e1aa3b0cd..bbcaede384 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -4,7 +4,6 @@ s390x_ss.add(files( 'cpu_features.c', 'cpu_models.c', 'gdbstub.c', - 'helper.c', 'interrupt.c', 'cpu-dump.c', )) @@ -23,6 +22,7 @@ s390x_ss.add(gen_features_h) s390x_softmmu_ss = ss.source_set() s390x_softmmu_ss.add(files( + 'helper.c', 'arch_dump.c', 'diag.c', 'ioinst.c', -- 2.32.0
[RFC v6 01/13] target/s390x: meson: add target_user_arch
the lack of target_user_arch makes it hard to fully leverage the build system in order to separate user code from sysemu code. Provide it, so that we can avoid the proliferation of #ifdef in target code. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck --- target/s390x/meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/s390x/meson.build b/target/s390x/meson.build index c42eadb7d2..1219f64112 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -58,5 +58,8 @@ if host_machine.cpu_family() == 's390x' and cc.has_link_argument('-Wl,--s390-pgs if_true: declare_dependency(link_args: ['-Wl,--s390-pgste'])) endif +s390x_user_ss = ss.source_set() + target_arch += {'s390x': s390x_ss} target_softmmu_arch += {'s390x': s390x_softmmu_ss} +target_user_arch += {'s390x': s390x_user_ss} -- 2.32.0
[RFC v6 02/13] hw/s390x: rename tod-qemu.c to tod-tcg.c
we stop short of renaming the actual qom object though, so type remains TYPE_QEMU_S390_TOD, ie "s390-tod-qemu". Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- hw/s390x/meson.build | 2 +- hw/s390x/{tod-qemu.c => tod-tcg.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename hw/s390x/{tod-qemu.c => tod-tcg.c} (100%) diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index 327e9c93af..02e81a9467 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -16,7 +16,7 @@ s390x_ss.add(files( 'sclp.c', 'sclpcpu.c', 'sclpquiesce.c', - 'tod-qemu.c', + 'tod-tcg.c', 'tod.c', )) s390x_ss.add(when: 'CONFIG_KVM', if_true: files( diff --git a/hw/s390x/tod-qemu.c b/hw/s390x/tod-tcg.c similarity index 100% rename from hw/s390x/tod-qemu.c rename to hw/s390x/tod-tcg.c -- 2.32.0
[RFC v6 00/13] s390x cleanup
this is the next version of a cleanup series for s390x. v5 -> v6: * target/s390x: start moving TCG-only code to tcg/ - keep the old pattern in MAINTAINERS (Cornelia) * target/s390x: make helper.c sysemu-only - fixed typo v4 -> v5: * "target/s390x: start moving TCG-only code to tcg/" - add change to MAINTAINERS file * "target/s390x: move sysemu-only code out to cpu-sysemu.c" - make use of SysemuCPUOps s390_sysemu_ops to handle * "target/s390x: split cpu-dump from helper.c" - add description to explain why split cpu-dump from helper.c * "target/s390x: make helper.c sysemu-only" - mention at the beginning of this file that this is sysemu only (Cornelia) * "target/s390x: remove kvm-stub.c" - add additional comment to explain the function can be removed (Thomas) * "target/s390x: move kvm files into kvm/" - add change to MAINTAINERS file * "target/s390x: split sysemu part of cpu models" - add change to MAINTAINERS file * "MAINTAINERS: update s390x directories" - removed, squash this in respectively: #6 target/s390x: start moving TCG-only code to tcg/ #12 target/s390x: move kvm files into kvm/ #13 target/s390x: split sysemu part of cpu models v3 -> v4: take s390x part from Claudio and modify for the current master * "target/s390x: meson: add target_user_arch" - new patch, add target_user_arch to avoid the proliferation of #ifdef in target code. v2 -> v3: minor changes * "hw/s390x: rename tod-qemu.c to tod-tcg.c": move to the front (David) * "hw/s390x: only build tod-qemu from the CONFIG_TCG build" - move just after, use "tod-tcg" instead * "hw/s390x: tod: make explicit checks for accelerators when initializing" - removed a line break in commit message * "target/s390x: start moving TCG-only code to tcg/" - split the rename s390x-internal.h rename part, do it before the move * "target/s390x: move kvm files into kvm/" - fix broken/missing move of trace events Cho, Yu-Chen (13): target/s390x: meson: add target_user_arch hw/s390x: rename tod-qemu.c to tod-tcg.c hw/s390x: only build tod-tcg from the CONFIG_TCG build hw/s390x: tod: make explicit checks for accelerators when initializing target/s390x: remove tcg-stub.c target/s390x: start moving TCG-only code to tcg/ target/s390x: move sysemu-only code out to cpu-sysemu.c target/s390x: split cpu-dump from helper.c target/s390x: make helper.c sysemu-only target/s390x: use kvm_enabled() to wrap call to kvm_s390_get_hpage_1m target/s390x: remove kvm-stub.c target/s390x: move kvm files into kvm/ target/s390x: split sysemu part of cpu models MAINTAINERS | 6 +- hw/intc/s390_flic_kvm.c | 2 +- hw/s390x/meson.build | 4 +- hw/s390x/s390-stattrib-kvm.c | 2 +- hw/s390x/tod-kvm.c| 2 +- hw/s390x/{tod-qemu.c => tod-tcg.c}| 2 +- hw/s390x/tod.c| 9 +- hw/vfio/ap.c | 2 +- include/hw/s390x/tod.h| 2 +- meson.build | 1 + target/s390x/arch_dump.c | 2 +- target/s390x/cpu-dump.c | 176 target/s390x/cpu-sysemu.c | 309 + target/s390x/cpu.c| 289 +--- target/s390x/cpu_models.c | 421 + target/s390x/cpu_models_sysemu.c | 426 ++ target/s390x/cpu_models_user.c| 20 + target/s390x/diag.c | 7 +- target/s390x/gdbstub.c| 2 +- target/s390x/helper.c | 162 +-- target/s390x/interrupt.c | 6 +- target/s390x/ioinst.c | 2 +- target/s390x/kvm-stub.c | 121 - target/s390x/{ => kvm}/kvm.c | 4 +- target/s390x/{ => kvm}/kvm_s390x.h| 0 target/s390x/kvm/meson.build | 17 + target/s390x/kvm/trace-events | 7 + target/s390x/kvm/trace.h | 1 + target/s390x/machine.c| 6 +- target/s390x/meson.build | 42 +- target/s390x/mmu_helper.c | 4 +- target/s390x/{internal.h => s390x-internal.h} | 8 + target/s390x/sigp.c | 2 +- target/s390x/tcg-stub.c | 30 -- target/s390x/{ => tcg}/cc_helper.c| 2 +- target/s390x/{ => tcg}/crypto_helper.c| 2 +- target/s390x/{ => tcg}/excp_helper.c | 2 +- target/s390x/{ => tcg}/fpu_helper.c | 2 +
[RFC v5 13/13] target/s390x: split sysemu part of cpu models
split sysemu part of cpu models, also create a tiny _user.c with just the (at least for now), empty implementation of apply_cpu_model. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- MAINTAINERS | 1 + target/s390x/cpu_models.c| 417 +- target/s390x/cpu_models_sysemu.c | 426 +++ target/s390x/cpu_models_user.c | 20 ++ target/s390x/meson.build | 4 + target/s390x/s390x-internal.h| 2 + 6 files changed, 454 insertions(+), 416 deletions(-) create mode 100644 target/s390x/cpu_models_sysemu.c create mode 100644 target/s390x/cpu_models_user.c diff --git a/MAINTAINERS b/MAINTAINERS index 014d4365f5..0b446a471d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -295,6 +295,7 @@ M: Richard Henderson M: David Hildenbrand S: Maintained F: target/s390x/tcg +F: target/s390x/cpu_models_*.[ch] F: hw/s390x/ F: disas/s390.c F: tests/tcg/s390x/ diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 0ed1c23774..30a192590d 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -18,18 +18,11 @@ #include "sysemu/tcg.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/qemu-print.h" -#include "qapi/qmp/qerror.h" -#include "qapi/qobject-input-visitor.h" -#include "qapi/qmp/qdict.h" #ifndef CONFIG_USER_ONLY -#include "sysemu/arch_init.h" #include "sysemu/sysemu.h" -#include "hw/pci/pci.h" #endif -#include "qapi/qapi-commands-machine-target.h" #include "hw/s390x/pv.h" #define CPUDEF_INIT(_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \ @@ -414,381 +407,6 @@ void s390_cpu_list(void) } } -static S390CPUModel *get_max_cpu_model(Error **errp); - -#ifndef CONFIG_USER_ONLY -static void list_add_feat(const char *name, void *opaque); - -static void check_unavailable_features(const S390CPUModel *max_model, - const S390CPUModel *model, - strList **unavailable) -{ -S390FeatBitmap missing; - -/* check general model compatibility */ -if (max_model->def->gen < model->def->gen || -(max_model->def->gen == model->def->gen && - max_model->def->ec_ga < model->def->ec_ga)) { -list_add_feat("type", unavailable); -} - -/* detect missing features if any to properly report them */ -bitmap_andnot(missing, model->features, max_model->features, - S390_FEAT_MAX); -if (!bitmap_empty(missing, S390_FEAT_MAX)) { -s390_feat_bitmap_to_ascii(missing, unavailable, list_add_feat); -} -} - -struct CpuDefinitionInfoListData { -CpuDefinitionInfoList *list; -S390CPUModel *model; -}; - -static void create_cpu_model_list(ObjectClass *klass, void *opaque) -{ -struct CpuDefinitionInfoListData *cpu_list_data = opaque; -CpuDefinitionInfoList **cpu_list = _list_data->list; -CpuDefinitionInfo *info; -char *name = g_strdup(object_class_get_name(klass)); -S390CPUClass *scc = S390_CPU_CLASS(klass); - -/* strip off the -s390x-cpu */ -g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0; -info = g_new0(CpuDefinitionInfo, 1); -info->name = name; -info->has_migration_safe = true; -info->migration_safe = scc->is_migration_safe; -info->q_static = scc->is_static; -info->q_typename = g_strdup(object_class_get_name(klass)); -/* check for unavailable features */ -if (cpu_list_data->model) { -Object *obj; -S390CPU *sc; -obj = object_new_with_class(klass); -sc = S390_CPU(obj); -if (sc->model) { -info->has_unavailable_features = true; -check_unavailable_features(cpu_list_data->model, sc->model, - >unavailable_features); -} -object_unref(obj); -} - -QAPI_LIST_PREPEND(*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ -struct CpuDefinitionInfoListData list_data = { -.list = NULL, -}; - -list_data.model = get_max_cpu_model(NULL); - -object_class_foreach(create_cpu_model_list, TYPE_S390_CPU, false, - _data); - -return list_data.list; -} - -static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, -Error **errp) -{ -Error *err = NULL; -const QDict *qdict = NULL; -const QDictEntry *e; -Visitor *visitor; -ObjectClass *oc; -S390CPU *cpu; -Object *obj; - -if (info->props) { -qdict = qobject_to(QDict, info->props); -if (!qdict) { -error_se
[RFC v5 12/13] target/s390x: move kvm files into kvm/
move kvm files into kvm/ After the reshuffling, update MAINTAINERS accordingly. Make use of the new directory: target/s390x/kvm/ Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- MAINTAINERS| 3 +-- hw/intc/s390_flic_kvm.c| 2 +- hw/s390x/s390-stattrib-kvm.c | 2 +- hw/s390x/tod-kvm.c | 2 +- hw/vfio/ap.c | 2 +- meson.build| 1 + target/s390x/cpu-sysemu.c | 2 +- target/s390x/cpu.c | 2 +- target/s390x/cpu_models.c | 2 +- target/s390x/diag.c| 2 +- target/s390x/interrupt.c | 2 +- target/s390x/{ => kvm}/kvm.c | 2 +- target/s390x/{ => kvm}/kvm_s390x.h | 0 target/s390x/kvm/meson.build | 17 + target/s390x/kvm/trace-events | 7 +++ target/s390x/kvm/trace.h | 1 + target/s390x/machine.c | 2 +- target/s390x/meson.build | 16 +--- target/s390x/mmu_helper.c | 2 +- target/s390x/trace-events | 6 -- 20 files changed, 40 insertions(+), 35 deletions(-) rename target/s390x/{ => kvm}/kvm.c (99%) rename target/s390x/{ => kvm}/kvm_s390x.h (100%) create mode 100644 target/s390x/kvm/meson.build create mode 100644 target/s390x/kvm/trace-events create mode 100644 target/s390x/kvm/trace.h diff --git a/MAINTAINERS b/MAINTAINERS index bf9bc0513a..014d4365f5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -391,8 +391,7 @@ M: Halil Pasic M: Cornelia Huck M: Christian Borntraeger S: Supported -F: target/s390x/kvm.c -F: target/s390x/kvm_s390x.h +F: target/s390x/kvm/ F: target/s390x/ioinst.[ch] F: target/s390x/machine.c F: target/s390x/sigp.c diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 929cfa3a68..efe5054182 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -11,7 +11,7 @@ */ #include "qemu/osdep.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include #include "qemu/error-report.h" #include "qemu/module.h" diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c index f0b11a74e4..24cd01382e 100644 --- a/hw/s390x/s390-stattrib-kvm.c +++ b/hw/s390x/s390-stattrib-kvm.c @@ -16,7 +16,7 @@ #include "qemu/error-report.h" #include "sysemu/kvm.h" #include "exec/ram_addr.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" Object *kvm_s390_stattrib_create(void) { diff --git a/hw/s390x/tod-kvm.c b/hw/s390x/tod-kvm.c index 0b94477486..ec855811ae 100644 --- a/hw/s390x/tod-kvm.c +++ b/hw/s390x/tod-kvm.c @@ -13,7 +13,7 @@ #include "qemu/module.h" #include "sysemu/runstate.h" #include "hw/s390x/tod.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" static void kvm_s390_get_tod_raw(S390TOD *tod, Error **errp) { diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 4b32aca1a0..e0dd561e85 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -21,7 +21,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" #include "hw/s390x/ap-bridge.h" diff --git a/meson.build b/meson.build index d8a92666fb..4c05153fe9 100644 --- a/meson.build +++ b/meson.build @@ -1886,6 +1886,7 @@ if have_system or have_user 'target/ppc', 'target/riscv', 'target/s390x', +'target/s390x/kvm', 'target/sparc', ] endif diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c index 16e5301084..df2c6bf694 100644 --- a/target/s390x/cpu-sysemu.c +++ b/target/s390x/cpu-sysemu.c @@ -24,7 +24,7 @@ #include "qapi/error.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "qemu/timer.h" diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 2b2b70e1c6..9574bc9305 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -24,7 +24,7 @@ #include "qapi/error.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "qemu/module.h" diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 4ff8cba7e5..0ed1c23774 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #includ
[RFC v5 10/13] target/s390x: use kvm_enabled() to wrap call to kvm_s390_get_hpage_1m
this will allow to remove the kvm stubs. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/diag.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/s390x/diag.c b/target/s390x/diag.c index c17a2498a7..8405f69df0 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -20,6 +20,7 @@ #include "hw/s390x/ipl.h" #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/pv.h" +#include "sysemu/kvm.h" #include "kvm_s390x.h" int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3) @@ -168,7 +169,7 @@ out: return; } -if (kvm_s390_get_hpage_1m()) { +if (kvm_enabled() && kvm_s390_get_hpage_1m()) { error_report("Protected VMs can currently not be backed with " "huge pages"); env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV; -- 2.32.0
[RFC v5 09/13] target/s390x: make helper.c sysemu-only
Now that we have moved cpu-dump functionality out of helper.c, we can make the module sysemu-only. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck --- target/s390x/helper.c| 6 +- target/s390x/meson.build | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 41ccc83d11..b9d18325bc 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -1,5 +1,5 @@ /* - * S/390 helpers + * S/390 helpers - systemu only * * Copyright (c) 2009 Ulrich Hecht * Copyright (c) 2011 Alexander Graf @@ -27,11 +27,8 @@ #include "hw/s390x/pv.h" #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" -#ifndef CONFIG_USER_ONLY #include "sysemu/tcg.h" -#endif -#ifndef CONFIG_USER_ONLY void s390x_tod_timer(void *opaque) { cpu_inject_clock_comparator((S390CPU *) opaque); @@ -322,4 +319,3 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) cpu_physical_memory_unmap(sa, len, 1, len); return 0; } -#endif /* CONFIG_USER_ONLY */ diff --git a/target/s390x/meson.build b/target/s390x/meson.build index 6e1aa3b0cd..bbcaede384 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -4,7 +4,6 @@ s390x_ss.add(files( 'cpu_features.c', 'cpu_models.c', 'gdbstub.c', - 'helper.c', 'interrupt.c', 'cpu-dump.c', )) @@ -23,6 +22,7 @@ s390x_ss.add(gen_features_h) s390x_softmmu_ss = ss.source_set() s390x_softmmu_ss.add(files( + 'helper.c', 'arch_dump.c', 'diag.c', 'ioinst.c', -- 2.32.0
[RFC v5 08/13] target/s390x: split cpu-dump from helper.c
Splitting this functionality also allows us to make helper.c sysemu-only. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck --- target/s390x/cpu-dump.c | 131 +++ target/s390x/helper.c| 107 target/s390x/meson.build | 1 + 3 files changed, 132 insertions(+), 107 deletions(-) create mode 100644 target/s390x/cpu-dump.c diff --git a/target/s390x/cpu-dump.c b/target/s390x/cpu-dump.c new file mode 100644 index 00..4170dec01a --- /dev/null +++ b/target/s390x/cpu-dump.c @@ -0,0 +1,131 @@ +/* + * S/390 CPU dump to FILE + * + * Copyright (c) 2009 Ulrich Hecht + * Copyright (c) 2011 Alexander Graf + * + * 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 library 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. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "s390x-internal.h" +#include "qemu/qemu-print.h" + +void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags) +{ +S390CPU *cpu = S390_CPU(cs); +CPUS390XState *env = >env; +int i; + +if (env->cc_op > 3) { +qemu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64 " cc %15s\n", + env->psw.mask, env->psw.addr, cc_name(env->cc_op)); +} else { +qemu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64 " cc %02x\n", + env->psw.mask, env->psw.addr, env->cc_op); +} + +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "R%02d=%016" PRIx64, i, env->regs[i]); +if ((i % 4) == 3) { +qemu_fprintf(f, "\n"); +} else { +qemu_fprintf(f, " "); +} +} + +if (flags & CPU_DUMP_FPU) { +if (s390_has_feat(S390_FEAT_VECTOR)) { +for (i = 0; i < 32; i++) { +qemu_fprintf(f, "V%02d=%016" PRIx64 "%016" PRIx64 "%c", + i, env->vregs[i][0], env->vregs[i][1], + i % 2 ? '\n' : ' '); +} +} else { +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "F%02d=%016" PRIx64 "%c", + i, *get_freg(env, i), + (i % 4) == 3 ? '\n' : ' '); +} +} +} + +#ifndef CONFIG_USER_ONLY +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "C%02d=%016" PRIx64, i, env->cregs[i]); +if ((i % 4) == 3) { +qemu_fprintf(f, "\n"); +} else { +qemu_fprintf(f, " "); +} +} +#endif + +#ifdef DEBUG_INLINE_BRANCHES +for (i = 0; i < CC_OP_MAX; i++) { +qemu_fprintf(f, " %15s = %10ld\t%10ld\n", cc_name(i), + inline_branch_miss[i], inline_branch_hit[i]); +} +#endif + +qemu_fprintf(f, "\n"); +} + +const char *cc_name(enum cc_op cc_op) +{ +static const char * const cc_names[] = { +[CC_OP_CONST0]= "CC_OP_CONST0", +[CC_OP_CONST1]= "CC_OP_CONST1", +[CC_OP_CONST2]= "CC_OP_CONST2", +[CC_OP_CONST3]= "CC_OP_CONST3", +[CC_OP_DYNAMIC] = "CC_OP_DYNAMIC", +[CC_OP_STATIC]= "CC_OP_STATIC", +[CC_OP_NZ]= "CC_OP_NZ", +[CC_OP_ADDU] = "CC_OP_ADDU", +[CC_OP_SUBU] = "CC_OP_SUBU", +[CC_OP_LTGT_32] = "CC_OP_LTGT_32", +[CC_OP_LTGT_64] = "CC_OP_LTGT_64", +[CC_OP_LTUGTU_32] = "CC_OP_LTUGTU_32", +[CC_OP_LTUGTU_64] = "CC_OP_LTUGTU_64", +[CC_OP_LTGT0_32] = "CC_OP_LTGT0_32", +[CC_OP_LTGT0_64] = "CC_OP_LTGT0_64", +[CC_OP_ADD_64]= "CC_OP_ADD_64", +[CC_OP_SUB_64]= "CC_OP_SUB_64", +[CC_OP_ABS_64]= "CC_OP_ABS_64", +[CC_OP_NABS_64] = "CC_OP_NABS_64", +[CC_OP_ADD_32]= "CC_OP_ADD_32", +[CC_OP_SUB_32]= "CC_OP_SUB_32", +[CC_OP_ABS_32]= "CC_OP_ABS_32", +[CC_OP_NABS_
[RFC v5 11/13] target/s390x: remove kvm-stub.c
all function calls are protected by kvm_enabled(), so we do not need the stubs. For kvm_s390_get_gs(), the last user has likely been removed with 0280b3eb7c ("s390x/kvm: use cpu model for gscb on compat machines"). Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- MAINTAINERS | 1 - target/s390x/kvm-stub.c | 126 --- target/s390x/meson.build | 2 +- 3 files changed, 1 insertion(+), 128 deletions(-) delete mode 100644 target/s390x/kvm-stub.c diff --git a/MAINTAINERS b/MAINTAINERS index d05dcc22e0..bf9bc0513a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -393,7 +393,6 @@ M: Christian Borntraeger S: Supported F: target/s390x/kvm.c 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 diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c deleted file mode 100644 index 9970b5a8c7..00 --- a/target/s390x/kvm-stub.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * QEMU KVM support -- s390x specific function stubs. - * - * Copyright (c) 2009 Ulrich Hecht - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#include "qemu/osdep.h" -#include "cpu.h" -#include "kvm_s390x.h" - -void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code) -{ -} - -int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf, -int len, bool is_write) -{ -return -ENOSYS; -} - -void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code) -{ -} - -int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state) -{ -return -ENOSYS; -} - -void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu) -{ -} - -int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu) -{ -return 0; -} - -int kvm_s390_get_hpage_1m(void) -{ -return 0; -} - -int kvm_s390_get_ri(void) -{ -return 0; -} - -int kvm_s390_get_gs(void) -{ -return 0; -} - -int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_set_clock(uint8_t tod_high, uint64_t tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_low) -{ -return -ENOSYS; -} - -void kvm_s390_enable_css_support(S390CPU *cpu) -{ -} - -int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, -int vq, bool assign) -{ -return -ENOSYS; -} - -void kvm_s390_cmma_reset(void) -{ -} - -void kvm_s390_reset_vcpu_initial(S390CPU *cpu) -{ -} - -void kvm_s390_reset_vcpu_clear(S390CPU *cpu) -{ -} - -void kvm_s390_reset_vcpu_normal(S390CPU *cpu) -{ -} - -int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_t *hw_limit) -{ -return 0; -} - -void kvm_s390_set_max_pagesize(uint64_t pagesize, Error **errp) -{ -} - -void kvm_s390_crypto_reset(void) -{ -} - -void kvm_s390_stop_interrupt(S390CPU *cpu) -{ -} - -void kvm_s390_restart_interrupt(S390CPU *cpu) -{ -} - -void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info) -{ -} diff --git a/target/s390x/meson.build b/target/s390x/meson.build index bbcaede384..6c8e03b8fb 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -8,7 +8,7 @@ s390x_ss.add(files( 'cpu-dump.c', )) -s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c')) +s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) gen_features = executable('gen-features', 'gen-features.c', native: true, build_by_default: false) -- 2.32.0
[RFC v5 07/13] target/s390x: move sysemu-only code out to cpu-sysemu.c
move sysemu-only code out to cpu-sysemu.c Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/cpu-sysemu.c | 309 ++ target/s390x/cpu.c| 285 ++- target/s390x/meson.build | 1 + target/s390x/trace-events | 2 +- 4 files changed, 320 insertions(+), 277 deletions(-) create mode 100644 target/s390x/cpu-sysemu.c diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c new file mode 100644 index 00..16e5301084 --- /dev/null +++ b/target/s390x/cpu-sysemu.c @@ -0,0 +1,309 @@ +/* + * QEMU S/390 CPU - System Emulation-only code + * + * Copyright (c) 2009 Ulrich Hecht + * Copyright (c) 2011 Alexander Graf + * Copyright (c) 2012 SUSE LINUX Products GmbH + * Copyright (c) 2012 IBM Corp. + * + * 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 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "cpu.h" +#include "s390x-internal.h" +#include "kvm_s390x.h" +#include "sysemu/kvm.h" +#include "sysemu/reset.h" +#include "qemu/timer.h" +#include "trace.h" +#include "qapi/qapi-visit-run-state.h" +#include "sysemu/hw_accel.h" + +#include "hw/s390x/pv.h" +#include "hw/boards.h" +#include "sysemu/arch_init.h" +#include "sysemu/sysemu.h" +#include "sysemu/tcg.h" +#include "hw/core/sysemu-cpu-ops.h" + +/* S390CPUClass::load_normal() */ +static void s390_cpu_load_normal(CPUState *s) +{ +S390CPU *cpu = S390_CPU(s); +uint64_t spsw; + +if (!s390_is_pv()) { +spsw = ldq_phys(s->as, 0); +cpu->env.psw.mask = spsw & PSW_MASK_SHORT_CTRL; +/* + * Invert short psw indication, so SIE will report a specification + * exception if it was not set. + */ +cpu->env.psw.mask ^= PSW_MASK_SHORTPSW; +cpu->env.psw.addr = spsw & PSW_MASK_SHORT_ADDR; +} else { +/* + * Firmware requires us to set the load state before we set + * the cpu to operating on protected guests. + */ +s390_cpu_set_state(S390_CPU_STATE_LOAD, cpu); +} +s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); +} + +void s390_cpu_machine_reset_cb(void *opaque) +{ +S390CPU *cpu = opaque; + +run_on_cpu(CPU(cpu), s390_do_cpu_full_reset, RUN_ON_CPU_NULL); +} + +static GuestPanicInformation *s390_cpu_get_crash_info(CPUState *cs) +{ +GuestPanicInformation *panic_info; +S390CPU *cpu = S390_CPU(cs); + +cpu_synchronize_state(cs); +panic_info = g_malloc0(sizeof(GuestPanicInformation)); + +panic_info->type = GUEST_PANIC_INFORMATION_TYPE_S390; +panic_info->u.s390.core = cpu->env.core_id; +panic_info->u.s390.psw_mask = cpu->env.psw.mask; +panic_info->u.s390.psw_addr = cpu->env.psw.addr; +panic_info->u.s390.reason = cpu->env.crash_reason; + +return panic_info; +} + +static void s390_cpu_get_crash_info_qom(Object *obj, Visitor *v, +const char *name, void *opaque, +Error **errp) +{ +CPUState *cs = CPU(obj); +GuestPanicInformation *panic_info; + +if (!cs->crash_occurred) { +error_setg(errp, "No crash occurred"); +return; +} + +panic_info = s390_cpu_get_crash_info(cs); + +visit_type_GuestPanicInformation(v, "crash-information", _info, + errp); +qapi_free_GuestPanicInformation(panic_info); +} + +void s390_cpu_init_sysemu(Object *obj) +{ +CPUState *cs = CPU(obj); +S390CPU *cpu = S390_CPU(obj); + +cs->start_powered_off = true; +object_property_add(obj, "crash-information", "GuestPanicInformation", +s390_cpu_get_crash_info_qom, NULL, NULL, NULL); +cpu->env.tod_timer = +timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_tod_timer, cpu); +cpu->env.cpu_timer = +timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu); +s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); +} + +bool s390_cpu_realize_sysemu(DeviceState *dev, Error **errp) +{ +S390CPU *cpu = S390_CPU(dev); +MachineState *ms = MACHINE(qdev_get_machine()); +
[RFC v5 05/13] target/s390x: remove tcg-stub.c
now that we protect all calls to the tcg-specific functions with if (tcg_enabled()), we do not need the TCG stub anymore. Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- target/s390x/meson.build | 2 +- target/s390x/tcg-stub.c | 30 -- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 target/s390x/tcg-stub.c diff --git a/target/s390x/meson.build b/target/s390x/meson.build index 1219f64112..a5e1ded93f 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -21,7 +21,7 @@ s390x_ss.add(when: 'CONFIG_TCG', if_true: files( 'vec_helper.c', 'vec_int_helper.c', 'vec_string_helper.c', -), if_false: files('tcg-stub.c')) +)) s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c')) diff --git a/target/s390x/tcg-stub.c b/target/s390x/tcg-stub.c deleted file mode 100644 index d22c898802..00 --- a/target/s390x/tcg-stub.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * QEMU TCG support -- s390x specific function stubs. - * - * Copyright (C) 2018 Red Hat Inc - * - * Authors: - * 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. - */ - -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "cpu.h" -#include "tcg_s390x.h" - -void tcg_s390_tod_updated(CPUState *cs, run_on_cpu_data opaque) -{ -} -void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, - uint32_t code, uintptr_t ra) -{ -g_assert_not_reached(); -} -void QEMU_NORETURN tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc, - uintptr_t ra) -{ -g_assert_not_reached(); -} -- 2.32.0
[RFC v5 06/13] target/s390x: start moving TCG-only code to tcg/
move everything related to translate, as well as HELPER code in tcg/ mmu_helper.c stays put for now, as it contains both TCG and KVM code. The internal.h file is renamed to s390x-internal.h, because of the risk of collision with other files with the same name. After the reshuffling, update MAINTAINERS accordingly. Make use of the new directory: target/s390x/tcg/ Signed-off-by: Claudio Fontana Acked-by: David Hildenbrand Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck --- MAINTAINERS | 2 +- hw/s390x/tod-tcg.c| 2 +- include/hw/s390x/tod.h| 2 +- target/s390x/arch_dump.c | 2 +- target/s390x/cpu.c| 2 +- target/s390x/cpu_models.c | 2 +- target/s390x/diag.c | 2 +- target/s390x/gdbstub.c| 2 +- target/s390x/helper.c | 2 +- target/s390x/interrupt.c | 4 ++-- target/s390x/ioinst.c | 2 +- target/s390x/kvm.c| 2 +- target/s390x/machine.c| 4 ++-- target/s390x/meson.build | 17 ++--- target/s390x/mmu_helper.c | 2 +- target/s390x/{internal.h => s390x-internal.h} | 6 ++ target/s390x/sigp.c | 2 +- target/s390x/{ => tcg}/cc_helper.c| 2 +- target/s390x/{ => tcg}/crypto_helper.c| 2 +- target/s390x/{ => tcg}/excp_helper.c | 2 +- target/s390x/{ => tcg}/fpu_helper.c | 2 +- target/s390x/{ => tcg}/insn-data.def | 0 target/s390x/{ => tcg}/insn-format.def| 0 target/s390x/{ => tcg}/int_helper.c | 2 +- target/s390x/{ => tcg}/mem_helper.c | 2 +- target/s390x/tcg/meson.build | 14 ++ target/s390x/{ => tcg}/misc_helper.c | 2 +- target/s390x/{ => tcg}/s390-tod.h | 0 target/s390x/{ => tcg}/tcg_s390x.h| 0 target/s390x/{ => tcg}/translate.c| 2 +- target/s390x/{ => tcg}/translate_vx.c.inc | 0 target/s390x/{ => tcg}/vec.h | 0 target/s390x/{ => tcg}/vec_fpu_helper.c | 2 +- target/s390x/{ => tcg}/vec_helper.c | 2 +- target/s390x/{ => tcg}/vec_int_helper.c | 0 target/s390x/{ => tcg}/vec_string_helper.c| 2 +- 36 files changed, 50 insertions(+), 43 deletions(-) rename target/s390x/{internal.h => s390x-internal.h} (98%) rename target/s390x/{ => tcg}/cc_helper.c (99%) rename target/s390x/{ => tcg}/crypto_helper.c (98%) rename target/s390x/{ => tcg}/excp_helper.c (99%) rename target/s390x/{ => tcg}/fpu_helper.c (99%) rename target/s390x/{ => tcg}/insn-data.def (100%) rename target/s390x/{ => tcg}/insn-format.def (100%) rename target/s390x/{ => tcg}/int_helper.c (99%) rename target/s390x/{ => tcg}/mem_helper.c (99%) create mode 100644 target/s390x/tcg/meson.build rename target/s390x/{ => tcg}/misc_helper.c (99%) rename target/s390x/{ => tcg}/s390-tod.h (100%) rename target/s390x/{ => tcg}/tcg_s390x.h (100%) rename target/s390x/{ => tcg}/translate.c (99%) rename target/s390x/{ => tcg}/translate_vx.c.inc (100%) rename target/s390x/{ => tcg}/vec.h (100%) rename target/s390x/{ => tcg}/vec_fpu_helper.c (99%) rename target/s390x/{ => tcg}/vec_helper.c (99%) rename target/s390x/{ => tcg}/vec_int_helper.c (100%) rename target/s390x/{ => tcg}/vec_string_helper.c (99%) diff --git a/MAINTAINERS b/MAINTAINERS index 636bf2f536..d05dcc22e0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -294,7 +294,7 @@ S390 TCG CPUs M: Richard Henderson M: David Hildenbrand S: Maintained -F: target/s390x/ +F: target/s390x/tcg F: hw/s390x/ F: disas/s390.c F: tests/tcg/s390x/ diff --git a/hw/s390x/tod-tcg.c b/hw/s390x/tod-tcg.c index e91b9590f5..4b3e65050a 100644 --- a/hw/s390x/tod-tcg.c +++ b/hw/s390x/tod-tcg.c @@ -16,7 +16,7 @@ #include "qemu/cutils.h" #include "qemu/module.h" #include "cpu.h" -#include "tcg_s390x.h" +#include "tcg/tcg_s390x.h" static void qemu_s390_tod_get(const S390TODState *td, S390TOD *tod, Error **errp) diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h index ff3195a4bf..0935e85089 100644 --- a/include/hw/s390x/tod.h +++ b/include/hw/s390x/tod.h @@ -12,7 +12,7 @@ #define HW_S390_TOD_H #include "hw/qdev-core.h" -#include "target/s390x/s390-tod.h" +#include "tcg/s390-tod.h" #include "qom/object.h" typedef struct S390TOD { diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c index cc1330876b..08daf93ae1 100644 --- a/target/s390x/arch_dump.c +++ b/target/s390x/arch_dump.c @@ -13,7 +13,7 @@ #incl
[RFC v5 01/13] target/s390x: meson: add target_user_arch
the lack of target_user_arch makes it hard to fully leverage the build system in order to separate user code from sysemu code. Provide it, so that we can avoid the proliferation of #ifdef in target code. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen Acked-by: Cornelia Huck --- target/s390x/meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/s390x/meson.build b/target/s390x/meson.build index c42eadb7d2..1219f64112 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -58,5 +58,8 @@ if host_machine.cpu_family() == 's390x' and cc.has_link_argument('-Wl,--s390-pgs if_true: declare_dependency(link_args: ['-Wl,--s390-pgste'])) endif +s390x_user_ss = ss.source_set() + target_arch += {'s390x': s390x_ss} target_softmmu_arch += {'s390x': s390x_softmmu_ss} +target_user_arch += {'s390x': s390x_user_ss} -- 2.32.0
[RFC v5 04/13] hw/s390x: tod: make explicit checks for accelerators when initializing
replace general "else" with specific checks for each possible accelerator. Handle qtest as a NOP, and error out for an unknown accelerator used in combination with tod. Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- hw/s390x/tod.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/s390x/tod.c b/hw/s390x/tod.c index 3c2979175e..fd5a36bf24 100644 --- a/hw/s390x/tod.c +++ b/hw/s390x/tod.c @@ -14,6 +14,8 @@ #include "qemu/error-report.h" #include "qemu/module.h" #include "sysemu/kvm.h" +#include "sysemu/tcg.h" +#include "sysemu/qtest.h" #include "migration/qemu-file-types.h" #include "migration/register.h" @@ -23,8 +25,13 @@ void s390_init_tod(void) if (kvm_enabled()) { obj = object_new(TYPE_KVM_S390_TOD); -} else { +} else if (tcg_enabled()) { obj = object_new(TYPE_QEMU_S390_TOD); +} else if (qtest_enabled()) { +return; +} else { +error_report("current accelerator not handled in s390_init_tod!"); +abort(); } object_property_add_child(qdev_get_machine(), TYPE_S390_TOD, obj); object_unref(obj); -- 2.32.0
[RFC v5 03/13] hw/s390x: only build tod-tcg from the CONFIG_TCG build
this will allow in later patches to remove unneeded stubs in target/s390x. Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- hw/s390x/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index 02e81a9467..28484256ec 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -16,7 +16,6 @@ s390x_ss.add(files( 'sclp.c', 'sclpcpu.c', 'sclpquiesce.c', - 'tod-tcg.c', 'tod.c', )) s390x_ss.add(when: 'CONFIG_KVM', if_true: files( @@ -25,6 +24,9 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files( 's390-stattrib-kvm.c', 'pv.c', )) +s390x_ss.add(when: 'CONFIG_TCG', if_true: files( + 'tod-tcg.c', +)) s390x_ss.add(when: 'CONFIG_S390_CCW_VIRTIO', if_true: files('s390-virtio-ccw.c')) s390x_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('3270-ccw.c')) s390x_ss.add(when: 'CONFIG_VFIO', if_true: files('s390-pci-vfio.c')) -- 2.32.0
[RFC v5 02/13] hw/s390x: rename tod-qemu.c to tod-tcg.c
we stop short of renaming the actual qom object though, so type remains TYPE_QEMU_S390_TOD, ie "s390-tod-qemu". Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- hw/s390x/meson.build | 2 +- hw/s390x/{tod-qemu.c => tod-tcg.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename hw/s390x/{tod-qemu.c => tod-tcg.c} (100%) diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index 327e9c93af..02e81a9467 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -16,7 +16,7 @@ s390x_ss.add(files( 'sclp.c', 'sclpcpu.c', 'sclpquiesce.c', - 'tod-qemu.c', + 'tod-tcg.c', 'tod.c', )) s390x_ss.add(when: 'CONFIG_KVM', if_true: files( diff --git a/hw/s390x/tod-qemu.c b/hw/s390x/tod-tcg.c similarity index 100% rename from hw/s390x/tod-qemu.c rename to hw/s390x/tod-tcg.c -- 2.32.0
[RFC v5 00/13] s390x cleanup
this is the next version of a cleanup series for s390x. v4 -> v5: * "target/s390x: start moving TCG-only code to tcg/" - add change to MAINTAINERS file * "target/s390x: move sysemu-only code out to cpu-sysemu.c" - make use of SysemuCPUOps s390_sysemu_ops to handle * "target/s390x: split cpu-dump from helper.c" - add description to explain why split cpu-dump from helper.c * "target/s390x: make helper.c sysemu-only" #9 - mention at the beginning of this file that this is sysemu only (Cornelia) * "target/s390x: remove kvm-stub.c" - add additional comment to explain the function can be removed (Thomas) * "target/s390x: move kvm files into kvm/" - add change to MAINTAINERS file * "target/s390x: split sysemu part of cpu models" - add change to MAINTAINERS file * "MAINTAINERS: update s390x directories" - removed, squash this in respectively: #6 target/s390x: start moving TCG-only code to tcg/ #12 target/s390x: move kvm files into kvm/ #13 target/s390x: split sysemu part of cpu models v3 -> v4: take s390x part from Claudio and modify for the current master * "target/s390x: meson: add target_user_arch" - new patch, add target_user_arch to avoid the proliferation of #ifdef in target code. v2 -> v3: minor changes * "hw/s390x: rename tod-qemu.c to tod-tcg.c": move to the front (David) * "hw/s390x: only build tod-qemu from the CONFIG_TCG build" - move just after, use "tod-tcg" instead * "hw/s390x: tod: make explicit checks for accelerators when initializing" - removed a line break in commit message * "target/s390x: start moving TCG-only code to tcg/" - split the rename s390x-internal.h rename part, do it before the move * "target/s390x: move kvm files into kvm/" - fix broken/missing move of trace events Cho, Yu-Chen (13): target/s390x: meson: add target_user_arch hw/s390x: rename tod-qemu.c to tod-tcg.c hw/s390x: only build tod-tcg from the CONFIG_TCG build hw/s390x: tod: make explicit checks for accelerators when initializing target/s390x: remove tcg-stub.c target/s390x: start moving TCG-only code to tcg/ target/s390x: move sysemu-only code out to cpu-sysemu.c target/s390x: split cpu-dump from helper.c target/s390x: make helper.c sysemu-only target/s390x: use kvm_enabled() to wrap call to kvm_s390_get_hpage_1m target/s390x: remove kvm-stub.c target/s390x: move kvm files into kvm/ target/s390x: split sysemu part of cpu models MAINTAINERS | 7 +- hw/intc/s390_flic_kvm.c | 2 +- hw/s390x/meson.build | 4 +- hw/s390x/s390-stattrib-kvm.c | 2 +- hw/s390x/tod-kvm.c| 2 +- hw/s390x/{tod-qemu.c => tod-tcg.c}| 2 +- hw/s390x/tod.c| 9 +- hw/vfio/ap.c | 2 +- include/hw/s390x/tod.h| 2 +- meson.build | 1 + target/s390x/arch_dump.c | 2 +- target/s390x/cpu-dump.c | 131 ++ target/s390x/cpu-sysemu.c | 309 + target/s390x/cpu.c| 289 +--- target/s390x/cpu_models.c | 421 + target/s390x/cpu_models_sysemu.c | 426 ++ target/s390x/cpu_models_user.c| 20 + target/s390x/diag.c | 7 +- target/s390x/gdbstub.c| 2 +- target/s390x/helper.c | 115 + target/s390x/interrupt.c | 6 +- target/s390x/ioinst.c | 2 +- target/s390x/kvm-stub.c | 126 -- target/s390x/{ => kvm}/kvm.c | 4 +- target/s390x/{ => kvm}/kvm_s390x.h| 0 target/s390x/kvm/meson.build | 17 + target/s390x/kvm/trace-events | 7 + target/s390x/kvm/trace.h | 1 + target/s390x/machine.c| 6 +- target/s390x/meson.build | 42 +- target/s390x/mmu_helper.c | 4 +- target/s390x/{internal.h => s390x-internal.h} | 8 + target/s390x/sigp.c | 2 +- target/s390x/tcg-stub.c | 30 -- target/s390x/{ => tcg}/cc_helper.c| 2 +- target/s390x/{ => tcg}/crypto_helper.c| 2 +- target/s390x/{ => tcg}/excp_helper.c | 2 +- target/s390x/{ => tcg}/fpu_helper.c | 2 +- target/s390x/{ => tcg}/insn-data.def | 0 target/s390x/{ => tcg}/insn-format.def| 0 target/s390x/{ => tcg}/int_helper.c | 2 +- target/s
[RFC v4 00/14] s390x cleanup
this is the next version of a cleanup series for s390x. v3 -> v4: take s390x part from Claudio and modify for the current master * "target/s390x: meson: add target_user_arch" - new patch, add target_user_arch to avoid the proliferation of #ifdef in target code. v2 -> v3: minor changes * "hw/s390x: rename tod-qemu.c to tod-tcg.c": move to the front (David) * "hw/s390x: only build tod-qemu from the CONFIG_TCG build" - move just after, use "tod-tcg" instead * "hw/s390x: tod: make explicit checks for accelerators when initializing" - removed a line break in commit message * "target/s390x: start moving TCG-only code to tcg/" - split the rename s390x-internal.h rename part, do it before the move * "target/s390x: move kvm files into kvm/" - fix broken/missing move of trace events --- v1 -> v2: split more, stubs removal for KVM, kvm/ move, sysemu cpu models * "hw/s390x: rename tod-qemu.c to tod-tcg.c" - new patch (Cornelia) * "hw/s390x: tod: make explicit checks for accelerators when initializing" - now error out and abort() for an unknown accelerator. (Cornelia) * "target/s390x: remove tcg-stub.c" : new patch split from "target/s390x: start moving TCG-only code to tcg/" (Cornelia) * "target/s390x: use kvm_enabled() to wrap call to kvm_s390_get_hpage_1m" - new patch, allows the removal of kvm stubs * "target/s390x: remove kvm-stub.c" - new patch, we do not need stubs, as all calls are wrapped by kvm_enabled(), and all prototypes are visible. * "target/s390x: move kvm files into kvm/" - new patch * "target/s390x: split sysemu part of cpu models" - new patch * "MAINTAINERS: update s390x directories" - new patch Pre-requisite series (not really needed for now, only in further work down the line): https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg07461.html Motivation and higher level steps: https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg04628.html Comments welcome, thanks, AL Cho, Yu-Chen (14): target/s390x: meson: add target_user_arch hw/s390x: rename tod-qemu.c to tod-tcg.c hw/s390x: only build tod-tcg from the CONFIG_TCG build hw/s390x: tod: make explicit checks for accelerators when initializing target/s390x: remove tcg-stub.c target/s390x: start moving TCG-only code to tcg/ target/s390x: move sysemu-only code out to cpu-sysemu.c target/s390x: split cpu-dump from helper.c target/s390x: make helper.c sysemu-only target/s390x: use kvm_enabled() to wrap call to kvm_s390_get_hpage_1m target/s390x: remove kvm-stub.c target/s390x: move kvm files into kvm/ target/s390x: split sysemu part of cpu models MAINTAINERS: update s390x directories MAINTAINERS | 8 +- hw/intc/s390_flic_kvm.c | 2 +- hw/s390x/meson.build | 4 +- hw/s390x/s390-stattrib-kvm.c | 2 +- hw/s390x/tod-kvm.c| 2 +- hw/s390x/{tod-qemu.c => tod-tcg.c}| 2 +- hw/s390x/tod.c| 9 +- hw/vfio/ap.c | 2 +- include/hw/s390x/tod.h| 2 +- meson.build | 1 + target/s390x/arch_dump.c | 2 +- target/s390x/cpu-dump.c | 131 ++ target/s390x/cpu-sysemu.c | 304 + target/s390x/cpu.c| 286 +--- target/s390x/cpu_models.c | 421 + target/s390x/cpu_models_sysemu.c | 426 ++ target/s390x/cpu_models_user.c| 20 + target/s390x/diag.c | 7 +- target/s390x/gdbstub.c| 2 +- target/s390x/helper.c | 113 + target/s390x/interrupt.c | 6 +- target/s390x/ioinst.c | 2 +- target/s390x/kvm-stub.c | 126 -- target/s390x/{ => kvm}/kvm.c | 4 +- target/s390x/{ => kvm}/kvm_s390x.h| 0 target/s390x/kvm/meson.build | 17 + target/s390x/kvm/trace-events | 7 + target/s390x/kvm/trace.h | 1 + target/s390x/machine.c| 6 +- target/s390x/meson.build | 42 +- target/s390x/mmu_helper.c | 4 +- target/s390x/{internal.h => s390x-internal.h} | 8 + target/s390x/sigp.c | 2 +- target/s390x/tcg-stub.c | 30 -- target/s390x/{ => tcg}/cc_helper.c| 2 +- target/s390x/{ => tcg}/crypto_helper.c| 2 +- target/s390x/{ => tcg}/excp_helper
Re: latest GOOD state of series i386 cleanup, arm cleanup, s390 cleanup
I also done a branch for current master from [RFC v3 00/13] s390x cleanup https://gitlab.com/alcho.tw/qemu/-/tree/s390_cleanup_v4 and it's also built and test success passed through my CI: https://gitlab.com/alcho.tw/qemu/-/pipelines/307149915 Cheers, AL Alex Bennée 於 2021年5月21日 週五 上午12:07寫道: > > > Claudio Fontana writes: > > > On 5/18/21 4:02 PM, Alex Bennée wrote: > >> > >> Claudio Fontana writes: > >> > >>> On 5/17/21 11:53 AM, Claudio Fontana wrote: > Hello all, > > due to my inactivity for a few weeks coupled likely with the upstream > processes around qemu-6.0 now the series: > > 1) i386 cleanup > 2) arm cleanup and experimental kvm-only build > 3) s390 cleanup > > have become stale and hard to rebase on latest master. > This effect is compounded by the fact that lots of broken tests in > master have been added. > >> > >> Which tests are these? I know master suffers a bit from occasional > >> falling red but to my knowledge everything should be green (at least > >> from my last PR anyway ;-). > >> > > In the interest of not losing work, > I provide here the latest known good state of these series: > > For the i386 cleanup: > https://gitlab.com/hw-claudio/qemu/-/pipelines/293603386 > > Tests started breaking horribly since about 1/2 weeks. > >> > >> The pipeline only shows one failed test (checkpatch) which is an > >> allowfail I believe. /me is confused. > > > > Hi Alex, yes, I pointed to the last pipeline that works :-) > > > >> > The latest version of the cleanup is reachable here: > > https://github.com/qemu/qemu.git branch "i386_cleanup_9" > > In my understanding, Paolo has now picked up this one. > > For the ARM cleanup and experimental kvm-only build: > > https://gitlab.com/hw-claudio/qemu/-/pipelines/293603376 > > https://github.com/qemu/qemu.git branch "arm_cleanup_v15" > > Again here tests started misbehaving in the same timeframe. > > The state of ARM cleanup is still experimental, maybe Liang or > Philippe you can adopt this one? > > I've done a re-base onto the current master (and my testing/next): > > https://github.com/stsquad/qemu/tree/review/arm_cleanup_v15 > > which is currently working it's way through my CI: > > https://gitlab.com/stsquad/qemu/-/pipelines/306727076 > > As I've got patches waiting for this re-factor I'm happy to take the > series on if you've run out of time/patience ;-) > > -- > Alex Bennée >
[RFC v4 13/14] target/s390x: split sysemu part of cpu models
also create a tiny _user.c with just the (at least for now), empty implementation of apply_cpu_model. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/cpu_models.c| 417 +- target/s390x/cpu_models_sysemu.c | 426 +++ target/s390x/cpu_models_user.c | 20 ++ target/s390x/meson.build | 4 + target/s390x/s390x-internal.h| 2 + 5 files changed, 453 insertions(+), 416 deletions(-) create mode 100644 target/s390x/cpu_models_sysemu.c create mode 100644 target/s390x/cpu_models_user.c diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 0ed1c23774..30a192590d 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -18,18 +18,11 @@ #include "sysemu/tcg.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/qemu-print.h" -#include "qapi/qmp/qerror.h" -#include "qapi/qobject-input-visitor.h" -#include "qapi/qmp/qdict.h" #ifndef CONFIG_USER_ONLY -#include "sysemu/arch_init.h" #include "sysemu/sysemu.h" -#include "hw/pci/pci.h" #endif -#include "qapi/qapi-commands-machine-target.h" #include "hw/s390x/pv.h" #define CPUDEF_INIT(_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \ @@ -414,381 +407,6 @@ void s390_cpu_list(void) } } -static S390CPUModel *get_max_cpu_model(Error **errp); - -#ifndef CONFIG_USER_ONLY -static void list_add_feat(const char *name, void *opaque); - -static void check_unavailable_features(const S390CPUModel *max_model, - const S390CPUModel *model, - strList **unavailable) -{ -S390FeatBitmap missing; - -/* check general model compatibility */ -if (max_model->def->gen < model->def->gen || -(max_model->def->gen == model->def->gen && - max_model->def->ec_ga < model->def->ec_ga)) { -list_add_feat("type", unavailable); -} - -/* detect missing features if any to properly report them */ -bitmap_andnot(missing, model->features, max_model->features, - S390_FEAT_MAX); -if (!bitmap_empty(missing, S390_FEAT_MAX)) { -s390_feat_bitmap_to_ascii(missing, unavailable, list_add_feat); -} -} - -struct CpuDefinitionInfoListData { -CpuDefinitionInfoList *list; -S390CPUModel *model; -}; - -static void create_cpu_model_list(ObjectClass *klass, void *opaque) -{ -struct CpuDefinitionInfoListData *cpu_list_data = opaque; -CpuDefinitionInfoList **cpu_list = _list_data->list; -CpuDefinitionInfo *info; -char *name = g_strdup(object_class_get_name(klass)); -S390CPUClass *scc = S390_CPU_CLASS(klass); - -/* strip off the -s390x-cpu */ -g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0; -info = g_new0(CpuDefinitionInfo, 1); -info->name = name; -info->has_migration_safe = true; -info->migration_safe = scc->is_migration_safe; -info->q_static = scc->is_static; -info->q_typename = g_strdup(object_class_get_name(klass)); -/* check for unavailable features */ -if (cpu_list_data->model) { -Object *obj; -S390CPU *sc; -obj = object_new_with_class(klass); -sc = S390_CPU(obj); -if (sc->model) { -info->has_unavailable_features = true; -check_unavailable_features(cpu_list_data->model, sc->model, - >unavailable_features); -} -object_unref(obj); -} - -QAPI_LIST_PREPEND(*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ -struct CpuDefinitionInfoListData list_data = { -.list = NULL, -}; - -list_data.model = get_max_cpu_model(NULL); - -object_class_foreach(create_cpu_model_list, TYPE_S390_CPU, false, - _data); - -return list_data.list; -} - -static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, -Error **errp) -{ -Error *err = NULL; -const QDict *qdict = NULL; -const QDictEntry *e; -Visitor *visitor; -ObjectClass *oc; -S390CPU *cpu; -Object *obj; - -if (info->props) { -qdict = qobject_to(QDict, info->props); -if (!qdict) { -error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict"); -return; -} -} - -oc = cpu_class_by_name(TYPE_S390_CPU, info->name); -if (!oc) { -error_setg(errp, "The CPU definition \'%s\' is unknown.", info->name); -return; -} -if (S390_CPU_CLASS(oc)->kvm_required && !kvm_enabled()) {
[RFC v4 14/14] MAINTAINERS: update s390x directories
After the reshuffling, update MAINTAINERS accordingly. Make use of the new directories: target/s390x/kvm/ target/s390x/tcg/ Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- MAINTAINERS | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 89741cfc19..8578927961 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -293,7 +293,7 @@ S390 TCG CPUs M: Richard Henderson M: David Hildenbrand S: Maintained -F: target/s390x/ +F: target/s390x/tcg F: hw/s390x/ F: disas/s390.c F: tests/tcg/s390x/ @@ -389,14 +389,12 @@ M: Halil Pasic M: Cornelia Huck M: Christian Borntraeger S: Supported -F: target/s390x/kvm.c -F: target/s390x/kvm_s390x.h -F: target/s390x/kvm-stub.c +F: target/s390x/kvm/ F: target/s390x/ioinst.[ch] F: target/s390x/machine.c F: target/s390x/sigp.c F: target/s390x/cpu_features*.[ch] -F: target/s390x/cpu_models.[ch] +F: target/s390x/cpu_models*.[ch] F: hw/s390x/pv.c F: include/hw/s390x/pv.h F: hw/intc/s390_flic.c -- 2.31.1
[RFC v4 10/14] target/s390x: use kvm_enabled() to wrap call to kvm_s390_get_hpage_1m
this will allow to remove the kvm stubs. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/diag.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/s390x/diag.c b/target/s390x/diag.c index c17a2498a7..8405f69df0 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -20,6 +20,7 @@ #include "hw/s390x/ipl.h" #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/pv.h" +#include "sysemu/kvm.h" #include "kvm_s390x.h" int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3) @@ -168,7 +169,7 @@ out: return; } -if (kvm_s390_get_hpage_1m()) { +if (kvm_enabled() && kvm_s390_get_hpage_1m()) { error_report("Protected VMs can currently not be backed with " "huge pages"); env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV; -- 2.31.1
[RFC v4 12/14] target/s390x: move kvm files into kvm/
Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- hw/intc/s390_flic_kvm.c| 2 +- hw/s390x/s390-stattrib-kvm.c | 2 +- hw/s390x/tod-kvm.c | 2 +- hw/vfio/ap.c | 2 +- meson.build| 1 + target/s390x/cpu-sysemu.c | 2 +- target/s390x/cpu.c | 2 +- target/s390x/cpu_models.c | 2 +- target/s390x/diag.c| 2 +- target/s390x/interrupt.c | 2 +- target/s390x/{ => kvm}/kvm.c | 2 +- target/s390x/{ => kvm}/kvm_s390x.h | 0 target/s390x/kvm/meson.build | 17 + target/s390x/kvm/trace-events | 7 +++ target/s390x/kvm/trace.h | 1 + target/s390x/machine.c | 2 +- target/s390x/meson.build | 16 +--- target/s390x/mmu_helper.c | 2 +- target/s390x/trace-events | 6 -- 19 files changed, 39 insertions(+), 33 deletions(-) rename target/s390x/{ => kvm}/kvm.c (99%) rename target/s390x/{ => kvm}/kvm_s390x.h (100%) create mode 100644 target/s390x/kvm/meson.build create mode 100644 target/s390x/kvm/trace-events create mode 100644 target/s390x/kvm/trace.h diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 929cfa3a68..efe5054182 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -11,7 +11,7 @@ */ #include "qemu/osdep.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include #include "qemu/error-report.h" #include "qemu/module.h" diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c index f0b11a74e4..24cd01382e 100644 --- a/hw/s390x/s390-stattrib-kvm.c +++ b/hw/s390x/s390-stattrib-kvm.c @@ -16,7 +16,7 @@ #include "qemu/error-report.h" #include "sysemu/kvm.h" #include "exec/ram_addr.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" Object *kvm_s390_stattrib_create(void) { diff --git a/hw/s390x/tod-kvm.c b/hw/s390x/tod-kvm.c index 0b94477486..ec855811ae 100644 --- a/hw/s390x/tod-kvm.c +++ b/hw/s390x/tod-kvm.c @@ -13,7 +13,7 @@ #include "qemu/module.h" #include "sysemu/runstate.h" #include "hw/s390x/tod.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" static void kvm_s390_get_tod_raw(S390TOD *tod, Error **errp) { diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 4b32aca1a0..e0dd561e85 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -21,7 +21,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "migration/vmstate.h" #include "hw/qdev-properties.h" #include "hw/s390x/ap-bridge.h" diff --git a/meson.build b/meson.build index 1559e8d873..37be2e60c3 100644 --- a/meson.build +++ b/meson.build @@ -1863,6 +1863,7 @@ if have_system or have_user 'target/ppc', 'target/riscv', 'target/s390x', +'target/s390x/kvm', 'target/sparc', ] endif diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c index 6081b7ef32..f3c1b4845a 100644 --- a/target/s390x/cpu-sysemu.c +++ b/target/s390x/cpu-sysemu.c @@ -24,7 +24,7 @@ #include "qapi/error.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "qemu/timer.h" diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 59efe48bcd..6e82ba73cc 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -24,7 +24,7 @@ #include "qapi/error.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "qemu/module.h" diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 4ff8cba7e5..0ed1c23774 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "s390x-internal.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h" #include "qapi/error.h" diff --git a/target/s390x/diag.c b/target/s390x/diag.c index 8405f69df0..76b01dcd68 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -21,7 +21,7 @@ #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/pv.h" #include "sysemu/kvm.h" -#include "kvm_s390x.h" +#include "kvm/kvm_s390x.h" int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3) { diff --git a/target/s3
[RFC v4 09/14] target/s390x: make helper.c sysemu-only
Now that we have moved cpu-dump functionality out of helper.c, we can make the module sysemu-only. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/helper.c| 4 target/s390x/meson.build | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 41ccc83d11..f246bec353 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -27,11 +27,8 @@ #include "hw/s390x/pv.h" #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" -#ifndef CONFIG_USER_ONLY #include "sysemu/tcg.h" -#endif -#ifndef CONFIG_USER_ONLY void s390x_tod_timer(void *opaque) { cpu_inject_clock_comparator((S390CPU *) opaque); @@ -322,4 +319,3 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) cpu_physical_memory_unmap(sa, len, 1, len); return 0; } -#endif /* CONFIG_USER_ONLY */ diff --git a/target/s390x/meson.build b/target/s390x/meson.build index 6e1aa3b0cd..bbcaede384 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -4,7 +4,6 @@ s390x_ss.add(files( 'cpu_features.c', 'cpu_models.c', 'gdbstub.c', - 'helper.c', 'interrupt.c', 'cpu-dump.c', )) @@ -23,6 +22,7 @@ s390x_ss.add(gen_features_h) s390x_softmmu_ss = ss.source_set() s390x_softmmu_ss.add(files( + 'helper.c', 'arch_dump.c', 'diag.c', 'ioinst.c', -- 2.31.1
[RFC v4 11/14] target/s390x: remove kvm-stub.c
all function calls are protected by kvm_enabled(), so we should not need the stubs. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/kvm-stub.c | 126 --- target/s390x/meson.build | 2 +- 2 files changed, 1 insertion(+), 127 deletions(-) delete mode 100644 target/s390x/kvm-stub.c diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c deleted file mode 100644 index 9970b5a8c7..00 --- a/target/s390x/kvm-stub.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * QEMU KVM support -- s390x specific function stubs. - * - * Copyright (c) 2009 Ulrich Hecht - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#include "qemu/osdep.h" -#include "cpu.h" -#include "kvm_s390x.h" - -void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code) -{ -} - -int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf, -int len, bool is_write) -{ -return -ENOSYS; -} - -void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code) -{ -} - -int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state) -{ -return -ENOSYS; -} - -void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu) -{ -} - -int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu) -{ -return 0; -} - -int kvm_s390_get_hpage_1m(void) -{ -return 0; -} - -int kvm_s390_get_ri(void) -{ -return 0; -} - -int kvm_s390_get_gs(void) -{ -return 0; -} - -int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_set_clock(uint8_t tod_high, uint64_t tod_low) -{ -return -ENOSYS; -} - -int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_low) -{ -return -ENOSYS; -} - -void kvm_s390_enable_css_support(S390CPU *cpu) -{ -} - -int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, -int vq, bool assign) -{ -return -ENOSYS; -} - -void kvm_s390_cmma_reset(void) -{ -} - -void kvm_s390_reset_vcpu_initial(S390CPU *cpu) -{ -} - -void kvm_s390_reset_vcpu_clear(S390CPU *cpu) -{ -} - -void kvm_s390_reset_vcpu_normal(S390CPU *cpu) -{ -} - -int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_t *hw_limit) -{ -return 0; -} - -void kvm_s390_set_max_pagesize(uint64_t pagesize, Error **errp) -{ -} - -void kvm_s390_crypto_reset(void) -{ -} - -void kvm_s390_stop_interrupt(S390CPU *cpu) -{ -} - -void kvm_s390_restart_interrupt(S390CPU *cpu) -{ -} - -void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info) -{ -} diff --git a/target/s390x/meson.build b/target/s390x/meson.build index bbcaede384..6c8e03b8fb 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -8,7 +8,7 @@ s390x_ss.add(files( 'cpu-dump.c', )) -s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c')) +s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c')) gen_features = executable('gen-features', 'gen-features.c', native: true, build_by_default: false) -- 2.31.1
[RFC v4 07/14] target/s390x: move sysemu-only code out to cpu-sysemu.c
Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/cpu-sysemu.c | 304 ++ target/s390x/cpu.c| 282 ++- target/s390x/meson.build | 1 + target/s390x/trace-events | 2 +- 4 files changed, 318 insertions(+), 271 deletions(-) create mode 100644 target/s390x/cpu-sysemu.c diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c new file mode 100644 index 00..6081b7ef32 --- /dev/null +++ b/target/s390x/cpu-sysemu.c @@ -0,0 +1,304 @@ +/* + * QEMU S/390 CPU - System Emulation-only code + * + * Copyright (c) 2009 Ulrich Hecht + * Copyright (c) 2011 Alexander Graf + * Copyright (c) 2012 SUSE LINUX Products GmbH + * Copyright (c) 2012 IBM Corp. + * + * 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 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "cpu.h" +#include "s390x-internal.h" +#include "kvm_s390x.h" +#include "sysemu/kvm.h" +#include "sysemu/reset.h" +#include "qemu/timer.h" +#include "trace.h" +#include "qapi/qapi-visit-run-state.h" +#include "sysemu/hw_accel.h" + +#include "hw/s390x/pv.h" +#include "hw/boards.h" +#include "sysemu/arch_init.h" +#include "sysemu/sysemu.h" +#include "sysemu/tcg.h" + +/* S390CPUClass::load_normal() */ +static void s390_cpu_load_normal(CPUState *s) +{ +S390CPU *cpu = S390_CPU(s); +uint64_t spsw; + +if (!s390_is_pv()) { +spsw = ldq_phys(s->as, 0); +cpu->env.psw.mask = spsw & PSW_MASK_SHORT_CTRL; +/* + * Invert short psw indication, so SIE will report a specification + * exception if it was not set. + */ +cpu->env.psw.mask ^= PSW_MASK_SHORTPSW; +cpu->env.psw.addr = spsw & PSW_MASK_SHORT_ADDR; +} else { +/* + * Firmware requires us to set the load state before we set + * the cpu to operating on protected guests. + */ +s390_cpu_set_state(S390_CPU_STATE_LOAD, cpu); +} +s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); +} + +void s390_cpu_machine_reset_cb(void *opaque) +{ +S390CPU *cpu = opaque; + +run_on_cpu(CPU(cpu), s390_do_cpu_full_reset, RUN_ON_CPU_NULL); +} + +static GuestPanicInformation *s390_cpu_get_crash_info(CPUState *cs) +{ +GuestPanicInformation *panic_info; +S390CPU *cpu = S390_CPU(cs); + +cpu_synchronize_state(cs); +panic_info = g_malloc0(sizeof(GuestPanicInformation)); + +panic_info->type = GUEST_PANIC_INFORMATION_TYPE_S390; +panic_info->u.s390.core = cpu->env.core_id; +panic_info->u.s390.psw_mask = cpu->env.psw.mask; +panic_info->u.s390.psw_addr = cpu->env.psw.addr; +panic_info->u.s390.reason = cpu->env.crash_reason; + +return panic_info; +} + +static void s390_cpu_get_crash_info_qom(Object *obj, Visitor *v, +const char *name, void *opaque, +Error **errp) +{ +CPUState *cs = CPU(obj); +GuestPanicInformation *panic_info; + +if (!cs->crash_occurred) { +error_setg(errp, "No crash occurred"); +return; +} + +panic_info = s390_cpu_get_crash_info(cs); + +visit_type_GuestPanicInformation(v, "crash-information", _info, + errp); +qapi_free_GuestPanicInformation(panic_info); +} + +void s390_cpu_init_sysemu(Object *obj) +{ +CPUState *cs = CPU(obj); +S390CPU *cpu = S390_CPU(obj); + +cs->start_powered_off = true; +object_property_add(obj, "crash-information", "GuestPanicInformation", +s390_cpu_get_crash_info_qom, NULL, NULL, NULL); +cpu->env.tod_timer = +timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_tod_timer, cpu); +cpu->env.cpu_timer = +timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu); +s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); +} + +bool s390_cpu_realize_sysemu(DeviceState *dev, Error **errp) +{ +S390CPU *cpu = S390_CPU(dev); +MachineState *ms = MACHINE(qdev_get_machine()); +unsigned int max_cpus = ms->smp.max_cpus; + +if (cpu->env.core_id >= max_cpus) {
[RFC v4 08/14] target/s390x: split cpu-dump from helper.c
Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/cpu-dump.c | 131 +++ target/s390x/helper.c| 107 target/s390x/meson.build | 1 + 3 files changed, 132 insertions(+), 107 deletions(-) create mode 100644 target/s390x/cpu-dump.c diff --git a/target/s390x/cpu-dump.c b/target/s390x/cpu-dump.c new file mode 100644 index 00..4170dec01a --- /dev/null +++ b/target/s390x/cpu-dump.c @@ -0,0 +1,131 @@ +/* + * S/390 CPU dump to FILE + * + * Copyright (c) 2009 Ulrich Hecht + * Copyright (c) 2011 Alexander Graf + * + * 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 library 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. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "s390x-internal.h" +#include "qemu/qemu-print.h" + +void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags) +{ +S390CPU *cpu = S390_CPU(cs); +CPUS390XState *env = >env; +int i; + +if (env->cc_op > 3) { +qemu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64 " cc %15s\n", + env->psw.mask, env->psw.addr, cc_name(env->cc_op)); +} else { +qemu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64 " cc %02x\n", + env->psw.mask, env->psw.addr, env->cc_op); +} + +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "R%02d=%016" PRIx64, i, env->regs[i]); +if ((i % 4) == 3) { +qemu_fprintf(f, "\n"); +} else { +qemu_fprintf(f, " "); +} +} + +if (flags & CPU_DUMP_FPU) { +if (s390_has_feat(S390_FEAT_VECTOR)) { +for (i = 0; i < 32; i++) { +qemu_fprintf(f, "V%02d=%016" PRIx64 "%016" PRIx64 "%c", + i, env->vregs[i][0], env->vregs[i][1], + i % 2 ? '\n' : ' '); +} +} else { +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "F%02d=%016" PRIx64 "%c", + i, *get_freg(env, i), + (i % 4) == 3 ? '\n' : ' '); +} +} +} + +#ifndef CONFIG_USER_ONLY +for (i = 0; i < 16; i++) { +qemu_fprintf(f, "C%02d=%016" PRIx64, i, env->cregs[i]); +if ((i % 4) == 3) { +qemu_fprintf(f, "\n"); +} else { +qemu_fprintf(f, " "); +} +} +#endif + +#ifdef DEBUG_INLINE_BRANCHES +for (i = 0; i < CC_OP_MAX; i++) { +qemu_fprintf(f, " %15s = %10ld\t%10ld\n", cc_name(i), + inline_branch_miss[i], inline_branch_hit[i]); +} +#endif + +qemu_fprintf(f, "\n"); +} + +const char *cc_name(enum cc_op cc_op) +{ +static const char * const cc_names[] = { +[CC_OP_CONST0]= "CC_OP_CONST0", +[CC_OP_CONST1]= "CC_OP_CONST1", +[CC_OP_CONST2]= "CC_OP_CONST2", +[CC_OP_CONST3]= "CC_OP_CONST3", +[CC_OP_DYNAMIC] = "CC_OP_DYNAMIC", +[CC_OP_STATIC]= "CC_OP_STATIC", +[CC_OP_NZ]= "CC_OP_NZ", +[CC_OP_ADDU] = "CC_OP_ADDU", +[CC_OP_SUBU] = "CC_OP_SUBU", +[CC_OP_LTGT_32] = "CC_OP_LTGT_32", +[CC_OP_LTGT_64] = "CC_OP_LTGT_64", +[CC_OP_LTUGTU_32] = "CC_OP_LTUGTU_32", +[CC_OP_LTUGTU_64] = "CC_OP_LTUGTU_64", +[CC_OP_LTGT0_32] = "CC_OP_LTGT0_32", +[CC_OP_LTGT0_64] = "CC_OP_LTGT0_64", +[CC_OP_ADD_64]= "CC_OP_ADD_64", +[CC_OP_SUB_64]= "CC_OP_SUB_64", +[CC_OP_ABS_64]= "CC_OP_ABS_64", +[CC_OP_NABS_64] = "CC_OP_NABS_64", +[CC_OP_ADD_32]= "CC_OP_ADD_32", +[CC_OP_SUB_32]= "CC_OP_SUB_32", +[CC_OP_ABS_32]= "CC_OP_ABS_32", +[CC_OP_NABS_32] = "CC_OP_NABS_32", +[CC_OP_COMP_32] = "CC_OP_COMP_32", +[CC_OP_COM
[RFC v4 06/14] target/s390x: start moving TCG-only code to tcg/
move everything related to translate, as well as HELPER code in tcg/ mmu_helper.c stays put for now, as it contains both TCG and KVM code. The internal.h file is renamed to s390x-internal.h, because of the risk of collision with other files with the same name. Signed-off-by: Claudio Fontana Acked-by: David Hildenbrand Signed-off-by: Cho, Yu-Chen --- hw/s390x/tod-tcg.c| 2 +- include/hw/s390x/tod.h| 2 +- target/s390x/arch_dump.c | 2 +- target/s390x/cpu.c| 2 +- target/s390x/cpu_models.c | 2 +- target/s390x/diag.c | 2 +- target/s390x/gdbstub.c| 2 +- target/s390x/helper.c | 2 +- target/s390x/interrupt.c | 4 ++-- target/s390x/ioinst.c | 2 +- target/s390x/kvm.c| 2 +- target/s390x/machine.c| 4 ++-- target/s390x/meson.build | 17 ++--- target/s390x/mmu_helper.c | 2 +- target/s390x/{internal.h => s390x-internal.h} | 6 ++ target/s390x/sigp.c | 2 +- target/s390x/{ => tcg}/cc_helper.c| 2 +- target/s390x/{ => tcg}/crypto_helper.c| 2 +- target/s390x/{ => tcg}/excp_helper.c | 2 +- target/s390x/{ => tcg}/fpu_helper.c | 2 +- target/s390x/{ => tcg}/insn-data.def | 0 target/s390x/{ => tcg}/insn-format.def| 0 target/s390x/{ => tcg}/int_helper.c | 2 +- target/s390x/{ => tcg}/mem_helper.c | 2 +- target/s390x/tcg/meson.build | 14 ++ target/s390x/{ => tcg}/misc_helper.c | 2 +- target/s390x/{ => tcg}/s390-tod.h | 0 target/s390x/{ => tcg}/tcg_s390x.h| 0 target/s390x/{ => tcg}/translate.c| 2 +- target/s390x/{ => tcg}/translate_vx.c.inc | 0 target/s390x/{ => tcg}/vec.h | 0 target/s390x/{ => tcg}/vec_fpu_helper.c | 2 +- target/s390x/{ => tcg}/vec_helper.c | 2 +- target/s390x/{ => tcg}/vec_int_helper.c | 0 target/s390x/{ => tcg}/vec_string_helper.c| 2 +- 35 files changed, 49 insertions(+), 42 deletions(-) rename target/s390x/{internal.h => s390x-internal.h} (98%) rename target/s390x/{ => tcg}/cc_helper.c (99%) rename target/s390x/{ => tcg}/crypto_helper.c (98%) rename target/s390x/{ => tcg}/excp_helper.c (99%) rename target/s390x/{ => tcg}/fpu_helper.c (99%) rename target/s390x/{ => tcg}/insn-data.def (100%) rename target/s390x/{ => tcg}/insn-format.def (100%) rename target/s390x/{ => tcg}/int_helper.c (99%) rename target/s390x/{ => tcg}/mem_helper.c (99%) create mode 100644 target/s390x/tcg/meson.build rename target/s390x/{ => tcg}/misc_helper.c (99%) rename target/s390x/{ => tcg}/s390-tod.h (100%) rename target/s390x/{ => tcg}/tcg_s390x.h (100%) rename target/s390x/{ => tcg}/translate.c (99%) rename target/s390x/{ => tcg}/translate_vx.c.inc (100%) rename target/s390x/{ => tcg}/vec.h (100%) rename target/s390x/{ => tcg}/vec_fpu_helper.c (99%) rename target/s390x/{ => tcg}/vec_helper.c (99%) rename target/s390x/{ => tcg}/vec_int_helper.c (100%) rename target/s390x/{ => tcg}/vec_string_helper.c (99%) diff --git a/hw/s390x/tod-tcg.c b/hw/s390x/tod-tcg.c index e91b9590f5..4b3e65050a 100644 --- a/hw/s390x/tod-tcg.c +++ b/hw/s390x/tod-tcg.c @@ -16,7 +16,7 @@ #include "qemu/cutils.h" #include "qemu/module.h" #include "cpu.h" -#include "tcg_s390x.h" +#include "tcg/tcg_s390x.h" static void qemu_s390_tod_get(const S390TODState *td, S390TOD *tod, Error **errp) diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h index ff3195a4bf..0935e85089 100644 --- a/include/hw/s390x/tod.h +++ b/include/hw/s390x/tod.h @@ -12,7 +12,7 @@ #define HW_S390_TOD_H #include "hw/qdev-core.h" -#include "target/s390x/s390-tod.h" +#include "tcg/s390-tod.h" #include "qom/object.h" typedef struct S390TOD { diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c index cc1330876b..08daf93ae1 100644 --- a/target/s390x/arch_dump.c +++ b/target/s390x/arch_dump.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "internal.h" +#include "s390x-internal.h" #include "elf.h" #include "sysemu/dump.h" diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 64455cf309..533b251b7e 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -23,7 +23,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "cpu.h" -#include "internal.h&quo
[RFC v4 03/14] hw/s390x: only build tod-tcg from the CONFIG_TCG build
this will allow in later patches to remove unneeded stubs in target/s390x. Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- hw/s390x/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index 02e81a9467..28484256ec 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -16,7 +16,6 @@ s390x_ss.add(files( 'sclp.c', 'sclpcpu.c', 'sclpquiesce.c', - 'tod-tcg.c', 'tod.c', )) s390x_ss.add(when: 'CONFIG_KVM', if_true: files( @@ -25,6 +24,9 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files( 's390-stattrib-kvm.c', 'pv.c', )) +s390x_ss.add(when: 'CONFIG_TCG', if_true: files( + 'tod-tcg.c', +)) s390x_ss.add(when: 'CONFIG_S390_CCW_VIRTIO', if_true: files('s390-virtio-ccw.c')) s390x_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('3270-ccw.c')) s390x_ss.add(when: 'CONFIG_VFIO', if_true: files('s390-pci-vfio.c')) -- 2.31.1
[RFC v4 04/14] hw/s390x: tod: make explicit checks for accelerators when initializing
replace general "else" with specific checks for each possible accelerator. Handle qtest as a NOP, and error out for an unknown accelerator used in combination with tod. Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- hw/s390x/tod.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/s390x/tod.c b/hw/s390x/tod.c index 3c2979175e..fd5a36bf24 100644 --- a/hw/s390x/tod.c +++ b/hw/s390x/tod.c @@ -14,6 +14,8 @@ #include "qemu/error-report.h" #include "qemu/module.h" #include "sysemu/kvm.h" +#include "sysemu/tcg.h" +#include "sysemu/qtest.h" #include "migration/qemu-file-types.h" #include "migration/register.h" @@ -23,8 +25,13 @@ void s390_init_tod(void) if (kvm_enabled()) { obj = object_new(TYPE_KVM_S390_TOD); -} else { +} else if (tcg_enabled()) { obj = object_new(TYPE_QEMU_S390_TOD); +} else if (qtest_enabled()) { +return; +} else { +error_report("current accelerator not handled in s390_init_tod!"); +abort(); } object_property_add_child(qdev_get_machine(), TYPE_S390_TOD, obj); object_unref(obj); -- 2.31.1
[RFC v4 05/14] target/s390x: remove tcg-stub.c
now that we protect all calls to the tcg-specific functions with if (tcg_enabled()), we do not need the TCG stub anymore. Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- target/s390x/meson.build | 2 +- target/s390x/tcg-stub.c | 30 -- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 target/s390x/tcg-stub.c diff --git a/target/s390x/meson.build b/target/s390x/meson.build index 1219f64112..a5e1ded93f 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -21,7 +21,7 @@ s390x_ss.add(when: 'CONFIG_TCG', if_true: files( 'vec_helper.c', 'vec_int_helper.c', 'vec_string_helper.c', -), if_false: files('tcg-stub.c')) +)) s390x_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c')) diff --git a/target/s390x/tcg-stub.c b/target/s390x/tcg-stub.c deleted file mode 100644 index d22c898802..00 --- a/target/s390x/tcg-stub.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * QEMU TCG support -- s390x specific function stubs. - * - * Copyright (C) 2018 Red Hat Inc - * - * Authors: - * 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. - */ - -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "cpu.h" -#include "tcg_s390x.h" - -void tcg_s390_tod_updated(CPUState *cs, run_on_cpu_data opaque) -{ -} -void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, - uint32_t code, uintptr_t ra) -{ -g_assert_not_reached(); -} -void QEMU_NORETURN tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc, - uintptr_t ra) -{ -g_assert_not_reached(); -} -- 2.31.1
[RFC v4 01/14] target/s390x: meson: add target_user_arch
the lack of target_user_arch makes it hard to fully leverage the build system in order to separate user code from sysemu code. Provide it, so that we can avoid the proliferation of #ifdef in target code. Signed-off-by: Claudio Fontana Signed-off-by: Cho, Yu-Chen --- target/s390x/meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/s390x/meson.build b/target/s390x/meson.build index c42eadb7d2..1219f64112 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -58,5 +58,8 @@ if host_machine.cpu_family() == 's390x' and cc.has_link_argument('-Wl,--s390-pgs if_true: declare_dependency(link_args: ['-Wl,--s390-pgste'])) endif +s390x_user_ss = ss.source_set() + target_arch += {'s390x': s390x_ss} target_softmmu_arch += {'s390x': s390x_softmmu_ss} +target_user_arch += {'s390x': s390x_user_ss} -- 2.31.1
[RFC v4 02/14] hw/s390x: rename tod-qemu.c to tod-tcg.c
we stop short of renaming the actual qom object though, so type remains TYPE_QEMU_S390_TOD, ie "s390-tod-qemu". Signed-off-by: Claudio Fontana Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Cho, Yu-Chen --- hw/s390x/meson.build | 2 +- hw/s390x/{tod-qemu.c => tod-tcg.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename hw/s390x/{tod-qemu.c => tod-tcg.c} (100%) diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index 327e9c93af..02e81a9467 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -16,7 +16,7 @@ s390x_ss.add(files( 'sclp.c', 'sclpcpu.c', 'sclpquiesce.c', - 'tod-qemu.c', + 'tod-tcg.c', 'tod.c', )) s390x_ss.add(when: 'CONFIG_KVM', if_true: files( diff --git a/hw/s390x/tod-qemu.c b/hw/s390x/tod-tcg.c similarity index 100% rename from hw/s390x/tod-qemu.c rename to hw/s390x/tod-tcg.c -- 2.31.1
[PATCH] gitlab-ci.yml: Add openSUSE Leap 15.2 for gitlab CI/CD
Add build-system-opensuse jobs and opensuse-leap.docker dockerfile. Use openSUSE Leap 15.2 container image in the gitlab-CI. Signed-off-by: Cho, Yu-Chen --- v4: Add package tar and fix python3 version from 3.8 to 3.6 Add acceptance-system-opensuse back. v3: Drop the "acceptance-system-opensuse" job part of the patch for now to get at least the basic compile-coverage v2: Drop some package from dockerfile to make docker image more light. v1: Add build-system-opensuse jobs and opensuse-leap.docker dockerfile. Use openSUSE Leap 15.2 container image in the gitlab-CI. --- .gitlab-ci.d/containers.yml | 5 ++ .gitlab-ci.yml| 31 +++ tests/docker/dockerfiles/opensuse-leap.docker | 55 +++ 3 files changed, 91 insertions(+) create mode 100644 tests/docker/dockerfiles/opensuse-leap.docker diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml index 892ca8d838..910754a699 100644 --- a/.gitlab-ci.d/containers.yml +++ b/.gitlab-ci.d/containers.yml @@ -246,3 +246,8 @@ amd64-ubuntu-container: <<: *container_job_definition variables: NAME: ubuntu + +amd64-opensuse-leap-container: + <<: *container_job_definition + variables: +NAME: opensuse-leap diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98bff03b47..fb65a2d29c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -195,6 +195,37 @@ acceptance-system-centos: MAKE_CHECK_ARGS: check-acceptance <<: *acceptance_definition +build-system-opensuse: + <<: *native_build_job_definition + variables: +IMAGE: opensuse-leap +TARGETS: s390x-softmmu x86_64-softmmu aarch64-softmmu +MAKE_CHECK_ARGS: check-build + artifacts: +expire_in: 2 days +paths: + - build + +check-system-opensuse: + <<: *native_test_job_definition + needs: +- job: build-system-opensuse + artifacts: true + variables: +IMAGE: opensuse-leap +MAKE_CHECK_ARGS: check + +acceptance-system-opensuse: + <<: *native_test_job_definition + needs: + - job: build-system-opensuse + artifacts: true + variables: + IMAGE: opensuse-leap + MAKE_CHECK_ARGS: check-acceptance + <<: *acceptance_definition + + build-disabled: <<: *native_build_job_definition variables: diff --git a/tests/docker/dockerfiles/opensuse-leap.docker b/tests/docker/dockerfiles/opensuse-leap.docker new file mode 100644 index 00..0e64893e4a --- /dev/null +++ b/tests/docker/dockerfiles/opensuse-leap.docker @@ -0,0 +1,55 @@ +FROM opensuse/leap:15.2 + +# Please keep this list sorted alphabetically +ENV PACKAGES \ +bc \ +brlapi-devel \ +bzip2 \ +cyrus-sasl-devel \ +gcc \ +gcc-c++ \ +mkisofs \ +gettext-runtime \ +git \ +glib2-devel \ +glusterfs-devel \ +libgnutls-devel \ +gtk3-devel \ +libaio-devel \ +libattr-devel \ +libcap-ng-devel \ +libepoxy-devel \ +libfdt-devel \ +libiscsi-devel \ +libjpeg8-devel \ +libpmem-devel \ +libpng16-devel \ +librbd-devel \ +libseccomp-devel \ +libssh-devel \ +lzo-devel \ +make \ +libSDL2_image-devel \ +ncurses-devel \ +ninja \ +libnuma-devel \ +perl \ +libpixman-1-0-devel \ +python3-base \ +python3-virtualenv \ +rdma-core-devel \ +libSDL2-devel \ +snappy-devel \ +libspice-server-devel \ +systemd-devel \ +systemtap-sdt-devel \ +tar \ +usbredir-devel \ +virglrenderer-devel \ +xen-devel \ +vte-devel \ +zlib-devel +ENV QEMU_CONFIGURE_OPTS --python=/usr/bin/python3.6 + +RUN zypper update -y && zypper --non-interactive install -y $PACKAGES +RUN rpm -q $PACKAGES | sort > /packages.txt -- 2.29.2
[PATCH v3] gitlab-ci.yml: Add openSUSE Leap 15.2 for gitlab CI/CD
Add build-system-opensuse jobs and opensuse-leap.docker dockerfile. Use openSUSE Leap 15.2 container image in the gitlab-CI. Signed-off-by: Cho, Yu-Chen --- v3: Drop the "acceptance-system-opensuse" job part of the patch for now to get at least the basic compile-coverage v2: Drop some package from dockerfile to make docker image more light. v1: Add build-system-opensuse jobs and opensuse-leap.docker dockerfile. Use openSUSE Leap 15.2 container image in the gitlab-CI. --- .gitlab-ci.d/containers.yml | 5 ++ .gitlab-ci.yml| 20 +++ tests/docker/dockerfiles/opensuse-leap.docker | 54 +++ 3 files changed, 79 insertions(+) create mode 100644 tests/docker/dockerfiles/opensuse-leap.docker diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml index 892ca8d838..910754a699 100644 --- a/.gitlab-ci.d/containers.yml +++ b/.gitlab-ci.d/containers.yml @@ -246,3 +246,8 @@ amd64-ubuntu-container: <<: *container_job_definition variables: NAME: ubuntu + +amd64-opensuse-leap-container: + <<: *container_job_definition + variables: +NAME: opensuse-leap diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98bff03b47..a1df981c9a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -195,6 +195,26 @@ acceptance-system-centos: MAKE_CHECK_ARGS: check-acceptance <<: *acceptance_definition +build-system-opensuse: + <<: *native_build_job_definition + variables: +IMAGE: opensuse-leap +TARGETS: s390x-softmmu x86_64-softmmu aarch64-softmmu +MAKE_CHECK_ARGS: check-build + artifacts: +expire_in: 2 days +paths: + - build + +check-system-opensuse: + <<: *native_test_job_definition + needs: +- job: build-system-opensuse + artifacts: true + variables: +IMAGE: opensuse-leap +MAKE_CHECK_ARGS: check + build-disabled: <<: *native_build_job_definition variables: diff --git a/tests/docker/dockerfiles/opensuse-leap.docker b/tests/docker/dockerfiles/opensuse-leap.docker new file mode 100644 index 00..8b0d915bff --- /dev/null +++ b/tests/docker/dockerfiles/opensuse-leap.docker @@ -0,0 +1,54 @@ +FROM opensuse/leap:15.2 + +# Please keep this list sorted alphabetically +ENV PACKAGES \ +bc \ +brlapi-devel \ +bzip2 \ +cyrus-sasl-devel \ +gcc \ +gcc-c++ \ +mkisofs \ +gettext-runtime \ +git \ +glib2-devel \ +glusterfs-devel \ +libgnutls-devel \ +gtk3-devel \ +libaio-devel \ +libattr-devel \ +libcap-ng-devel \ +libepoxy-devel \ +libfdt-devel \ +libiscsi-devel \ +libjpeg8-devel \ +libpmem-devel \ +libpng16-devel \ +librbd-devel \ +libseccomp-devel \ +libssh-devel \ +lzo-devel \ +make \ +libSDL2_image-devel \ +ncurses-devel \ +ninja \ +libnuma-devel \ +perl \ +libpixman-1-0-devel \ +python3-base \ +python3-virtualenv \ +rdma-core-devel \ +libSDL2-devel \ +snappy-devel \ +libspice-server-devel \ +systemd-devel \ +systemtap-sdt-devel \ +usbredir-devel \ +virglrenderer-devel \ +xen-devel \ +vte-devel \ +zlib-devel +ENV QEMU_CONFIGURE_OPTS --python=/usr/bin/python3.8 + +RUN zypper update -y && zypper --non-interactive install -y $PACKAGES +RUN rpm -q $PACKAGES | sort > /packages.txt -- 2.29.2
Re: [PATCH v2] gitlab-ci.yml: Add openSUSE Leap 15.2 for gitlab CI/CD
Hi Thomas, Sorry for late reply, Thomas Huth 於 2020年12月18日 週五 下午7:14寫道: > > On 11/12/2020 14.09, Thomas Huth wrote: > > On 10/12/2020 10.32, AL Yu-Chen Cho wrote: > >> Hi Thomas, > >> > >> I try to reproduce this failed in my repo, but it seems works fine. > >> Would you please give it a try again? I think you maybe just hit a bad > >> point in time... > > > > I just re-tried, but it still fails for me: > > > > https://gitlab.com/huth/qemu/-/jobs/905376471 > > > > Did you also rebase your branch to the latest master version? > > I just gave it yet another try to really rule out that it was not a > temporary problem, but the "acceptance" job still fails for me: > > https://gitlab.com/huth/qemu/-/jobs/920543768 > > Would it make sense to drop the "acceptance-system-opensuse" job part of the > patch for now to get at least the basic compile-coverage in? > Yes, I tried to fix the "acceptance-system-opensuse" error but still got weird error in: VENV /builds/huth/qemu/build/tests/venv 57Error: Command '['/builds/huth/qemu/build/tests/venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1. So I will submit the v3 to drop it for now, thanks a lot. Cheers, AL > Thomas > >
[PATCH v2] gitlab-ci.yml: Add openSUSE Leap 15.2 for gitlab CI/CD
v2: Drop some package from dockerfile to make docker image more light. v1: Add build-system-opensuse jobs and opensuse-leap.docker dockerfile. Use openSUSE Leap 15.2 container image in the gitlab-CI. Signed-off-by: Cho, Yu-Chen --- .gitlab-ci.d/containers.yml | 5 ++ .gitlab-ci.yml| 30 +++ tests/docker/dockerfiles/opensuse-leap.docker | 54 +++ 3 files changed, 89 insertions(+) create mode 100644 tests/docker/dockerfiles/opensuse-leap.docker diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml index 892ca8d838..910754a699 100644 --- a/.gitlab-ci.d/containers.yml +++ b/.gitlab-ci.d/containers.yml @@ -246,3 +246,8 @@ amd64-ubuntu-container: <<: *container_job_definition variables: NAME: ubuntu + +amd64-opensuse-leap-container: + <<: *container_job_definition + variables: +NAME: opensuse-leap diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0173e82b1..6a256fe07b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -195,6 +195,36 @@ acceptance-system-centos: MAKE_CHECK_ARGS: check-acceptance <<: *acceptance_definition +build-system-opensuse: + <<: *native_build_job_definition + variables: +IMAGE: opensuse-leap +TARGETS: s390x-softmmu x86_64-softmmu aarch64-softmmu +MAKE_CHECK_ARGS: check-build + artifacts: +expire_in: 2 days +paths: + - build + +check-system-opensuse: + <<: *native_test_job_definition + needs: +- job: build-system-opensuse + artifacts: true + variables: +IMAGE: opensuse-leap +MAKE_CHECK_ARGS: check + +acceptance-system-opensuse: + <<: *native_test_job_definition + needs: +- job: build-system-opensuse + artifacts: true + variables: +IMAGE: opensuse-leap +MAKE_CHECK_ARGS: check-acceptance + <<: *acceptance_definition + build-disabled: <<: *native_build_job_definition variables: diff --git a/tests/docker/dockerfiles/opensuse-leap.docker b/tests/docker/dockerfiles/opensuse-leap.docker new file mode 100644 index 00..8b0d915bff --- /dev/null +++ b/tests/docker/dockerfiles/opensuse-leap.docker @@ -0,0 +1,54 @@ +FROM opensuse/leap:15.2 + +# Please keep this list sorted alphabetically +ENV PACKAGES \ +bc \ +brlapi-devel \ +bzip2 \ +cyrus-sasl-devel \ +gcc \ +gcc-c++ \ +mkisofs \ +gettext-runtime \ +git \ +glib2-devel \ +glusterfs-devel \ +libgnutls-devel \ +gtk3-devel \ +libaio-devel \ +libattr-devel \ +libcap-ng-devel \ +libepoxy-devel \ +libfdt-devel \ +libiscsi-devel \ +libjpeg8-devel \ +libpmem-devel \ +libpng16-devel \ +librbd-devel \ +libseccomp-devel \ +libssh-devel \ +lzo-devel \ +make \ +libSDL2_image-devel \ +ncurses-devel \ +ninja \ +libnuma-devel \ +perl \ +libpixman-1-0-devel \ +python3-base \ +python3-virtualenv \ +rdma-core-devel \ +libSDL2-devel \ +snappy-devel \ +libspice-server-devel \ +systemd-devel \ +systemtap-sdt-devel \ +usbredir-devel \ +virglrenderer-devel \ +xen-devel \ +vte-devel \ +zlib-devel +ENV QEMU_CONFIGURE_OPTS --python=/usr/bin/python3.8 + +RUN zypper update -y && zypper --non-interactive install -y $PACKAGES +RUN rpm -q $PACKAGES | sort > /packages.txt -- 2.29.2
[PATCH v2] gitlab-ci.yml: Add openSUSE Leap 15.2 for gitlab CI/CD
v2: Drop some package from dockerfile to make docker image more light. v1: Add build-system-opensuse jobs and opensuse-leap.docker dockerfile. Use openSUSE Leap 15.2 container image in the gitlab-CI. Signed-off-by: Cho, Yu-Chen --- .gitlab-ci.d/containers.yml | 5 ++ .gitlab-ci.yml| 30 +++ tests/docker/dockerfiles/opensuse-leap.docker | 54 +++ 3 files changed, 89 insertions(+) create mode 100644 tests/docker/dockerfiles/opensuse-leap.docker diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml index 892ca8d838..910754a699 100644 --- a/.gitlab-ci.d/containers.yml +++ b/.gitlab-ci.d/containers.yml @@ -246,3 +246,8 @@ amd64-ubuntu-container: <<: *container_job_definition variables: NAME: ubuntu + +amd64-opensuse-leap-container: + <<: *container_job_definition + variables: +NAME: opensuse-leap diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0173e82b1..6a256fe07b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -195,6 +195,36 @@ acceptance-system-centos: MAKE_CHECK_ARGS: check-acceptance <<: *acceptance_definition +build-system-opensuse: + <<: *native_build_job_definition + variables: +IMAGE: opensuse-leap +TARGETS: s390x-softmmu x86_64-softmmu aarch64-softmmu +MAKE_CHECK_ARGS: check-build + artifacts: +expire_in: 2 days +paths: + - build + +check-system-opensuse: + <<: *native_test_job_definition + needs: +- job: build-system-opensuse + artifacts: true + variables: +IMAGE: opensuse-leap +MAKE_CHECK_ARGS: check + +acceptance-system-opensuse: + <<: *native_test_job_definition + needs: +- job: build-system-opensuse + artifacts: true + variables: +IMAGE: opensuse-leap +MAKE_CHECK_ARGS: check-acceptance + <<: *acceptance_definition + build-disabled: <<: *native_build_job_definition variables: diff --git a/tests/docker/dockerfiles/opensuse-leap.docker b/tests/docker/dockerfiles/opensuse-leap.docker new file mode 100644 index 00..8b0d915bff --- /dev/null +++ b/tests/docker/dockerfiles/opensuse-leap.docker @@ -0,0 +1,54 @@ +FROM opensuse/leap:15.2 + +# Please keep this list sorted alphabetically +ENV PACKAGES \ +bc \ +brlapi-devel \ +bzip2 \ +cyrus-sasl-devel \ +gcc \ +gcc-c++ \ +mkisofs \ +gettext-runtime \ +git \ +glib2-devel \ +glusterfs-devel \ +libgnutls-devel \ +gtk3-devel \ +libaio-devel \ +libattr-devel \ +libcap-ng-devel \ +libepoxy-devel \ +libfdt-devel \ +libiscsi-devel \ +libjpeg8-devel \ +libpmem-devel \ +libpng16-devel \ +librbd-devel \ +libseccomp-devel \ +libssh-devel \ +lzo-devel \ +make \ +libSDL2_image-devel \ +ncurses-devel \ +ninja \ +libnuma-devel \ +perl \ +libpixman-1-0-devel \ +python3-base \ +python3-virtualenv \ +rdma-core-devel \ +libSDL2-devel \ +snappy-devel \ +libspice-server-devel \ +systemd-devel \ +systemtap-sdt-devel \ +usbredir-devel \ +virglrenderer-devel \ +xen-devel \ +vte-devel \ +zlib-devel +ENV QEMU_CONFIGURE_OPTS --python=/usr/bin/python3.8 + +RUN zypper update -y && zypper --non-interactive install -y $PACKAGES +RUN rpm -q $PACKAGES | sort > /packages.txt -- 2.29.2
[PATCH] gitlab-ci.yml: Add openSUSE Leap 15.2 for gitlab CI/CD
Add build-system-opensuse jobs and add opensuse-leap.docker dockerfile. Use openSUSE Leap 15.2 container image in the gitlab-CI. Signed-off-by: Cho, Yu-Chen --- .gitlab-ci.d/containers.yml | 5 ++ .gitlab-ci.yml| 30 +++ tests/docker/dockerfiles/opensuse-leap.docker | 88 +++ 3 files changed, 123 insertions(+) create mode 100644 tests/docker/dockerfiles/opensuse-leap.docker diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml index 11d079ea58..082624a6fa 100644 --- a/.gitlab-ci.d/containers.yml +++ b/.gitlab-ci.d/containers.yml @@ -246,3 +246,8 @@ amd64-ubuntu-container: <<: *container_job_definition variables: NAME: ubuntu + +amd64-opensuse-leap-container: + <<: *container_job_definition + variables: +NAME: opensuse-leap diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a8b375188..bf4759296a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -195,6 +195,36 @@ acceptance-system-centos: MAKE_CHECK_ARGS: check-acceptance <<: *acceptance_definition +build-system-opensuse: + <<: *native_build_job_definition + variables: +IMAGE: opensuse-leap +TARGETS: s390x-softmmu x86_64-softmmu aarch64-softmmu +MAKE_CHECK_ARGS: check-build + artifacts: +expire_in: 2 days +paths: + - build + +check-system-opensuse: + <<: *native_test_job_definition + needs: +- job: build-system-opensuse + artifacts: true + variables: +IMAGE: opensuse-leap +MAKE_CHECK_ARGS: check + +acceptance-system-opensuse: + <<: *native_test_job_definition + needs: +- job: build-system-opensuse + artifacts: true + variables: +IMAGE: opensuse-leap +MAKE_CHECK_ARGS: check-acceptance + <<: *acceptance_definition + build-disabled: <<: *native_build_job_definition variables: diff --git a/tests/docker/dockerfiles/opensuse-leap.docker b/tests/docker/dockerfiles/opensuse-leap.docker new file mode 100644 index 00..712eb4fe3a --- /dev/null +++ b/tests/docker/dockerfiles/opensuse-leap.docker @@ -0,0 +1,88 @@ +FROM opensuse/leap:15.2 + +RUN zypper update -y + +# Please keep this list sorted alphabetically +ENV PACKAGES \ +bc \ +brlapi-devel \ +bzip2 \ +libzip-devel \ +ccache \ +clang \ +cyrus-sasl-devel \ +dbus-1 \ +device-mapper-devel \ +gcc \ +gcc-c++ \ +mkisofs \ +gettext-runtime \ +git \ +glib2-devel \ +glusterfs-devel \ +libgnutls-devel \ +gtk3-devel \ +hostname \ +libaio-devel \ +libasan5 \ +libattr-devel \ +libblockdev-devel \ +libcap-ng-devel \ +libcurl-devel \ +libepoxy-devel \ +libfdt-devel \ +libiscsi-devel \ +libjpeg8-devel \ +libpmem-devel \ +libpng16-devel \ +librbd-devel \ +libseccomp-devel \ +libssh-devel \ +libubsan0 \ +libudev-devel \ +libxml2-devel \ +libzstd-devel \ +llvm \ +lzo-devel \ +make \ +mingw32-filesystem \ +glibc-devel-32bit \ +libSDL2_image-devel \ +mingw64-binutils \ +nmap \ +ncat \ +ncurses-devel \ +libnettle-devel \ +ninja \ +mozilla-nss-devel \ +libnuma-devel \ +perl \ +libpixman-1-0-devel \ +python3-base \ +python3-PyYAML \ +python3-numpy \ +python3-opencv \ +python3-Pillow \ +python3-pip \ +python3-Sphinx \ +python3-virtualenv \ +rdma-core-devel \ +libSDL2-devel \ +snappy-devel \ +sparse \ +libspice-server-devel \ +systemd-devel \ +systemtap-sdt-devel \ +tar \ +tesseract-ocr \ +tesseract-ocr-traineddata-english \ +usbredir-devel \ +virglrenderer-devel \ +libvte-2_91-0 \ +which \ +xen-devel \ +zlib-devel +ENV QEMU_CONFIGURE_OPTS --python=/usr/bin/python3.8 + +RUN zypper --non-interactive install -y $PACKAGES +RUN rpm -q $PACKAGES | sort > /packages.txt -- 2.29.2