aboutsummaryrefslogtreecommitdiff
path: root/target-s390x/kvm.c
diff options
context:
space:
mode:
authorDavid Hildenbrand <dahi@linux.vnet.ibm.com>2014-02-25 15:53:00 +0100
committerCornelia Huck <cornelia.huck@de.ibm.com>2014-05-20 13:05:58 +0200
commitb30f4dfbdaf353e580f8a834aeea6b96ac1c67c9 (patch)
treebab1d1518254724a3320ff2e56c3937dc524e14a /target-s390x/kvm.c
parent8e4e86afa524588397be2101c3582c897fc408df (diff)
s390x/kvm: software breakpoint support
This patch allows to insert and remove sw breakpoints using the QEMU gdbserver on s390 as well as to interrupt execution on a breakpoint hit when running with KVM enabled. Whenever a software breakpoint is inserted, common code calls kvm ioctl KVM_UPDATE_GUEST_DEBUG. As this method's default on s390 is to return an error if not implement, the insertion will fail. Therefore, KVM also has to be updated in order to make use of software breakpoints. Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'target-s390x/kvm.c')
-rw-r--r--target-s390x/kvm.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 4d12f70021..6d47637d78 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -583,6 +583,22 @@ static void kvm_handle_diag_308(S390CPU *cpu, struct kvm_run *run)
handle_diag_308(&cpu->env, r1, r3);
}
+static int handle_sw_breakpoint(S390CPU *cpu, struct kvm_run *run)
+{
+ CPUS390XState *env = &cpu->env;
+ unsigned long pc;
+
+ cpu_synchronize_state(CPU(cpu));
+
+ pc = env->psw.addr - 4;
+ if (kvm_find_sw_breakpoint(CPU(cpu), pc)) {
+ env->psw.addr = pc;
+ return EXCP_DEBUG;
+ }
+
+ return -ENOENT;
+}
+
#define DIAG_KVM_CODE_MASK 0x000000000000ffff
static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb)
@@ -603,7 +619,7 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb)
r = handle_hypercall(cpu, run);
break;
case DIAG_KVM_BREAKPOINT:
- sleep(10);
+ r = handle_sw_breakpoint(cpu, run);
break;
default:
DPRINTF("KVM: unknown DIAG: 0x%x\n", func_code);
@@ -705,7 +721,7 @@ out:
return 0;
}
-static void handle_instruction(S390CPU *cpu, struct kvm_run *run)
+static int handle_instruction(S390CPU *cpu, struct kvm_run *run)
{
unsigned int ipa0 = (run->s390_sieic.ipa & 0xff00);
uint8_t ipa1 = run->s390_sieic.ipa & 0x00ff;
@@ -732,8 +748,11 @@ static void handle_instruction(S390CPU *cpu, struct kvm_run *run)
}
if (r < 0) {
+ r = 0;
enter_pgmcheck(cpu, 0x0001);
}
+
+ return r;
}
static bool is_special_wait_psw(CPUState *cs)
@@ -753,7 +772,7 @@ static int handle_intercept(S390CPU *cpu)
(long)cs->kvm_run->psw_addr);
switch (icpt_code) {
case ICPT_INSTRUCTION:
- handle_instruction(cpu, run);
+ r = handle_instruction(cpu, run);
break;
case ICPT_WAITPSW:
/* disabled wait, since enabled wait is handled in kernel */