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)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 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 1212785322 18000
# Node ID c5506b990f6a32d3b099396acdfd9ab6e10c3a51 # Parent 907554fde798d0dc03ba21901dab5471ade3e829 [v4] Add gdb break point support to PowerPC kvm

* Got trigger happy and left some debug statements in the last patch. Also was not manipulating dbsr with proper variable.

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;
+		u32 dbsr_mask = 0;
+
+		vcpu->arch.pc = mfspr(SPRN_CSRR0);
+
+		/* clear events in DBSR register */
+		dbsr = mfspr(SPRN_DBSR);
+
+		if (dbsr & DBSR_IAC1)
+			dbsr_mask |= DBSR_IAC1; 
+		if (dbsr & DBSR_IAC2)
+			dbsr_mask |= DBSR_IAC2; 
+		if (dbsr & DBSR_IAC3)
+			dbsr_mask |= DBSR_IAC3;
+		if (dbsr & DBSR_IAC4)
+			dbsr_mask |= DBSR_IAC4;
+
+		mtspr (SPRN_DBSR, dbsr_mask);
+
+		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];