s390x/tcg: implement STOP and RESET interrupts for TCG

Implement them like KVM implements/handles them. Both can only be
triggered via SIGP instructions. RESET has (almost) the lowest priority if
the CPU is running, and the highest if the CPU is STOPPED. This is handled
in SIGP code already. On delivery, we only have to care about the
"CPU running" scenario.

STOP is defined to be delivered after all other interrupts have been
delivered. Therefore it has the actual lowest priority.

As both can wake up a CPU if sleeping, indicate them correctly to
external code (e.g. cpu_has_work()).

Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20170928203708.9376-25-david@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
This commit is contained in:
David Hildenbrand 2017-09-28 22:37:02 +02:00 committed by Cornelia Huck
parent a6880d213b
commit b1ab5f6068
6 changed files with 51 additions and 6 deletions

View file

@ -109,22 +109,28 @@ int cpu_inject_external_call(S390CPU *cpu, uint16_t src_cpu_addr)
void cpu_inject_restart(S390CPU *cpu)
{
CPUS390XState *env = &cpu->env;
if (kvm_enabled()) {
kvm_s390_restart_interrupt(cpu);
return;
}
/* FIXME TCG */
g_assert_not_reached();
env->pending_int |= INTERRUPT_RESTART;
cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
}
void cpu_inject_stop(S390CPU *cpu)
{
CPUS390XState *env = &cpu->env;
if (kvm_enabled()) {
kvm_s390_stop_interrupt(cpu);
return;
}
/* FIXME TCG */
g_assert_not_reached();
env->pending_int |= INTERRUPT_STOP;
cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD);
}
static void cpu_inject_io(S390CPU *cpu, uint16_t subchannel_id,
@ -272,6 +278,20 @@ bool s390_cpu_has_io_int(S390CPU *cpu)
return env->pending_int & INTERRUPT_IO;
}
bool s390_cpu_has_restart_int(S390CPU *cpu)
{
CPUS390XState *env = &cpu->env;
return env->pending_int & INTERRUPT_RESTART;
}
bool s390_cpu_has_stop_int(S390CPU *cpu)
{
CPUS390XState *env = &cpu->env;
return env->pending_int & INTERRUPT_STOP;
}
#endif
bool s390_cpu_has_int(S390CPU *cpu)
@ -282,7 +302,9 @@ bool s390_cpu_has_int(S390CPU *cpu)
}
return s390_cpu_has_mcck_int(cpu) ||
s390_cpu_has_ext_int(cpu) ||
s390_cpu_has_io_int(cpu);
s390_cpu_has_io_int(cpu) ||
s390_cpu_has_restart_int(cpu) ||
s390_cpu_has_stop_int(cpu);
#else
return false;
#endif