aboutsummaryrefslogtreecommitdiff
path: root/target-s390x
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2012-10-31 06:06:49 +0100
committerAndreas Färber <afaerber@suse.de>2012-12-19 14:09:31 +0100
commit1bc22652d62f862a5def54f939e87fdb7a5593ae (patch)
tree007c4c834f580f81989b94c5c5489a57ff2b2263 /target-s390x
parent20d695a9254c1b086a456d3b79a3c311236643ba (diff)
kvm: Pass CPUState to kvm_vcpu_ioctl()
Adapt helper functions to pass X86CPU / PowerPCCPU / S390CPU. Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'target-s390x')
-rw-r--r--target-s390x/cpu.h12
-rw-r--r--target-s390x/interrupt.c3
-rw-r--r--target-s390x/kvm.c62
-rw-r--r--target-s390x/misc_helper.c2
4 files changed, 42 insertions, 37 deletions
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 0f9a1f7340..7e7e3b7199 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -296,21 +296,21 @@ void s390x_cpu_timer(void *opaque);
int s390_virtio_hypercall(CPUS390XState *env, uint64_t mem, uint64_t hypercall);
#ifdef CONFIG_KVM
-void kvm_s390_interrupt(CPUS390XState *env, int type, uint32_t code);
-void kvm_s390_virtio_irq(CPUS390XState *env, int config_change, uint64_t token);
-void kvm_s390_interrupt_internal(CPUS390XState *env, int type, uint32_t parm,
+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);
#else
-static inline void kvm_s390_interrupt(CPUS390XState *env, int type, uint32_t code)
+static inline void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code)
{
}
-static inline void kvm_s390_virtio_irq(CPUS390XState *env, int config_change,
+static inline void kvm_s390_virtio_irq(S390CPU *cpu, int config_change,
uint64_t token)
{
}
-static inline void kvm_s390_interrupt_internal(CPUS390XState *env, int type,
+static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
uint32_t parm, uint64_t parm64,
int vm)
{
diff --git a/target-s390x/interrupt.c b/target-s390x/interrupt.c
index c1b034f775..97487bd631 100644
--- a/target-s390x/interrupt.c
+++ b/target-s390x/interrupt.c
@@ -19,7 +19,8 @@ void s390_sclp_extint(uint32_t parm)
if (kvm_enabled()) {
#ifdef CONFIG_KVM
- kvm_s390_interrupt_internal(env, KVM_S390_INT_SERVICE, parm, 0, 1);
+ kvm_s390_interrupt_internal(dummy_cpu, KVM_S390_INT_SERVICE, parm,
+ 0, 1);
#endif
} else {
env->psw.addr += 4;
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index d4e6ab2db8..5422678330 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -74,10 +74,9 @@ int kvm_arch_init(KVMState *s)
int kvm_arch_init_vcpu(CPUState *cpu)
{
- CPUS390XState *env = &S390_CPU(cpu)->env;
int ret = 0;
- if (kvm_vcpu_ioctl(env, KVM_S390_INITIAL_RESET, NULL) < 0) {
+ if (kvm_vcpu_ioctl(cpu, KVM_S390_INITIAL_RESET, NULL) < 0) {
perror("cannot init reset vcpu");
}
@@ -111,7 +110,7 @@ int kvm_arch_put_registers(CPUState *cs, int level)
for (i = 0; i < 16; i++) {
regs.gprs[i] = env->regs[i];
}
- ret = kvm_vcpu_ioctl(env, KVM_SET_REGS, &regs);
+ ret = kvm_vcpu_ioctl(cs, KVM_SET_REGS, &regs);
if (ret < 0) {
return ret;
}
@@ -136,7 +135,7 @@ int kvm_arch_put_registers(CPUState *cs, int level)
sregs.acrs[i] = env->aregs[i];
sregs.crs[i] = env->cregs[i];
}
- ret = kvm_vcpu_ioctl(env, KVM_SET_SREGS, &sregs);
+ ret = kvm_vcpu_ioctl(cs, KVM_SET_SREGS, &sregs);
if (ret < 0) {
return ret;
}
@@ -171,7 +170,7 @@ int kvm_arch_get_registers(CPUState *cs)
env->regs[i] = env->kvm_run->s.regs.gprs[i];
}
} else {
- ret = kvm_vcpu_ioctl(env, KVM_GET_REGS, &regs);
+ ret = kvm_vcpu_ioctl(cs, KVM_GET_REGS, &regs);
if (ret < 0) {
return ret;
}
@@ -189,7 +188,7 @@ int kvm_arch_get_registers(CPUState *cs)
env->cregs[i] = env->kvm_run->s.regs.crs[i];
}
} else {
- ret = kvm_vcpu_ioctl(env, KVM_GET_SREGS, &sregs);
+ ret = kvm_vcpu_ioctl(cs, KVM_GET_SREGS, &sregs);
if (ret < 0) {
return ret;
}
@@ -289,9 +288,11 @@ int kvm_arch_process_async_events(CPUState *cs)
return cpu->env.halted;
}
-void kvm_s390_interrupt_internal(CPUS390XState *env, int type, uint32_t parm,
+void kvm_s390_interrupt_internal(S390CPU *cpu, int type, uint32_t parm,
uint64_t parm64, int vm)
{
+ CPUS390XState *env = &cpu->env;
+ CPUState *cs = CPU(cpu);
struct kvm_s390_interrupt kvmint;
int r;
@@ -306,7 +307,7 @@ void kvm_s390_interrupt_internal(CPUS390XState *env, int type, uint32_t parm,
if (vm) {
r = kvm_vm_ioctl(env->kvm_state, KVM_S390_INTERRUPT, &kvmint);
} else {
- r = kvm_vcpu_ioctl(env, KVM_S390_INTERRUPT, &kvmint);
+ r = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &kvmint);
}
if (r < 0) {
@@ -315,20 +316,20 @@ void kvm_s390_interrupt_internal(CPUS390XState *env, int type, uint32_t parm,
}
}
-void kvm_s390_virtio_irq(CPUS390XState *env, int config_change, uint64_t token)
+void kvm_s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token)
{
- kvm_s390_interrupt_internal(env, KVM_S390_INT_VIRTIO, config_change,
+ kvm_s390_interrupt_internal(cpu, KVM_S390_INT_VIRTIO, config_change,
token, 1);
}
-void kvm_s390_interrupt(CPUS390XState *env, int type, uint32_t code)
+void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code)
{
- kvm_s390_interrupt_internal(env, type, code, 0, 0);
+ kvm_s390_interrupt_internal(cpu, type, code, 0, 0);
}
-static void enter_pgmcheck(CPUS390XState *env, uint16_t code)
+static void enter_pgmcheck(S390CPU *cpu, uint16_t code)
{
- kvm_s390_interrupt(env, KVM_S390_PROGRAM_INT, code);
+ kvm_s390_interrupt(cpu, KVM_S390_PROGRAM_INT, code);
}
static inline void setcc(CPUS390XState *env, uint64_t cc)
@@ -340,9 +341,10 @@ static inline void setcc(CPUS390XState *env, uint64_t cc)
env->psw.mask |= (cc & 3) << 44;
}
-static int kvm_sclp_service_call(CPUS390XState *env, struct kvm_run *run,
+static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run,
uint16_t ipbh0)
{
+ CPUS390XState *env = &cpu->env;
uint32_t sccb;
uint64_t code;
int r = 0;
@@ -353,14 +355,14 @@ static int kvm_sclp_service_call(CPUS390XState *env, struct kvm_run *run,
r = sclp_service_call(sccb, code);
if (r < 0) {
- enter_pgmcheck(env, -r);
+ enter_pgmcheck(cpu, -r);
}
setcc(env, r);
return 0;
}
-static int handle_priv(CPUS390XState *env, struct kvm_run *run, uint8_t ipa1)
+static int handle_priv(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
{
int r = 0;
uint16_t ipbh0 = (run->s390_sieic.ipb & 0xffff0000) >> 16;
@@ -368,7 +370,7 @@ static int handle_priv(CPUS390XState *env, struct kvm_run *run, uint8_t ipa1)
dprintf("KVM: PRIV: %d\n", ipa1);
switch (ipa1) {
case PRIV_SCLP_CALL:
- r = kvm_sclp_service_call(env, run, ipbh0);
+ r = kvm_sclp_service_call(cpu, run, ipbh0);
break;
default:
dprintf("KVM: unknown PRIV: 0x%x\n", ipa1);
@@ -411,7 +413,7 @@ static int s390_cpu_restart(S390CPU *cpu)
{
CPUS390XState *env = &cpu->env;
- kvm_s390_interrupt(env, KVM_S390_RESTART, 0);
+ kvm_s390_interrupt(cpu, KVM_S390_RESTART, 0);
s390_add_running_cpu(env);
qemu_cpu_kick(CPU(cpu));
dprintf("DONE: SIGP cpu restart: %p\n", env);
@@ -425,12 +427,13 @@ static int s390_store_status(CPUS390XState *env, uint32_t parameter)
return -1;
}
-static int s390_cpu_initial_reset(CPUS390XState *env)
+static int s390_cpu_initial_reset(S390CPU *cpu)
{
+ CPUS390XState *env = &cpu->env;
int i;
s390_del_running_cpu(env);
- if (kvm_vcpu_ioctl(env, KVM_S390_INITIAL_RESET, NULL) < 0) {
+ if (kvm_vcpu_ioctl(CPU(cpu), KVM_S390_INITIAL_RESET, NULL) < 0) {
perror("cannot init reset vcpu");
}
@@ -489,7 +492,7 @@ static int handle_sigp(CPUS390XState *env, struct kvm_run *run, uint8_t ipa1)
/* make the caller panic */
return -1;
case SIGP_INITIAL_CPU_RESET:
- r = s390_cpu_initial_reset(target_env);
+ r = s390_cpu_initial_reset(target_cpu);
break;
default:
fprintf(stderr, "KVM: unknown SIGP: 0x%x\n", order_code);
@@ -501,8 +504,9 @@ out:
return 0;
}
-static int handle_instruction(CPUS390XState *env, struct kvm_run *run)
+static int handle_instruction(S390CPU *cpu, struct kvm_run *run)
{
+ CPUS390XState *env = &cpu->env;
unsigned int ipa0 = (run->s390_sieic.ipa & 0xff00);
uint8_t ipa1 = run->s390_sieic.ipa & 0x00ff;
int ipb_code = (run->s390_sieic.ipb & 0x0fff0000) >> 16;
@@ -511,7 +515,7 @@ static int handle_instruction(CPUS390XState *env, struct kvm_run *run)
dprintf("handle_instruction 0x%x 0x%x\n", run->s390_sieic.ipa, run->s390_sieic.ipb);
switch (ipa0) {
case IPA0_PRIV:
- r = handle_priv(env, run, ipa1);
+ r = handle_priv(cpu, run, ipa1);
break;
case IPA0_DIAG:
r = handle_diag(env, run, ipb_code);
@@ -522,7 +526,7 @@ static int handle_instruction(CPUS390XState *env, struct kvm_run *run)
}
if (r < 0) {
- enter_pgmcheck(env, 0x0001);
+ enter_pgmcheck(cpu, 0x0001);
}
return 0;
}
@@ -533,8 +537,9 @@ static bool is_special_wait_psw(CPUS390XState *env)
return env->kvm_run->psw_addr == 0xfffUL;
}
-static int handle_intercept(CPUS390XState *env)
+static int handle_intercept(S390CPU *cpu)
{
+ CPUS390XState *env = &cpu->env;
struct kvm_run *run = env->kvm_run;
int icpt_code = run->s390_sieic.icptcode;
int r = 0;
@@ -543,7 +548,7 @@ static int handle_intercept(CPUS390XState *env)
(long)env->kvm_run->psw_addr);
switch (icpt_code) {
case ICPT_INSTRUCTION:
- r = handle_instruction(env, run);
+ r = handle_instruction(cpu, run);
break;
case ICPT_WAITPSW:
if (s390_del_running_cpu(env) == 0 &&
@@ -578,12 +583,11 @@ static int handle_intercept(CPUS390XState *env)
int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
{
S390CPU *cpu = S390_CPU(cs);
- CPUS390XState *env = &cpu->env;
int ret = 0;
switch (run->exit_reason) {
case KVM_EXIT_S390_SIEIC:
- ret = handle_intercept(env);
+ ret = handle_intercept(cpu);
break;
case KVM_EXIT_S390_RESET:
qemu_system_reset_request();
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index 38d8f2a627..0834a1992b 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -57,7 +57,7 @@ void program_interrupt(CPUS390XState *env, uint32_t code, int ilc)
if (kvm_enabled()) {
#ifdef CONFIG_KVM
- kvm_s390_interrupt(env, KVM_S390_PROGRAM_INT, code);
+ kvm_s390_interrupt(s390_env_get_cpu(env), KVM_S390_PROGRAM_INT, code);
#endif
} else {
env->int_pgm_code = code;