Add gdb break point support to PowerPC kvm
Subsystems (2)
PATCH v5 1/1 Add gdb break point support to PowerPC kvm
4 files changed, 128 insertions(+), 2 deletions(-) arch/powerpc/kvm/booke_guest.c | 16 +++++ arch/powerpc/kvm/booke_interrupts.S | 3 arch/powerpc/kvm/powerpc.c | 106 ++++++++++++++++++++++++++++++++++- include/asm-powerpc/kvm_host.h | 5 +
* Boiled down conditional for dbsr to one line, when handling debug interrupts. Renamed load_guest_debug_registers() to guest_load_debug_registers()
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 +16 -0
@@ -410,6 +410,22 @@ int kvmppc_handle_exit(struct kvm_run *rbreak ; } +case BOOKE_INTERRUPT_DEBUG : { +u32 dbsr; + + vcpu->arch.pc =mfspr (SPRN_CSRR0 ); + +/* clear IAC events in DBSR register */ + dbsr =mfspr (SPRN_DBSR ); + + dbsr &= (DBSR_IAC1 |DBSR_IAC2 |DBSR_IAC3 |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 +105 -1
123 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 ];
Quoted 7 lines · Jerone Young
4 files changed, 128 insertions(+), 2 deletions(-) arch/powerpc/kvm/booke_guest.c | 16 +++++ arch/powerpc/kvm/booke_interrupts.S | 3 arch/powerpc/kvm/powerpc.c | 106 ++++++++++++++++++++++++++++++++++- include/asm-powerpc/kvm_host.h | 5 +
Quoted 6 lines
* Boiled down conditional for dbsr to one line, when handling debug interrupts. Renamed
load_guest_debug_registers()toguest_load_debug_registers()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.
Signed-off-by Jerone Young <[email protected]>
You still have not renamed restore_host_debug_state() and guest_load_debug_registers(), which you agreed to previously.
You still have not renamed guest_debug(), which you also agreed to previously. I don't see why you have a separate function for this anyways.
You also have not addressed the case I pointed out where an IAC matches after you've programmed it but before you've entered the guest.
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 11 lines · Hollis Blanchard
Quoted 10 lines · Jerone Young
4 files changed, 128 insertions(+), 2 deletions(-) arch/powerpc/kvm/booke_guest.c | 16 +++++ arch/powerpc/kvm/booke_interrupts.S | 3 arch/powerpc/kvm/powerpc.c | 106 ++++++++++++++++++++++++++++++++++- include/asm-powerpc/kvm_host.h | 5 +* Boiled down conditional for dbsr to one line, when handling debug interrupts. Renamed
load_guest_debug_registers()toguest_load_debug_registers()
Quoted 6 lines
Quoted 3 lines
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.
Signed-off-by Jerone Young <[email protected]>You still have not renamed
restore_host_debug_state()andguest_load_debug_registers(), which you agreed to previously.
My bad. I was mainly just addressing the issues we went over this morning. I'll fix the names.
Quoted 7 lines
You still have not renamed
guest_debug(), which you also agreed to previously. I don't see why you have a separate function for this anyways.You also have not addressed the case I pointed out where an IAC matches after you've programmed it but before you've entered the guest.
Basically can disable them in the dbcr0 before we do any switching out of registers.
If an IAC is matched before we enter the guest it will be caught host that catches it.
Quoted 7 lines · Jerone Young
Quoted 2 lines
You also have not addressed the case I pointed out where an IAC
matches
Quoted 1 line
after you've programmed it but before you've entered the guest.
Basically can disable them in the dbcr0 before we do any switching out of registers.
We'll have to enable DBCR0 some time, right?
Quoted 2 lines
If an IAC is matched before we enter the guest it will be caught host that catches it.
But that won't happen because you've disabled MSR[DE].
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 11 lines · Hollis Blanchard
Quoted 7 lines · Jerone Young
Quoted 2 lines
You also have not addressed the case I pointed out where an IAC
matches
Quoted 1 line
after you've programmed it but before you've entered the guest.
Basically can disable them in the dbcr0 before we do any switching out of registers.
We'll have to enable DBCR0 some time, right?
Yes it gets enabled when when the guest cuts on the bits it wants & the we restre the host DBCR0.
Quoted 4 lines
Quoted 2 lines
If an IAC is matched before we enter the guest it will be caught host that catches it.
But that won't happen because you've disabled MSR[DE].
Ah... you don't rember the whole imprecise interrupts ;-) . When MSR[DE] =0 and an IAC will go off but not at the exact address. This was fun figuring out.
I also have a bug in this patch. I placed the wrong definitions when disabling the debug interrupts. I'll respin again. Look things over more carefully this time.
Quoted 1 line
Quoted 16 lines · Jerone Young
Quoted 11 lines · Hollis Blanchard
Quoted 7 lines · Jerone Young
Quoted 2 lines
You also have not addressed the case I pointed out where an IAC
matches
Quoted 1 line
after you've programmed it but before you've entered the guest.
Basically can disable them in the dbcr0 before we do any switching out of registers.
We'll have to enable DBCR0 some time, right?
Yes it gets enabled when when the guest cuts on the bits it wants & the we restre the host DBCR0.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If an IAC is matched before we enter the guest it will be caught host that catches it.
But that won't happen because you've disabled MSR[DE].
Ah... you don't rember the whole imprecise interrupts ;-) . When MSR[DE] =0 and an IAC will go off but not at the exact address. This was fun figuring out.
Right. Now, when will the deferred debug event fire, and who will handle it? What can we do about that?
Quoted 3 lines
I also have a bug in this patch. I placed the wrong definitions when disabling the debug interrupts. I'll respin again. Look things over more carefully this time.
I think you're respinning these patches too frequently, before conversation has concluded.
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 20 lines · Hollis Blanchard
Quoted 19 lines · Jerone Young
Quoted 11 lines · Hollis Blanchard
Quoted 7 lines · Jerone Young
Quoted 2 lines
You also have not addressed the case I pointed out where an IAC
matches
Quoted 1 line
after you've programmed it but before you've entered the guest.
Basically can disable them in the dbcr0 before we do any switching out of registers.
We'll have to enable DBCR0 some time, right?
Yes it gets enabled when when the guest cuts on the bits it wants & the we restre the host DBCR0.
Quoted 3 lines
Quoted 2 lines
If an IAC is matched before we enter the guest it will be caught host that catches it.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
But that won't happen because you've disabled MSR[DE].
Ah... you don't rember the whole imprecise interrupts ;-) . When MSR[DE] =0 and an IAC will go off but not at the exact address. This was fun figuring out.
Right. Now, when will the deferred debug event fire, and who will handle it? What can we do about that?
If the debug registers are turned off before we disable MSR[DE], there will be no debug events at all.
This is what I was talking about in my first couple of emails. If a debug event does go off and the host does not handle it, the only way to know is the dbsr register (and there is no way to save that off). So in the end it could end up going off in the guest.
This is why I said you should not do host debugging if you want to do guest debugging at the sametime, as a work around for now.
Really can be addressed in a patch on top of this patch. Though I really don't want to linger on this problem as it is not critical at the moment as nobody is using these registers in the host currently.
I can clear the dbsr registers also when disabling the debug interrupts as a solution?
Quoted 7 lines
Quoted 4 lines
I also have a bug in this patch. I placed the wrong definitions when disabling the debug interrupts. I'll respin again. Look things over more carefully this time.
I think you're respinning these patches too frequently, before conversation has concluded.
I think respining has helped in the conversation to be honest. As I can better demonstrate what I am thinking (though better without mistakes). Also I figured this was concluded. I will not spin anymore patches till we can agree on an answer for everything.
Quoted 17 lines · Jerone Young
Quoted 4 lines · Hollis Blanchard
Quoted 3 lines · Jerone Young
Quoted 3 lines
Quoted 2 lines
If an IAC is matched before we enter the guest it will be caught host that catches it.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
But that won't happen because you've disabled MSR[DE].
Ah... you don't rember the whole imprecise interrupts ;-) . When MSR[DE] =0 and an IAC will go off but not at the exact address. This was fun figuring out.
Right. Now, when will the deferred debug event fire, and who will handle it? What can we do about that?
If the debug registers are turned off before we disable MSR[DE], there will be no debug events at all.
Quoted 7 lines
This is what I was talking about in my first couple of emails. If a debug event does go off and the host does not handle it, the only way to know is the dbsr register (and there is no way to save that off). So in the end it could end up going off in the guest.
This is why I said you should not do host debugging if you want to do guest debugging at the sametime, as a work around for now.
As I said before, forget host debugging!
In fact, here is the exact text I sent to you on Friday, which you don't appear to have read, in which I said exactly the same thing:
On Fri, 2008-06-06 at 14:27 -0500, Hollis Blanchard wrote:
Quoted 7 lines
On Fri, 2008-06-06 at 14:11 -0500, Jerone Young wrote:
> That is an issue if you are using the IAC registers in the host also > at the same time.That is a totally separate issue. Imagine this in the host:
0xc0001000load_guest_debug_registers:
Quoted 8 lines
MSR[DE] = 0 IAC[0] = 0xc0001080 ... 0xc0001080 ... enter guestIAC1 matched. Now what happens?
Please think about this scenario.
Quoted 2 lines
I can clear the dbsr registers also when disabling the debug interrupts as a solution?
I think you're on the right track, but what you propose here simply won't affect the above scenario.
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 23 lines · Hollis Blanchard
Quoted 22 lines · Jerone Young
Quoted 4 lines · Hollis Blanchard
Quoted 3 lines · Jerone Young
Quoted 3 lines
Quoted 2 lines
If an IAC is matched before we enter the guest it will be caught host that catches it.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
But that won't happen because you've disabled MSR[DE].
Ah... you don't rember the whole imprecise interrupts ;-) . When MSR[DE] =0 and an IAC will go off but not at the exact address. This was fun figuring out.
Right. Now, when will the deferred debug event fire, and who will handle it? What can we do about that?
If the debug registers are turned off before we disable MSR[DE], there will be no debug events at all.
This is what I was talking about in my first couple of emails. If a debug event does go off and the host does not handle it, the only way to know is the dbsr register (and there is no way to save that off). So in the end it could end up going off in the guest.
Quoted 4 lines
Quoted 2 lines
This is why I said you should not do host debugging if you want to do guest debugging at the sametime, as a work around for now.
As I said before, forget host debugging!
If it's not about host debugging then I'm confused where you are going with this. Please be more clear.
Quoted 19 lines
In fact, here is the exact text I sent to you on Friday, which you don't appear to have read, in which I said exactly the same thing:
On Fri, 2008-06-06 at 14:27 -0500, Hollis Blanchard wrote:
Quoted 14 lines
On Fri, 2008-06-06 at 14:11 -0500, Jerone Young wrote:
> That is an issue if you are using the IAC registers in the host also > at the same time.That is a totally separate issue. Imagine this in the host:
0xc0001000load_guest_debug_registers:MSR[DE] = 0 IAC[0] = 0xc0001080 ... 0xc0001080 ... enter guest
Quoted 3 lines
Quoted 1 line
IAC1 matched. Now what happens?
Please think about this scenario.
Again I'm lost on where you are going here. We are in the guest it matches. I'm not sure what you are trying to say here?
Quoted 7 lines
Quoted 3 lines
I can clear the dbsr registers also when disabling the debug interrupts as a solution?
I think you're on the right track, but what you propose here simply won't affect the above scenario.
Quoted 46 lines · Hollis Blanchard
Quoted 17 lines · Jerone Young
Quoted 4 lines · Hollis Blanchard
Quoted 3 lines · Jerone Young
Quoted 3 lines
Quoted 2 lines
If an IAC is matched before we enter the guest it will be caught host that catches it.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
But that won't happen because you've disabled MSR[DE].
Ah... you don't rember the whole imprecise interrupts ;-) . When MSR[DE] =0 and an IAC will go off but not at the exact address. This was fun figuring out.
Right. Now, when will the deferred debug event fire, and who will handle it? What can we do about that?
If the debug registers are turned off before we disable MSR[DE], there will be no debug events at all.
Quoted 7 lines
This is what I was talking about in my first couple of emails. If a debug event does go off and the host does not handle it, the only way to know is the dbsr register (and there is no way to save that off). So in the end it could end up going off in the guest.
This is why I said you should not do host debugging if you want to do guest debugging at the sametime, as a work around for now.
As I said before, forget host debugging!
In fact, here is the exact text I sent to you on Friday, which you don't appear to have read, in which I said exactly the same thing:
On Fri, 2008-06-06 at 14:27 -0500, Hollis Blanchard wrote:
Quoted 14 lines
On Fri, 2008-06-06 at 14:11 -0500, Jerone Young wrote:
> That is an issue if you are using the IAC registers in the host also > at the same time.That is a totally separate issue. Imagine this in the host:
0xc0001000load_guest_debug_registers:MSR[DE] = 0 IAC[0] = 0xc0001080 ... 0xc0001080 ... enter guest
Quoted 3 lines
Quoted 1 line
IAC1 matched. Now what happens?
Please think about this scenario.
Oh it hit me. So we *could* get an imprecise interrupt once we enable dbcr0.
So do you want to enable dbcr0 once we enable MSR_DE in __kvmppc_vcpu_run() ?
(In the future please just plainly state the issue..it saves emails..which I guess saves trees .. in someway).
Quoted 7 lines
Quoted 3 lines
I can clear the dbsr registers also when disabling the debug interrupts as a solution?
I think you're on the right track, but what you propose here simply won't affect the above scenario.