[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/5 v4] ppc: Add debug interrupt injection handler
From: |
Bharat Bhushan |
Subject: |
[Qemu-devel] [PATCH 3/5 v4] ppc: Add debug interrupt injection handler |
Date: |
Thu, 26 Jun 2014 10:41:27 +0530 |
With this patch a debug interrupt can be injected to guest.
Follow up patch will use this interface to inject debug
interrupt to guest if qemu will not be able to handle.
Signed-off-by: Bharat Bhushan <address@hidden>
---
v3->v4:
- No Change
target-ppc/kvm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 70f77d1..5238de7 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -759,11 +759,59 @@ static int kvm_put_vpa(CPUState *cs)
}
#endif /* TARGET_PPC64 */
-static int kvmppc_inject_debug_exception(CPUState *cs)
+static int kvmppc_e500_inject_debug_exception(CPUState *cs)
{
+ PowerPCCPU *cpu = POWERPC_CPU(cs);
+ CPUPPCState *env = &cpu->env;
+ struct kvm_sregs sregs;
+ int ret;
+
+ if (!cap_booke_sregs) {
+ return -1;
+ }
+
+ ret = kvm_vcpu_ioctl(cs, KVM_GET_SREGS, &sregs);
+ if (ret < 0) {
+ return -1;
+ }
+
+ if (sregs.u.e.features & KVM_SREGS_E_ED) {
+ sregs.u.e.dsrr0 = env->nip;
+ sregs.u.e.dsrr1 = env->msr;
+ } else {
+ sregs.u.e.csrr0 = env->nip;
+ sregs.u.e.csrr1 = env->msr;
+ }
+
+ sregs.u.e.update_special = KVM_SREGS_E_UPDATE_DBSR;
+ sregs.u.e.dbsr = env->spr[SPR_BOOKE_DBSR];
+
+ ret = kvm_vcpu_ioctl(cs, KVM_SET_SREGS, &sregs);
+ if (ret < 0) {
+ return -1;
+ }
+
return 0;
}
+static int kvmppc_inject_debug_exception(CPUState *cs)
+{
+ PowerPCCPU *cpu = POWERPC_CPU(cs);
+ CPUPPCState *env = &cpu->env;
+ int ret = -1;
+
+ switch (env->excp_model) {
+ case POWERPC_EXCP_BOOKE:
+ ret = kvmppc_e500_inject_debug_exception(cs);
+ break;
+ default:
+ fprintf(stderr, "%s: Invalid exception model %d\n",
+ __func__, env->excp_model);
+ break;
+ }
+ return ret;
+}
+
static void kvmppc_inject_exception(CPUState *cs)
{
PowerPCCPU *cpu = POWERPC_CPU(cs);
@@ -772,8 +820,9 @@ static void kvmppc_inject_exception(CPUState *cs)
if (env->pending_interrupts & (1 << PPC_INTERRUPT_DEBUG)) {
if (kvmppc_inject_debug_exception(cs)) {
fprintf(stderr, "%s: Debug exception injection failed\n",
__func__);
+ return;
}
- return;
+ env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DEBUG);
}
}
--
1.9.0