#include "hw/hw.h"
#include "sysemu/arch_init.h"
#include "sysemu/sysemu.h"
-#include "hw/s390x/sclp.h"
#endif
#define CR0_RESET 0xE0UL
static bool s390_cpu_has_work(CPUState *cs)
{
S390CPU *cpu = S390_CPU(cs);
- CPUS390XState *env = &cpu->env;
- return (cs->interrupt_request & CPU_INTERRUPT_HARD) &&
- (env->psw.mask & PSW_MASK_EXT);
+ /* STOPPED cpus can never wake up */
+ if (s390_cpu_get_state(cpu) != CPU_STATE_LOAD &&
+ s390_cpu_get_state(cpu) != CPU_STATE_OPERATING) {
+ return false;
+ }
+
+ if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
+ return false;
+ }
+
+ return s390_cpu_has_int(cpu);
}
#if !defined(CONFIG_USER_ONLY)
CPUS390XState *env = &cpu->env;
env->pfault_token = -1UL;
+ env->bpbc = false;
scc->parent_reset(s);
cpu->env.sigp_order = 0;
s390_cpu_set_state(CPU_STATE_STOPPED, cpu);
{
S390CPU *cpu = S390_CPU(s);
CPUS390XState *env = &cpu->env;
- int i;
s390_cpu_reset(s);
/* initial reset does not clear everything! */
env->gbea = 1;
env->pfault_token = -1UL;
- env->ext_index = -1;
- for (i = 0; i < ARRAY_SIZE(env->io_index); i++) {
- env->io_index[i] = -1;
- }
/* tininess for underflow is detected before rounding */
set_float_detect_tininess(float_tininess_before_rounding,
S390CPU *cpu = S390_CPU(s);
S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
CPUS390XState *env = &cpu->env;
- int i;
scc->parent_reset(s);
cpu->env.sigp_order = 0;
env->gbea = 1;
env->pfault_token = -1UL;
- env->ext_index = -1;
- for (i = 0; i < ARRAY_SIZE(env->io_index); i++) {
- env->io_index[i] = -1;
- }
/* tininess for underflow is detected before rounding */
set_float_detect_tininess(float_tininess_before_rounding,
{
CPUState *cs = CPU(dev);
S390CPUClass *scc = S390_CPU_GET_CLASS(dev);
+#if !defined(CONFIG_USER_ONLY)
S390CPU *cpu = S390_CPU(dev);
- CPUS390XState *env = &cpu->env;
+#endif
Error *err = NULL;
/* the model has to be realized before qemu_init_vcpu() due to kvm */
max_cpus - 1);
goto out;
}
-#else
- /* implicitly set for linux-user only */
- cpu->env.core_id = scc->next_core_id;
- scc->next_core_id++;
-#endif
if (cpu_exists(cpu->env.core_id)) {
error_setg(&err, "Unable to add CPU with core-id: %" PRIu32
}
/* sync cs->cpu_index and env->core_id. The latter is needed for TCG. */
- cs->cpu_index = env->core_id;
+ cs->cpu_index = cpu->env.core_id;
+#endif
+
cpu_exec_realizefn(cs, &err);
if (err != NULL) {
goto out;
#endif
scc->parent_realize(dev, &err);
-
-#if !defined(CONFIG_USER_ONLY)
- if (dev->hotplugged) {
- raise_irq_cpu_hotplug();
- }
-#endif
-
out:
error_propagate(errp, err);
}
CPUState *cs = CPU(obj);
S390CPU *cpu = S390_CPU(obj);
CPUS390XState *env = &cpu->env;
- static bool inited;
#if !defined(CONFIG_USER_ONLY)
struct tm tm;
#endif
env->cpu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu);
s390_cpu_set_state(CPU_STATE_STOPPED, cpu);
#endif
-
- if (tcg_enabled() && !inited) {
- inited = true;
- s390x_translate_init();
- }
}
static void s390_cpu_finalize(Object *obj)
break;
case CPU_STATE_OPERATING:
case CPU_STATE_LOAD:
- /* unhalt the cpu for common infrastructure */
- s390_cpu_unhalt(cpu);
+ /*
+ * 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",
int s390_get_clock(uint8_t *tod_high, uint64_t *tod_low)
{
+ int r = 0;
+
if (kvm_enabled()) {
- return kvm_s390_get_clock(tod_high, tod_low);
+ r = kvm_s390_get_clock_ext(tod_high, tod_low);
+ if (r == -ENXIO) {
+ return kvm_s390_get_clock(tod_high, tod_low);
+ }
+ } else {
+ /* Fixme TCG */
+ *tod_high = 0;
+ *tod_low = 0;
}
- /* Fixme TCG */
- *tod_high = 0;
- *tod_low = 0;
- return 0;
+
+ return r;
}
int s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
{
+ int r = 0;
+
if (kvm_enabled()) {
- return kvm_s390_set_clock(tod_high, tod_low);
+ r = kvm_s390_set_clock_ext(tod_high, tod_low);
+ if (r == -ENXIO) {
+ return kvm_s390_set_clock(tod_high, tod_low);
+ }
}
/* Fixme TCG */
- return 0;
+ return r;
}
int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit)
}
}
-int s390_cpu_restart(S390CPU *cpu)
-{
- if (kvm_enabled()) {
- return kvm_s390_cpu_restart(cpu);
- }
- return -ENOSYS;
-}
-
int s390_get_memslot_count(void)
{
if (kvm_enabled()) {
}
static Property s390x_cpu_properties[] = {
+#if !defined(CONFIG_USER_ONLY)
DEFINE_PROP_UINT32("core-id", S390CPU, env.core_id, 0),
+#endif
DEFINE_PROP_END_OF_LIST()
};
CPUClass *cc = CPU_CLASS(scc);
DeviceClass *dc = DEVICE_CLASS(oc);
- scc->parent_realize = dc->realize;
- dc->realize = s390_cpu_realizefn;
+ device_class_set_parent_realize(dc, s390_cpu_realizefn,
+ &scc->parent_realize);
dc->props = s390x_cpu_properties;
dc->user_creatable = true;
#endif
#endif
cc->disas_set_info = s390_cpu_disas_set_info;
+#ifdef CONFIG_TCG
+ cc->tcg_initialize = s390x_translate_init;
+#endif
cc->gdb_num_core_regs = S390_NUM_CORE_REGS;
cc->gdb_core_xml_file = "s390x-core64.xml";