Skip to contentSkip to conversation

Add gdb break point support to PowerPC kvm

PATCH Superseded Jerone Young 1 participant 1 message Jun 6, 2008

Subsystems (2)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Add gdb break point support to PowerPC kvm

4 files changed, 138 insertions(+), 2 deletions(-)
arch/powerpc/kvm/booke_guest.c      |   25 ++++++++
arch/powerpc/kvm/booke_interrupts.S |    3 
arch/powerpc/kvm/powerpc.c          |  107 ++++++++++++++++++++++++++++++++++-
include/asm-powerpc/kvm_host.h      |    5 +

# HG changeset patch
# User Jerone Young <[email protected]>
# Date 1212783178 18000
# Node ID aa3df6c6777041e6662173ee84f0557707691640 # Parent 907554fde798d0dc03ba21901dab5471ade3e829 [v2] Add gdb break point support to PowerPC kvm

This patch adds the ability to use breakpoints from a gdb stub in userpace (currently qemu). It does this through the use of hardware debug registers.

arch/powerpc/kvm/booke_guest.c +25 -0
@@ -410,6 +410,31 @@ int kvmppc_handle_exit(struct kvm_run *r
 		break;
 	}
 
+	case BOOKE_INTERRUPT_DEBUG: {
+		u32 dbsr;
+		struct kvm_guest_debug *dbg = &vcpu->guest_debug;
+
+		vcpu->arch.pc = mfspr(SPRN_CSRR0);
+
+		/* clear events in DBSR register */
+		dbsr = mfspr(SPRN_DBSR);
+
+		if (vcpu->arch.pc = dbg->bp[0])
+			dbsr |= DBSR_IAC1; 
+		if (vcpu->arch.pc = dbg->bp[1])
+			dbsr |= DBSR_IAC2; 
+		if (vcpu->arch.pc = dbg->bp[2])
+			dbsr |= DBSR_IAC3;
+		if (vcpu->arch.pc = dbg->bp[3])
+			dbsr |= DBSR_IAC4;
+
+		mtspr (SPRN_DBSR, dbsr);
+
+		run->exit_reason = KVM_EXIT_DEBUG;
+		r = RESUME_HOST;
+		break;
+	}
+
 	default:
 		printk(KERN_EMERG "exit_nr %d\n", exit_nr);
 		BUG();
arch/powerpc/kvm/booke_interrupts.S +2 -1
@@ -42,7 +42,8 @@
 #define HOST_STACK_LR   (HOST_STACK_SIZE + 4) /* In caller stack frame. */
 
 #define NEED_INST_MASK ((1<<BOOKE_INTERRUPT_PROGRAM) | \
-                        (1<<BOOKE_INTERRUPT_DTLB_MISS))
+                        (1<<BOOKE_INTERRUPT_DTLB_MISS) | \
+                        (1<<BOOKE_INTERRUPT_DEBUG))
 
 #define NEED_DEAR_MASK ((1<<BOOKE_INTERRUPT_DATA_STORAGE) | \
                         (1<<BOOKE_INTERRUPT_DTLB_MISS))
arch/powerpc/kvm/powerpc.c +106 -1

124 lines not on this page · raw message

include/asm-powerpc/kvm_host.h +5 -0
@@ -84,6 +84,11 @@ struct kvm_vcpu_arch {
 
 	u32 host_stack;
 	u32 host_pid;
+	u32 host_dbcr0;
+	u32 host_dbcr1;
+	u32 host_dbcr2;
+	u32 host_iac[4];
+	u32 host_msr;
 
 	u64 fpr[32];
 	u32 gpr[32];