Browse Source
- add gen16 cpumodels - refactor/cleanup some code - bugfixes -----BEGIN PGP SIGNATURE----- iIgEABYIADAWIQRpo7U29cv8ZSCAJsHeiLtWQd5mwQUCYObg3RIcY29odWNrQHJl ZGhhdC5jb20ACgkQ3oi7VkHeZsGAdAD/dSZkhfgjNWJjka0hmnyQyNCSzq6jox1L PccGyqhkqU8BAM4DUa2bZdst8bLfhUuAA0M5gKkCqkzHdDraBqTL8LQJ =H7dn -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/cohuck-gitlab/tags/s390x-20210708' into staging s390x updates: - add gen16 cpumodels - refactor/cleanup some code - bugfixes # gpg: Signature made Thu 08 Jul 2021 12:26:21 BST # gpg: using EDDSA key 69A3B536F5CBFC65208026C1DE88BB5641DE66C1 # gpg: issuer "cohuck@redhat.com" # gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>" [unknown] # gpg: aka "Cornelia Huck <huckc@linux.vnet.ibm.com>" [full] # gpg: aka "Cornelia Huck <cornelia.huck@de.ibm.com>" [full] # gpg: aka "Cornelia Huck <cohuck@kernel.org>" [unknown] # gpg: aka "Cornelia Huck <cohuck@redhat.com>" [unknown] # Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0 18CE DECF 6B93 C6F0 2FAF # Subkey fingerprint: 69A3 B536 F5CB FC65 2080 26C1 DE88 BB56 41DE 66C1 * remotes/cohuck-gitlab/tags/s390x-20210708: target/s390x: split sysemu part of cpu models target/s390x: move kvm files into kvm/ target/s390x: remove kvm-stub.c target/s390x: use kvm_enabled() to wrap call to kvm_s390_get_hpage_1m target/s390x: make helper.c sysemu-only target/s390x: split cpu-dump from helper.c target/s390x: move sysemu-only code out to cpu-sysemu.c target/s390x: start moving TCG-only code to tcg/ target/s390x: rename internal.h to s390x-internal.h target/s390x: remove tcg-stub.c hw/s390x: only build tod-tcg from the CONFIG_TCG build hw/s390x: tod: make explicit checks for accelerators when initializing hw/s390x: rename tod-qemu.c to tod-tcg.c target/s390x: meson: add target_user_arch s390x/tcg: Fix m5 vs. m4 field for VECTOR MULTIPLY SUM LOGICAL target/s390x: Fix CC set by CONVERT TO FIXED/LOGICAL s390x/cpumodel: add 3931 and 3932 Signed-off-by: Peter Maydell <peter.maydell@linaro.org>pull/121/head
57 changed files with 1167 additions and 1127 deletions
@ -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 = &cpu->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_32] = "CC_OP_ABS_32", |
|||
[CC_OP_NABS_32] = "CC_OP_NABS_32", |
|||
[CC_OP_COMP_32] = "CC_OP_COMP_32", |
|||
[CC_OP_COMP_64] = "CC_OP_COMP_64", |
|||
[CC_OP_TM_32] = "CC_OP_TM_32", |
|||
[CC_OP_TM_64] = "CC_OP_TM_64", |
|||
[CC_OP_NZ_F32] = "CC_OP_NZ_F32", |
|||
[CC_OP_NZ_F64] = "CC_OP_NZ_F64", |
|||
[CC_OP_NZ_F128] = "CC_OP_NZ_F128", |
|||
[CC_OP_ICM] = "CC_OP_ICM", |
|||
[CC_OP_SLA_32] = "CC_OP_SLA_32", |
|||
[CC_OP_SLA_64] = "CC_OP_SLA_64", |
|||
[CC_OP_FLOGR] = "CC_OP_FLOGR", |
|||
[CC_OP_LCBB] = "CC_OP_LCBB", |
|||
[CC_OP_VC] = "CC_OP_VC", |
|||
[CC_OP_MULS_32] = "CC_OP_MULS_32", |
|||
[CC_OP_MULS_64] = "CC_OP_MULS_64", |
|||
}; |
|||
|
|||
return cc_names[cc_op]; |
|||
} |
|||
@ -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/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", &panic_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) { |
|||
error_setg(errp, "Unable to add CPU with core-id: %" PRIu32 |
|||
", maximum core-id: %d", cpu->env.core_id, |
|||
max_cpus - 1); |
|||
return false; |
|||
} |
|||
|
|||
if (cpu_exists(cpu->env.core_id)) { |
|||
error_setg(errp, "Unable to add CPU with core-id: %" PRIu32 |
|||
", it already exists", cpu->env.core_id); |
|||
return false; |
|||
} |
|||
|
|||
/* sync cs->cpu_index and env->core_id. The latter is needed for TCG. */ |
|||
CPU(cpu)->cpu_index = cpu->env.core_id; |
|||
return true; |
|||
} |
|||
|
|||
void s390_cpu_finalize(Object *obj) |
|||
{ |
|||
S390CPU *cpu = S390_CPU(obj); |
|||
|
|||
timer_free(cpu->env.tod_timer); |
|||
timer_free(cpu->env.cpu_timer); |
|||
|
|||
qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu); |
|||
g_free(cpu->irqstate); |
|||
} |
|||
|
|||
static const struct SysemuCPUOps s390_sysemu_ops = { |
|||
.get_phys_page_debug = s390_cpu_get_phys_page_debug, |
|||
.get_crash_info = s390_cpu_get_crash_info, |
|||
.write_elf64_note = s390_cpu_write_elf64_note, |
|||
.legacy_vmsd = &vmstate_s390_cpu, |
|||
}; |
|||
|
|||
void s390_cpu_class_init_sysemu(CPUClass *cc) |
|||
{ |
|||
S390CPUClass *scc = S390_CPU_CLASS(cc); |
|||
|
|||
scc->load_normal = s390_cpu_load_normal; |
|||
cc->sysemu_ops = &s390_sysemu_ops; |
|||
} |
|||
|
|||
static bool disabled_wait(CPUState *cpu) |
|||
{ |
|||
return cpu->halted && !(S390_CPU(cpu)->env.psw.mask & |
|||
(PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK)); |
|||
} |
|||
|
|||
static unsigned s390_count_running_cpus(void) |
|||
{ |
|||
CPUState *cpu; |
|||
int nr_running = 0; |
|||
|
|||
CPU_FOREACH(cpu) { |
|||
uint8_t state = S390_CPU(cpu)->env.cpu_state; |
|||
if (state == S390_CPU_STATE_OPERATING || |
|||
state == S390_CPU_STATE_LOAD) { |
|||
if (!disabled_wait(cpu)) { |
|||
nr_running++; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return nr_running; |
|||
} |
|||
|
|||
unsigned int s390_cpu_halt(S390CPU *cpu) |
|||
{ |
|||
CPUState *cs = CPU(cpu); |
|||
trace_cpu_halt(cs->cpu_index); |
|||
|
|||
if (!cs->halted) { |
|||
cs->halted = 1; |
|||
cs->exception_index = EXCP_HLT; |
|||
} |
|||
|
|||
return s390_count_running_cpus(); |
|||
} |
|||
|
|||
void s390_cpu_unhalt(S390CPU *cpu) |
|||
{ |
|||
CPUState *cs = CPU(cpu); |
|||
trace_cpu_unhalt(cs->cpu_index); |
|||
|
|||
if (cs->halted) { |
|||
cs->halted = 0; |
|||
cs->exception_index = -1; |
|||
} |
|||
} |
|||
|
|||
unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu) |
|||
{ |
|||
trace_cpu_set_state(CPU(cpu)->cpu_index, cpu_state); |
|||
|
|||
switch (cpu_state) { |
|||
case S390_CPU_STATE_STOPPED: |
|||
case S390_CPU_STATE_CHECK_STOP: |
|||
/* halt the cpu for common infrastructure */ |
|||
s390_cpu_halt(cpu); |
|||
break; |
|||
case S390_CPU_STATE_OPERATING: |
|||
case S390_CPU_STATE_LOAD: |
|||
/*
|
|||
* Starting a CPU with a PSW WAIT bit set: |
|||
* KVM: handles this internally and triggers another WAIT exit. |
|||
* TCG: will actually try to continue to run. Don't unhalt, will |
|||
* be done when the CPU actually has work (an interrupt). |
|||
*/ |
|||
if (!tcg_enabled() || !(cpu->env.psw.mask & PSW_MASK_WAIT)) { |
|||
s390_cpu_unhalt(cpu); |
|||
} |
|||
break; |
|||
default: |
|||
error_report("Requested CPU state is not a valid S390 CPU state: %u", |
|||
cpu_state); |
|||
exit(1); |
|||
} |
|||
if (kvm_enabled() && cpu->env.cpu_state != cpu_state) { |
|||
kvm_s390_set_cpu_state(cpu, cpu_state); |
|||
} |
|||
cpu->env.cpu_state = cpu_state; |
|||
|
|||
return s390_count_running_cpus(); |
|||
} |
|||
|
|||
int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit) |
|||
{ |
|||
if (kvm_enabled()) { |
|||
return kvm_s390_set_mem_limit(new_limit, hw_limit); |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
void s390_set_max_pagesize(uint64_t pagesize, Error **errp) |
|||
{ |
|||
if (kvm_enabled()) { |
|||
kvm_s390_set_max_pagesize(pagesize, errp); |
|||
} |
|||
} |
|||
|
|||
void s390_cmma_reset(void) |
|||
{ |
|||
if (kvm_enabled()) { |
|||
kvm_s390_cmma_reset(); |
|||
} |
|||
} |
|||
|
|||
int s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch_id, |
|||
int vq, bool assign) |
|||
{ |
|||
if (kvm_enabled()) { |
|||
return kvm_s390_assign_subch_ioeventfd(notifier, sch_id, vq, assign); |
|||
} else { |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
void s390_crypto_reset(void) |
|||
{ |
|||
if (kvm_enabled()) { |
|||
kvm_s390_crypto_reset(); |
|||
} |
|||
} |
|||
|
|||
void s390_enable_css_support(S390CPU *cpu) |
|||
{ |
|||
if (kvm_enabled()) { |
|||
kvm_s390_enable_css_support(cpu); |
|||
} |
|||
} |
|||
|
|||
void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_data arg) |
|||
{ |
|||
if (kvm_enabled()) { |
|||
kvm_s390_set_diag318(cs, arg.host_ulong); |
|||
} |
|||
} |
|||
@ -0,0 +1,426 @@ |
|||
/*
|
|||
* CPU models for s390x - System Emulation-only |
|||
* |
|||
* Copyright 2016 IBM Corp. |
|||
* |
|||
* Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com> |
|||
* |
|||
* This work is licensed under the terms of the GNU GPL, version 2 or (at |
|||
* your option) any later version. See the COPYING file in the top-level |
|||
* directory. |
|||
*/ |
|||
|
|||
#include "qemu/osdep.h" |
|||
#include "cpu.h" |
|||
#include "s390x-internal.h" |
|||
#include "kvm/kvm_s390x.h" |
|||
#include "sysemu/kvm.h" |
|||
#include "sysemu/tcg.h" |
|||
#include "qapi/error.h" |
|||
#include "qapi/visitor.h" |
|||
#include "qapi/qmp/qerror.h" |
|||
#include "qapi/qobject-input-visitor.h" |
|||
#include "qapi/qmp/qdict.h" |
|||
#include "qapi/qapi-commands-machine-target.h" |
|||
|
|||
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 = &cpu_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, |
|||
&info->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, |
|||
&list_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()) { |
|||
error_setg(errp, "The CPU definition '%s' requires KVM", info->name); |
|||
return; |
|||
} |
|||
obj = object_new_with_class(oc); |
|||
cpu = S390_CPU(obj); |
|||
|
|||
if (!cpu->model) { |
|||
error_setg(errp, "Details about the host CPU model are not available, " |
|||
"it cannot be used."); |
|||
object_unref(obj); |
|||
return; |
|||
} |
|||
|
|||
if (qdict) { |
|||
visitor = qobject_input_visitor_new(info->props); |
|||
if (!visit_start_struct(visitor, NULL, NULL, 0, errp)) { |
|||
visit_free(visitor); |
|||
object_unref(obj); |
|||
return; |
|||
} |
|||
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) { |
|||
if (!object_property_set(obj, e->key, visitor, &err)) { |
|||
break; |
|||
} |
|||
} |
|||
if (!err) { |
|||
visit_check_struct(visitor, &err); |
|||
} |
|||
visit_end_struct(visitor, NULL); |
|||
visit_free(visitor); |
|||
if (err) { |
|||
error_propagate(errp, err); |
|||
object_unref(obj); |
|||
return; |
|||
} |
|||
} |
|||
|
|||
/* copy the model and throw the cpu away */ |
|||
memcpy(model, cpu->model, sizeof(*model)); |
|||
object_unref(obj); |
|||
} |
|||
|
|||
static void qdict_add_disabled_feat(const char *name, void *opaque) |
|||
{ |
|||
qdict_put_bool(opaque, name, false); |
|||
} |
|||
|
|||
static void qdict_add_enabled_feat(const char *name, void *opaque) |
|||
{ |
|||
qdict_put_bool(opaque, name, true); |
|||
} |
|||
|
|||
/* convert S390CPUDef into a static CpuModelInfo */ |
|||
static void cpu_info_from_model(CpuModelInfo *info, const S390CPUModel *model, |
|||
bool delta_changes) |
|||
{ |
|||
QDict *qdict = qdict_new(); |
|||
S390FeatBitmap bitmap; |
|||
|
|||
/* always fallback to the static base model */ |
|||
info->name = g_strdup_printf("%s-base", model->def->name); |
|||
|
|||
if (delta_changes) { |
|||
/* features deleted from the base feature set */ |
|||
bitmap_andnot(bitmap, model->def->base_feat, model->features, |
|||
S390_FEAT_MAX); |
|||
if (!bitmap_empty(bitmap, S390_FEAT_MAX)) { |
|||
s390_feat_bitmap_to_ascii(bitmap, qdict, qdict_add_disabled_feat); |
|||
} |
|||
|
|||
/* features added to the base feature set */ |
|||
bitmap_andnot(bitmap, model->features, model->def->base_feat, |
|||
S390_FEAT_MAX); |
|||
if (!bitmap_empty(bitmap, S390_FEAT_MAX)) { |
|||
s390_feat_bitmap_to_ascii(bitmap, qdict, qdict_add_enabled_feat); |
|||
} |
|||
} else { |
|||
/* expand all features */ |
|||
s390_feat_bitmap_to_ascii(model->features, qdict, |
|||
qdict_add_enabled_feat); |
|||
bitmap_complement(bitmap, model->features, S390_FEAT_MAX); |
|||
s390_feat_bitmap_to_ascii(bitmap, qdict, qdict_add_disabled_feat); |
|||
} |
|||
|
|||
if (!qdict_size(qdict)) { |
|||
qobject_unref(qdict); |
|||
} else { |
|||
info->props = QOBJECT(qdict); |
|||
info->has_props = true; |
|||
} |
|||
} |
|||
|
|||
CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, |
|||
CpuModelInfo *model, |
|||
Error **errp) |
|||
{ |
|||
Error *err = NULL; |
|||
CpuModelExpansionInfo *expansion_info = NULL; |
|||
S390CPUModel s390_model; |
|||
bool delta_changes = false; |
|||
|
|||
/* convert it to our internal representation */ |
|||
cpu_model_from_info(&s390_model, model, &err); |
|||
if (err) { |
|||
error_propagate(errp, err); |
|||
return NULL; |
|||
} |
|||
|
|||
if (type == CPU_MODEL_EXPANSION_TYPE_STATIC) { |
|||
delta_changes = true; |
|||
} else if (type != CPU_MODEL_EXPANSION_TYPE_FULL) { |
|||
error_setg(errp, "The requested expansion type is not supported."); |
|||
return NULL; |
|||
} |
|||
|
|||
/* convert it back to a static representation */ |
|||
expansion_info = g_new0(CpuModelExpansionInfo, 1); |
|||
expansion_info->model = g_malloc0(sizeof(*expansion_info->model)); |
|||
cpu_info_from_model(expansion_info->model, &s390_model, delta_changes); |
|||
return expansion_info; |
|||
} |
|||
|
|||
static void list_add_feat(const char *name, void *opaque) |
|||
{ |
|||
strList **last = (strList **) opaque; |
|||
|
|||
QAPI_LIST_PREPEND(*last, g_strdup(name)); |
|||
} |
|||
|
|||
CpuModelCompareInfo *qmp_query_cpu_model_comparison(CpuModelInfo *infoa, |
|||
CpuModelInfo *infob, |
|||
Error **errp) |
|||
{ |
|||
Error *err = NULL; |
|||
CpuModelCompareResult feat_result, gen_result; |
|||
CpuModelCompareInfo *compare_info; |
|||
S390FeatBitmap missing, added; |
|||
S390CPUModel modela, modelb; |
|||
|
|||
/* convert both models to our internal representation */ |
|||
cpu_model_from_info(&modela, infoa, &err); |
|||
if (err) { |
|||
error_propagate(errp, err); |
|||
return NULL; |
|||
} |
|||
cpu_model_from_info(&modelb, infob, &err); |
|||
if (err) { |
|||
error_propagate(errp, err); |
|||
return NULL; |
|||
} |
|||
compare_info = g_new0(CpuModelCompareInfo, 1); |
|||
|
|||
/* check the cpu generation and ga level */ |
|||
if (modela.def->gen == modelb.def->gen) { |
|||
if (modela.def->ec_ga == modelb.def->ec_ga) { |
|||
/* ec and corresponding bc are identical */ |
|||
gen_result = CPU_MODEL_COMPARE_RESULT_IDENTICAL; |
|||
} else if (modela.def->ec_ga < modelb.def->ec_ga) { |
|||
gen_result = CPU_MODEL_COMPARE_RESULT_SUBSET; |
|||
} else { |
|||
gen_result = CPU_MODEL_COMPARE_RESULT_SUPERSET; |
|||
} |
|||
} else if (modela.def->gen < modelb.def->gen) { |
|||
gen_result = CPU_MODEL_COMPARE_RESULT_SUBSET; |
|||
} else { |
|||
gen_result = CPU_MODEL_COMPARE_RESULT_SUPERSET; |
|||
} |
|||
if (gen_result != CPU_MODEL_COMPARE_RESULT_IDENTICAL) { |
|||
/* both models cannot be made identical */ |
|||
list_add_feat("type", &compare_info->responsible_properties); |
|||
} |
|||
|
|||
/* check the feature set */ |
|||
if (bitmap_equal(modela.features, modelb.features, S390_FEAT_MAX)) { |
|||
feat_result = CPU_MODEL_COMPARE_RESULT_IDENTICAL; |
|||
} else { |
|||
bitmap_andnot(missing, modela.features, modelb.features, S390_FEAT_MAX); |
|||
s390_feat_bitmap_to_ascii(missing, |
|||
&compare_info->responsible_properties, |
|||
list_add_feat); |
|||
bitmap_andnot(added, modelb.features, modela.features, S390_FEAT_MAX); |
|||
s390_feat_bitmap_to_ascii(added, &compare_info->responsible_properties, |
|||
list_add_feat); |
|||
if (bitmap_empty(missing, S390_FEAT_MAX)) { |
|||
feat_result = CPU_MODEL_COMPARE_RESULT_SUBSET; |
|||
} else if (bitmap_empty(added, S390_FEAT_MAX)) { |
|||
feat_result = CPU_MODEL_COMPARE_RESULT_SUPERSET; |
|||
} else { |
|||
feat_result = CPU_MODEL_COMPARE_RESULT_INCOMPATIBLE; |
|||
} |
|||
} |
|||
|
|||
/* combine the results */ |
|||
if (gen_result == feat_result) { |
|||
compare_info->result = gen_result; |
|||
} else if (feat_result == CPU_MODEL_COMPARE_RESULT_IDENTICAL) { |
|||
compare_info->result = gen_result; |
|||
} else if (gen_result == CPU_MODEL_COMPARE_RESULT_IDENTICAL) { |
|||
compare_info->result = feat_result; |
|||
} else { |
|||
compare_info->result = CPU_MODEL_COMPARE_RESULT_INCOMPATIBLE; |
|||
} |
|||
return compare_info; |
|||
} |
|||
|
|||
CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuModelInfo *infoa, |
|||
CpuModelInfo *infob, |
|||
Error **errp) |
|||
{ |
|||
Error *err = NULL; |
|||
CpuModelBaselineInfo *baseline_info; |
|||
S390CPUModel modela, modelb, model; |
|||
uint16_t cpu_type; |
|||
uint8_t max_gen_ga; |
|||
uint8_t max_gen; |
|||
|
|||
/* convert both models to our internal representation */ |
|||
cpu_model_from_info(&modela, infoa, &err); |
|||
if (err) { |
|||
error_propagate(errp, err); |
|||
return NULL; |
|||
} |
|||
|
|||
cpu_model_from_info(&modelb, infob, &err); |
|||
if (err) { |
|||
error_propagate(errp, err); |
|||
return NULL; |
|||
} |
|||
|
|||
/* features both models support */ |
|||
bitmap_and(model.features, modela.features, modelb.features, S390_FEAT_MAX); |
|||
|
|||
/* detect the maximum model not regarding features */ |
|||
if (modela.def->gen == modelb.def->gen) { |
|||
if (modela.def->type == modelb.def->type) { |
|||
cpu_type = modela.def->type; |
|||
} else { |
|||
cpu_type = 0; |
|||
} |
|||
max_gen = modela.def->gen; |
|||
max_gen_ga = MIN(modela.def->ec_ga, modelb.def->ec_ga); |
|||
} else if (modela.def->gen > modelb.def->gen) { |
|||
cpu_type = modelb.def->type; |
|||
max_gen = modelb.def->gen; |
|||
max_gen_ga = modelb.def->ec_ga; |
|||
} else { |
|||
cpu_type = modela.def->type; |
|||
max_gen = modela.def->gen; |
|||
max_gen_ga = modela.def->ec_ga; |
|||
} |
|||
|
|||
model.def = s390_find_cpu_def(cpu_type, max_gen, max_gen_ga, |
|||
model.features); |
|||
|
|||
/* models without early base features (esan3) are bad */ |
|||
if (!model.def) { |
|||
error_setg(errp, "No compatible CPU model could be created as" |
|||
" important base features are disabled"); |
|||
return NULL; |
|||
} |
|||
|
|||
/* strip off features not part of the max model */ |
|||
bitmap_and(model.features, model.features, model.def->full_feat, |
|||
S390_FEAT_MAX); |
|||
|
|||
baseline_info = g_new0(CpuModelBaselineInfo, 1); |
|||
baseline_info->model = g_malloc0(sizeof(*baseline_info->model)); |
|||
cpu_info_from_model(baseline_info->model, &model, true); |
|||
return baseline_info; |
|||
} |
|||
|
|||
void apply_cpu_model(const S390CPUModel *model, Error **errp) |
|||
{ |
|||
Error *err = NULL; |
|||
static S390CPUModel applied_model; |
|||
static bool applied; |
|||
|
|||
/*
|
|||
* We have the same model for all VCPUs. KVM can only be configured before |
|||
* any VCPUs are defined in KVM. |
|||
*/ |
|||
if (applied) { |
|||
if (model && memcmp(&applied_model, model, sizeof(S390CPUModel))) { |
|||
error_setg(errp, "Mixed CPU models are not supported on s390x."); |
|||
} |
|||
return; |
|||
} |
|||
|
|||
if (kvm_enabled()) { |
|||
kvm_s390_apply_cpu_model(model, &err); |
|||
if (err) { |
|||
error_propagate(errp, err); |
|||
return; |
|||
} |
|||
} |
|||
|
|||
applied = true; |
|||
if (model) { |
|||
applied_model = *model; |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
/*
|
|||
* CPU models for s390x - User-mode |
|||
* |
|||
* Copyright 2016 IBM Corp. |
|||
* |
|||
* Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com> |
|||
* |
|||
* This work is licensed under the terms of the GNU GPL, version 2 or (at |
|||
* your option) any later version. See the COPYING file in the top-level |
|||
* directory. |
|||
*/ |
|||
|
|||
#include "qemu/osdep.h" |
|||
#include "cpu.h" |
|||
#include "s390x-internal.h" |
|||
#include "qapi/error.h" |
|||
|
|||
void apply_cpu_model(const S390CPUModel *model, Error **errp) |
|||
{ |
|||
} |
|||
@ -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) |
|||
{ |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
|
|||
s390x_ss.add(when: 'CONFIG_KVM', if_true: files( |
|||
'kvm.c' |
|||
)) |
|||
|
|||
# Newer kernels on s390 check for an S390_PGSTE program header and |
|||
# enable the pgste page table extensions in that case. This makes |
|||
# the vm.allocate_pgste sysctl unnecessary. We enable this program |
|||
# header if |
|||
# - we build on s390x |
|||
# - we build the system emulation for s390x (qemu-system-s390x) |
|||
# - KVM is enabled |
|||
# - the linker supports --s390-pgste |
|||
if host_machine.cpu_family() == 's390x' and cc.has_link_argument('-Wl,--s390-pgste') |
|||
s390x_softmmu_ss.add(when: 'CONFIG_KVM', |
|||
if_true: declare_dependency(link_args: ['-Wl,--s390-pgste'])) |
|||
endif |
|||
@ -0,0 +1,7 @@ |
|||
# See docs/devel/tracing.txt for syntax documentation. |
|||
|
|||
# kvm.c |
|||
kvm_enable_cmma(int rc) "CMMA: enabling with result code %d" |
|||
kvm_clear_cmma(int rc) "CMMA: clearing with result code %d" |
|||
kvm_failed_cpu_state_set(int cpu_index, uint8_t state, const char *msg) "Warning: Unable to set cpu %d state %" PRIu8 " to KVM: %s" |
|||
kvm_assign_subch_ioeventfd(int fd, uint32_t addr, bool assign, int datamatch) "fd: %d sch: @0x%x assign: %d vq: %d" |
|||
@ -0,0 +1 @@ |
|||
#include "trace/trace-target_s390x_kvm.h" |
|||
@ -1,30 +0,0 @@ |
|||
/*
|
|||
* QEMU TCG support -- s390x specific function stubs. |
|||
* |
|||
* Copyright (C) 2018 Red Hat Inc |
|||
* |
|||
* Authors: |
|||
* David Hildenbrand <david@redhat.com> |
|||
* |
|||
* 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(); |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
s390x_ss.add(when: 'CONFIG_TCG', if_true: files( |
|||
'cc_helper.c', |
|||
'crypto_helper.c', |
|||
'excp_helper.c', |
|||
'fpu_helper.c', |
|||
'int_helper.c', |
|||
'mem_helper.c', |
|||
'misc_helper.c', |
|||
'translate.c', |
|||
'vec_fpu_helper.c', |
|||
'vec_helper.c', |
|||
'vec_int_helper.c', |
|||
'vec_string_helper.c', |
|||
)) |
|||
Loading…
Reference in new issue