aboutsummaryrefslogtreecommitdiff
path: root/target-s390x
diff options
context:
space:
mode:
authorCornelia Huck <cornelia.huck@de.ibm.com>2014-03-11 13:19:43 +0100
committerCornelia Huck <cornelia.huck@de.ibm.com>2014-06-10 09:50:27 +0200
commitde13d2161473d02ae97ec0f8e4503147554892dd (patch)
tree2d43f192b9e974e313eac5399d2f907493a86a8c /target-s390x
parent66ad0893f07f194b5c8607cb81061b8d7202511c (diff)
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>
Diffstat (limited to 'target-s390x')
-rw-r--r--target-s390x/cpu.h41
-rw-r--r--target-s390x/interrupt.c38
-rw-r--r--target-s390x/kvm.c104
-rw-r--r--target-s390x/misc_helper.c7
4 files changed, 85 insertions, 105 deletions
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 644d1266c1..9982c35fc2 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -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(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_virtio_irq(int config_change, uint64_t token)
{
}
-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,
diff --git a/target-s390x/interrupt.c b/target-s390x/interrupt.c
index c32bdcb0c1..23a9114f5a 100644
--- a/target-s390x/interrupt.c
+++ b/target-s390x/interrupt.c
@@ -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)
{
- S390CPU *dummy_cpu = s390_cpu_addr2state(0);
- CPUS390XState *env = &dummy_cpu->env;
-
if (kvm_enabled()) {
- kvm_s390_service_interrupt(dummy_cpu, parm);
+ kvm_s390_service_interrupt(parm);
} else {
+ S390CPU *dummy_cpu = s390_cpu_addr2state(0);
+ CPUS390XState *env = &dummy_cpu->env;
+
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);
}
}
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 0d36ab4a42..a2133ff1ce 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -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;
-
- if (!cs->kvm_state) {
- return;
- }
-
- 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);
- }
-}
+ struct kvm_s390_irq irq = {
+ .type = KVM_S390_INT_VIRTIO,
+ .u.ext.ext_params = config_change,
+ .u.ext.ext_params2 = token,
+ };
-void kvm_s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token)
-{
- kvm_s390_interrupt_internal(cpu, KVM_S390_INT_VIRTIO, config_change,
- token, 1);
+ kvm_s390_floating_interrupt(&irq);
}
-void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code)
+void kvm_s390_service_interrupt(uint32_t parm)
{
- kvm_s390_interrupt_internal(cpu, type, code, 0, 0);
-}
+ struct kvm_s390_irq irq = {
+ .type = KVM_S390_INT_SERVICE,
+ .u.ext.ext_params = parm,
+ };
-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)
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index 519edb81dd..0b625826ef 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -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);