s390x: cleanup interrupt injection

Remove the need for a cpu to inject a floating interrupt on kvm.

Acked-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
This commit is contained in:
Cornelia Huck 2014-03-11 13:19:43 +01:00
parent 66ad0893f0
commit de13d21614
6 changed files with 91 additions and 120 deletions

View File

@ -128,13 +128,11 @@ uint16_t css_build_subchannel_id(SubchDev *sch)
static void css_inject_io_interrupt(SubchDev *sch)
{
S390CPU *cpu = s390_cpu_addr2state(0);
uint8_t isc = (sch->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ISC) >> 11;
trace_css_io_interrupt(sch->cssid, sch->ssid, sch->schid,
sch->curr_status.pmcw.intparm, isc, "");
s390_io_interrupt(cpu,
css_build_subchannel_id(sch),
s390_io_interrupt(css_build_subchannel_id(sch),
sch->schid,
sch->curr_status.pmcw.intparm,
isc << 27);
@ -147,7 +145,6 @@ void css_conditional_io_interrupt(SubchDev *sch)
* with alert status.
*/
if (!(sch->curr_status.scsw.ctrl & SCSW_STCTL_STATUS_PEND)) {
S390CPU *cpu = s390_cpu_addr2state(0);
uint8_t isc = (sch->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ISC) >> 11;
trace_css_io_interrupt(sch->cssid, sch->ssid, sch->schid,
@ -157,8 +154,7 @@ void css_conditional_io_interrupt(SubchDev *sch)
sch->curr_status.scsw.ctrl |=
SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;
/* Inject an I/O interrupt. */
s390_io_interrupt(cpu,
css_build_subchannel_id(sch),
s390_io_interrupt(css_build_subchannel_id(sch),
sch->schid,
sch->curr_status.pmcw.intparm,
isc << 27);
@ -167,11 +163,10 @@ void css_conditional_io_interrupt(SubchDev *sch)
void css_adapter_interrupt(uint8_t isc)
{
S390CPU *cpu = s390_cpu_addr2state(0);
uint32_t io_int_word = (isc << 27) | IO_INT_WORD_AI;
trace_css_adapter_interrupt(isc);
s390_io_interrupt(cpu, 0, 0, 0, io_int_word);
s390_io_interrupt(0, 0, 0, io_int_word);
}
static void sch_handle_clear_func(SubchDev *sch)
@ -1231,11 +1226,9 @@ void css_queue_crw(uint8_t rsc, uint8_t erc, int chain, uint16_t rsid)
QTAILQ_INSERT_TAIL(&channel_subsys->pending_crws, crw_cont, sibling);
if (channel_subsys->do_crw_mchk) {
S390CPU *cpu = s390_cpu_addr2state(0);
channel_subsys->do_crw_mchk = false;
/* Inject crw pending machine check. */
s390_crw_mchk(cpu);
s390_crw_mchk();
}
}

View File

@ -133,8 +133,7 @@ static int s390_virtio_device_init(VirtIOS390Device *dev, VirtIODevice *vdev)
s390_virtio_device_sync(dev);
s390_virtio_reset_idx(dev);
if (dev->qdev.hotplugged) {
S390CPU *cpu = s390_cpu_addr2state(0);
s390_virtio_irq(cpu, VIRTIO_PARAM_DEV_ADD, dev->dev_offs);
s390_virtio_irq(VIRTIO_PARAM_DEV_ADD, dev->dev_offs);
}
return 0;
@ -478,9 +477,8 @@ static void virtio_s390_notify(DeviceState *d, uint16_t vector)
{
VirtIOS390Device *dev = to_virtio_s390_device_fast(d);
uint64_t token = s390_virtio_device_vq_token(dev, vector);
S390CPU *cpu = s390_cpu_addr2state(0);
s390_virtio_irq(cpu, 0, token);
s390_virtio_irq(0, token);
}
static unsigned virtio_s390_get_features(DeviceState *d)

View File

@ -357,37 +357,22 @@ void s390x_tod_timer(void *opaque);
void s390x_cpu_timer(void *opaque);
int s390_virtio_hypercall(CPUS390XState *env);
void s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token);
void s390_virtio_irq(int config_change, uint64_t token);
#ifdef CONFIG_KVM
void kvm_s390_reset_vcpu(S390CPU *cpu);
void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code);
void kvm_s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token);
void kvm_s390_interrupt_internal(S390CPU *cpu, int type, uint32_t parm,
uint64_t parm64, int vm);
void kvm_s390_service_interrupt(S390CPU *cpu, uint32_t parm);
void kvm_s390_virtio_irq(int config_change, uint64_t token);
void kvm_s390_service_interrupt(uint32_t parm);
void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq);
#else
static inline void kvm_s390_reset_vcpu(S390CPU *cpu)
{
}
static inline void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code)
static inline void kvm_s390_virtio_irq(int config_change, uint64_t token)
{
}
static inline void kvm_s390_virtio_irq(S390CPU *cpu, int config_change,
uint64_t token)
{
}
static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
uint32_t parm, uint64_t parm64,
int vm)
{
}
static inline void kvm_s390_service_interrupt(S390CPU *cpu, uint32_t parm)
static inline void kvm_s390_service_interrupt(uint32_t parm)
{
}
#endif
@ -1073,24 +1058,23 @@ void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp,
uintptr_t retaddr);
#ifdef CONFIG_KVM
void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id,
void kvm_s390_io_interrupt(uint16_t subchannel_id,
uint16_t subchannel_nr, uint32_t io_int_parm,
uint32_t io_int_word);
void kvm_s390_crw_mchk(S390CPU *cpu);
void kvm_s390_crw_mchk(void);
void kvm_s390_enable_css_support(S390CPU *cpu);
int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,
int vq, bool assign);
int kvm_s390_cpu_restart(S390CPU *cpu);
void kvm_s390_clear_cmma_callback(void *opaque);
#else
static inline void kvm_s390_io_interrupt(S390CPU *cpu,
uint16_t subchannel_id,
static inline void kvm_s390_io_interrupt(uint16_t subchannel_id,
uint16_t subchannel_nr,
uint32_t io_int_parm,
uint32_t io_int_word)
{
}
static inline void kvm_s390_crw_mchk(S390CPU *cpu)
static inline void kvm_s390_crw_mchk(void)
{
}
static inline void kvm_s390_enable_css_support(S390CPU *cpu)
@ -1127,10 +1111,9 @@ static inline int s390_cpu_restart(S390CPU *cpu)
return -ENOSYS;
}
void s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id,
uint16_t subchannel_nr, uint32_t io_int_parm,
uint32_t io_int_word);
void s390_crw_mchk(S390CPU *cpu);
void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr,
uint32_t io_int_parm, uint32_t io_int_word);
void s390_crw_mchk(void);
static inline int s390_assign_subch_ioeventfd(EventNotifier *notifier,
uint32_t sch_id, int vq,

View File

@ -12,50 +12,56 @@
/*
* All of the following interrupts are floating, i.e. not per-vcpu.
* We just need a dummy cpustate in order to be able to inject.
* We just need a dummy cpustate in order to be able to inject in the
* non-kvm case.
*/
#if !defined(CONFIG_USER_ONLY)
void s390_sclp_extint(uint32_t parm)
{
if (kvm_enabled()) {
kvm_s390_service_interrupt(parm);
} else {
S390CPU *dummy_cpu = s390_cpu_addr2state(0);
CPUS390XState *env = &dummy_cpu->env;
if (kvm_enabled()) {
kvm_s390_service_interrupt(dummy_cpu, parm);
} else {
env->psw.addr += 4;
cpu_inject_ext(dummy_cpu, EXT_SERVICE, parm, 0);
}
}
void s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token)
void s390_virtio_irq(int config_change, uint64_t token)
{
if (kvm_enabled()) {
kvm_s390_virtio_irq(cpu, config_change, token);
kvm_s390_virtio_irq(config_change, token);
} else {
cpu_inject_ext(cpu, EXT_VIRTIO, config_change, token);
S390CPU *dummy_cpu = s390_cpu_addr2state(0);
cpu_inject_ext(dummy_cpu, EXT_VIRTIO, config_change, token);
}
}
void s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id,
uint16_t subchannel_nr, uint32_t io_int_parm,
uint32_t io_int_word)
void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr,
uint32_t io_int_parm, uint32_t io_int_word)
{
if (kvm_enabled()) {
kvm_s390_io_interrupt(cpu, subchannel_id, subchannel_nr, io_int_parm,
kvm_s390_io_interrupt(subchannel_id, subchannel_nr, io_int_parm,
io_int_word);
} else {
cpu_inject_io(cpu, subchannel_id, subchannel_nr, io_int_parm,
S390CPU *dummy_cpu = s390_cpu_addr2state(0);
cpu_inject_io(dummy_cpu, subchannel_id, subchannel_nr, io_int_parm,
io_int_word);
}
}
void s390_crw_mchk(S390CPU *cpu)
void s390_crw_mchk(void)
{
if (kvm_enabled()) {
kvm_s390_crw_mchk(cpu);
kvm_s390_crw_mchk();
} else {
cpu_inject_crw_mchk(cpu);
S390CPU *dummy_cpu = s390_cpu_addr2state(0);
cpu_inject_crw_mchk(dummy_cpu);
}
}

View File

@ -641,52 +641,35 @@ void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq)
}
}
void kvm_s390_interrupt_internal(S390CPU *cpu, int type, uint32_t parm,
uint64_t parm64, int vm)
void kvm_s390_virtio_irq(int config_change, uint64_t token)
{
CPUState *cs = CPU(cpu);
struct kvm_s390_interrupt kvmint;
int r;
struct kvm_s390_irq irq = {
.type = KVM_S390_INT_VIRTIO,
.u.ext.ext_params = config_change,
.u.ext.ext_params2 = token,
};
if (!cs->kvm_state) {
return;
kvm_s390_floating_interrupt(&irq);
}
kvmint.type = type;
kvmint.parm = parm;
kvmint.parm64 = parm64;
if (vm) {
r = kvm_vm_ioctl(cs->kvm_state, KVM_S390_INTERRUPT, &kvmint);
} else {
r = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &kvmint);
}
if (r < 0) {
fprintf(stderr, "KVM failed to inject interrupt\n");
exit(1);
}
}
void kvm_s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token)
void kvm_s390_service_interrupt(uint32_t parm)
{
kvm_s390_interrupt_internal(cpu, KVM_S390_INT_VIRTIO, config_change,
token, 1);
}
struct kvm_s390_irq irq = {
.type = KVM_S390_INT_SERVICE,
.u.ext.ext_params = parm,
};
void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code)
{
kvm_s390_interrupt_internal(cpu, type, code, 0, 0);
}
void kvm_s390_service_interrupt(S390CPU *cpu, uint32_t parm)
{
kvm_s390_interrupt_internal(cpu, KVM_S390_INT_SERVICE, parm, 0 , 1);
kvm_s390_floating_interrupt(&irq);
}
static void enter_pgmcheck(S390CPU *cpu, uint16_t code)
{
kvm_s390_interrupt(cpu, KVM_S390_PROGRAM_INT, code);
struct kvm_s390_irq irq = {
.type = KVM_S390_PROGRAM_INT,
.u.pgm.code = code,
};
kvm_s390_vcpu_interrupt(cpu, &irq);
}
static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run,
@ -902,7 +885,11 @@ static int kvm_s390_cpu_start(S390CPU *cpu)
int kvm_s390_cpu_restart(S390CPU *cpu)
{
kvm_s390_interrupt(cpu, KVM_S390_RESTART, 0);
struct kvm_s390_irq irq = {
.type = KVM_S390_RESTART,
};
kvm_s390_vcpu_interrupt(cpu, &irq);
s390_add_running_cpu(cpu);
qemu_cpu_kick(CPU(cpu));
DPRINTF("DONE: KVM cpu restart: %p\n", &cpu->env);
@ -1122,18 +1109,10 @@ static int handle_tsch(S390CPU *cpu)
* If an I/O interrupt had been dequeued, we have to reinject it.
*/
if (run->s390_tsch.dequeued) {
uint16_t subchannel_id = run->s390_tsch.subchannel_id;
uint16_t subchannel_nr = run->s390_tsch.subchannel_nr;
uint32_t io_int_parm = run->s390_tsch.io_int_parm;
uint32_t io_int_word = run->s390_tsch.io_int_word;
uint32_t type = ((subchannel_id & 0xff00) << 24) |
((subchannel_id & 0x00060) << 22) | (subchannel_nr << 16);
kvm_s390_interrupt_internal(cpu, type,
((uint32_t)subchannel_id << 16)
| subchannel_nr,
((uint64_t)io_int_parm << 32)
| io_int_word, 1);
kvm_s390_io_interrupt(run->s390_tsch.subchannel_id,
run->s390_tsch.subchannel_nr,
run->s390_tsch.io_int_parm,
run->s390_tsch.io_int_word);
}
ret = 0;
}
@ -1218,27 +1197,34 @@ int kvm_arch_on_sigbus(int code, void *addr)
return 1;
}
void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id,
void kvm_s390_io_interrupt(uint16_t subchannel_id,
uint16_t subchannel_nr, uint32_t io_int_parm,
uint32_t io_int_word)
{
uint32_t type;
struct kvm_s390_irq irq = {
.u.io.subchannel_id = subchannel_id,
.u.io.subchannel_nr = subchannel_nr,
.u.io.io_int_parm = io_int_parm,
.u.io.io_int_word = io_int_word,
};
if (io_int_word & IO_INT_WORD_AI) {
type = KVM_S390_INT_IO(1, 0, 0, 0);
irq.type = KVM_S390_INT_IO(1, 0, 0, 0);
} else {
type = ((subchannel_id & 0xff00) << 24) |
irq.type = ((subchannel_id & 0xff00) << 24) |
((subchannel_id & 0x00060) << 22) | (subchannel_nr << 16);
}
kvm_s390_interrupt_internal(cpu, type,
((uint32_t)subchannel_id << 16) | subchannel_nr,
((uint64_t)io_int_parm << 32) | io_int_word, 1);
kvm_s390_floating_interrupt(&irq);
}
void kvm_s390_crw_mchk(S390CPU *cpu)
void kvm_s390_crw_mchk(void)
{
kvm_s390_interrupt_internal(cpu, KVM_S390_MCHK, 1 << 28,
0x00400f1d40330000, 1);
struct kvm_s390_irq irq = {
.type = KVM_S390_MCHK,
.u.mchk.cr14 = 1 << 28,
.u.mchk.mcic = 0x00400f1d40330000,
};
kvm_s390_floating_interrupt(&irq);
}
void kvm_s390_enable_css_support(S390CPU *cpu)

View File

@ -85,7 +85,12 @@ void program_interrupt(CPUS390XState *env, uint32_t code, int ilen)
if (kvm_enabled()) {
#ifdef CONFIG_KVM
kvm_s390_interrupt(cpu, KVM_S390_PROGRAM_INT, code);
struct kvm_s390_irq irq = {
.type = KVM_S390_PROGRAM_INT,
.u.pgm.code = code,
};
kvm_s390_vcpu_interrupt(cpu, &irq);
#endif
} else {
CPUState *cs = CPU(cpu);