Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-10-04 Thread Alexander Graf

On 04.10.2012, at 17:19, Bhushan Bharat-R65777 wrote:

> 
> 
>>> -static int emulation_exit(struct kvm_run *run, struct kvm_vcpu
>>> *vcpu)
>>> +static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
>>> + int exit_nr)
>>> {
>>> enum emulation_result er;
>>> 
>>> +   if (unlikely(vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) &&
>>> +vcpu->arch.last_inst == KVMPPC_INST_GUEST_GDB) {
>> 
>> This belongs into the normal emulation code path, behind the same
>> switch() that everything else goes through.
> 
> I am not sure I understood correctly. Below is the reason why I
> placed this
 code here.
> Instruction where software breakpoint is to be set is replaced by "ehpriv"
 instruction. On e500v2, this is not a valid instruction can causes
 program interrupt. On e500mc, "ehpriv" is a valid instruction. Both
 the exit path calls emulation_exit(), so we have placed the code in this
>> function.
> Do you want this code to be moved in program interrupt exit path for
> e500v2
 and BOOKE_INTERRUPT_HV_PRIV for e500mc?
 
 Ok, in this patch you do (basically):
 
 int emulation_exit()
 {
   if (inst == DEBUG_INST) {
   debug_stuff();
   return;
   }
 
   switch (inst) {
   case INST_A:
   foo();
   
   }
 }
>>> 
>>> Are not we doing something like this:
>>> int emulation_exit()
>>> {
>>>if (inst == DEBUG_INST) {
>>>debug_stuff();
>>>return;
>>>}
>>> 
>>>status = kvmppc_emulate_instruction()
>>>switch (status) {
>>>case FAIL:
>>>foo();
>>>case DONE:
>>> foo1();
>>>
>>>}
>>> }
>>> 
>>> Do you want something like this:
>>> 
>>> int emulation_exit()
>>> {
>>> 
>>>status = kvmppc_emulate_instruction()
>>>switch (status) {
>>>case FAIL:
>>> if (inst == DEBUG_INST) {
>>> debug_stuff();
>>>   return;
>>> }
>>>foo();
>>> 
>>>case DONE:
>>> foo1();
>>>
>>>}
>>> }
>> 
>> No, I want the DEBUG_INST be handled the same as any other instruction we
>> emulate.
> 
> I would like to understand what you are thinking:
> What I derived is , add the instruction in kvmppc_emulate_instruction() (or 
> its child function) which, 
> 1) fill the relevant information in run-> , kvmppc_account_exit(vcpu, 
> DEBUG_EXITS); and returns EMULATION_DONE
> And in emulation_exit()
> status = kvmppc_emulate_instruction()
> switch (status) {
>   case EMULATION_DONE:
>   if (inst == DEBUG)
>   return RESUME_HOST;
> }
> Or
> 2) kvmppc_account_exit(vcpu, DEBUG_EXITS); returns EMULATION_DONE;
> And in emulation_exit()
> status = kvmppc_emulate_instruction()
> switch (status) {
>   case EMULATION_DONE:
>   if (inst == DEBUG) {
>   fill run-> 
>   return RESUME_HOST;
>   }
> }
> 
> Or
> 3) kvmppc_account_exit(vcpu, DEBUG_EXITS); returns a new status type 
> (EMULATION_DEBUG_INST)
> And in emulation_exit()
> status = kvmppc_emulate_instruction()
> switch (status) {
>   case EMULATION_DEBUG_INST:
>   fill run-> 
>   return RESUME_HOST;
> }

This one :).

> 
>> 
 
 what I want is:
 
 int emulation_exit()
 {
   switch (inst) {
   case INST_A:
   foo(); break;
   case DEBUG_INST:
   debug_stuff(); break;
   
   }
 }
 
> 
> 
>> 
>>> +   run->exit_reason = KVM_EXIT_DEBUG;
>>> +   run->debug.arch.pc = vcpu->arch.pc;
>>> +   run->debug.arch.exception = exit_nr;
>>> +   run->debug.arch.status = 0;
>>> +   kvmppc_account_exit(vcpu, DEBUG_EXITS);
>>> +   return RESUME_HOST;
>>> +   }
>>> +
>>> er = kvmppc_emulate_instruction(run, vcpu);
>>> switch (er) {
>>> case EMULATE_DONE:
>>> @@ -697,6 +711,44 @@ static int emulation_exit(struct kvm_run
>>> *run, struct
>> kvm_vcpu *vcpu)
>>> default:
>>> BUG();
>>> }
>>> +
>>> +   if (unlikely(vcpu->guest_debug & KVM_GUESTDBG_ENABLE) &&
>>> +   (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)) {
>> 
>> I don't understand how this is supposed to work. When we enable
>> singlestep, why would we end up in emulation_exit()?
> 
> When singlestep is enabled then we set DBCR0[ICMP] and the debug
> handler
 should be able to handle this. I think you are right.
> 
>> 
>>> +   run->exit_reason = KVM_EXIT_DEBUG;
>>> +   return RES

RE: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-10-04 Thread Bhushan Bharat-R65777


> > -static int emulation_exit(struct kvm_run *run, struct kvm_vcpu
> > *vcpu)
> > +static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
> > + int exit_nr)
> > {
> > enum emulation_result er;
> >
> > +   if (unlikely(vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) &&
> > +vcpu->arch.last_inst == KVMPPC_INST_GUEST_GDB) {
> 
>  This belongs into the normal emulation code path, behind the same
>  switch() that everything else goes through.
> >>>
> >>> I am not sure I understood correctly. Below is the reason why I
> >>> placed this
> >> code here.
> >>> Instruction where software breakpoint is to be set is replaced by "ehpriv"
> >> instruction. On e500v2, this is not a valid instruction can causes
> >> program interrupt. On e500mc, "ehpriv" is a valid instruction. Both
> >> the exit path calls emulation_exit(), so we have placed the code in this
> function.
> >>> Do you want this code to be moved in program interrupt exit path for
> >>> e500v2
> >> and BOOKE_INTERRUPT_HV_PRIV for e500mc?
> >>
> >> Ok, in this patch you do (basically):
> >>
> >> int emulation_exit()
> >> {
> >>if (inst == DEBUG_INST) {
> >>debug_stuff();
> >>return;
> >>}
> >>
> >>switch (inst) {
> >>case INST_A:
> >>foo();
> >>
> >>}
> >> }
> >
> > Are not we doing something like this:
> > int emulation_exit()
> > {
> > if (inst == DEBUG_INST) {
> > debug_stuff();
> > return;
> > }
> >
> > status = kvmppc_emulate_instruction()
> > switch (status) {
> > case FAIL:
> > foo();
> > case DONE:
> > foo1();
> > 
> > }
> > }
> >
> > Do you want something like this:
> >
> > int emulation_exit()
> > {
> >
> > status = kvmppc_emulate_instruction()
> > switch (status) {
> > case FAIL:
> > if (inst == DEBUG_INST) {
> > debug_stuff();
> >   return;
> > }
> > foo();
> >
> > case DONE:
> > foo1();
> > 
> > }
> > }
> 
> No, I want the DEBUG_INST be handled the same as any other instruction we
> emulate.

I would like to understand what you are thinking:
What I derived is , add the instruction in kvmppc_emulate_instruction() (or its 
child function) which, 
1) fill the relevant information in run-> , kvmppc_account_exit(vcpu, 
DEBUG_EXITS); and returns EMULATION_DONE
 And in emulation_exit()
 status = kvmppc_emulate_instruction()
 switch (status) {
case EMULATION_DONE:
if (inst == DEBUG)
return RESUME_HOST;
 }
 Or
2) kvmppc_account_exit(vcpu, DEBUG_EXITS); returns EMULATION_DONE;
And in emulation_exit()
 status = kvmppc_emulate_instruction()
 switch (status) {
case EMULATION_DONE:
if (inst == DEBUG) {
fill run-> 
return RESUME_HOST;
}
 }

Or
3) kvmppc_account_exit(vcpu, DEBUG_EXITS); returns a new status type 
(EMULATION_DEBUG_INST)
And in emulation_exit()
 status = kvmppc_emulate_instruction()
 switch (status) {
case EMULATION_DEBUG_INST:
fill run-> 
return RESUME_HOST;
 }

> 
> >>
> >> what I want is:
> >>
> >> int emulation_exit()
> >> {
> >>switch (inst) {
> >>case INST_A:
> >>foo(); break;
> >>case DEBUG_INST:
> >>debug_stuff(); break;
> >>
> >>}
> >> }
> >>
> >>>
> >>>
> 
> > +   run->exit_reason = KVM_EXIT_DEBUG;
> > +   run->debug.arch.pc = vcpu->arch.pc;
> > +   run->debug.arch.exception = exit_nr;
> > +   run->debug.arch.status = 0;
> > +   kvmppc_account_exit(vcpu, DEBUG_EXITS);
> > +   return RESUME_HOST;
> > +   }
> > +
> > er = kvmppc_emulate_instruction(run, vcpu);
> > switch (er) {
> > case EMULATE_DONE:
> > @@ -697,6 +711,44 @@ static int emulation_exit(struct kvm_run
> > *run, struct
>  kvm_vcpu *vcpu)
> > default:
> > BUG();
> > }
> > +
> > +   if (unlikely(vcpu->guest_debug & KVM_GUESTDBG_ENABLE) &&
> > +   (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)) {
> 
>  I don't understand how this is supposed to work. When we enable
>  singlestep, why would we end up in emulation_exit()?
> >>>
> >>> When singlestep is enabled then we set DBCR0[ICMP] and the debug
> >>> handler
> >> should be able to handle this. I think you are right.
> >>>
> 
> > +   run->exit_reason = KVM_EXIT_DEBUG;
> > +   return RESUME_HOST;
> > +   }
> > +}
> > +
> > +static int kvmppc_handle_debug(st

Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-10-04 Thread Alexander Graf

On 04.10.2012, at 16:22, Bhushan Bharat-R65777 wrote:

> 
> 
>> -Original Message-
>> From: Alexander Graf [mailto:ag...@suse.de]
>> Sent: Thursday, October 04, 2012 4:56 PM
>> To: Bhushan Bharat-R65777
>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>> 
>> 
>> On 04.10.2012, at 13:06, Bhushan Bharat-R65777 wrote:
>> 
>>> 
>>> 
>>>> -Original Message-
>>>> From: Alexander Graf [mailto:ag...@suse.de]
>>>> Sent: Monday, September 24, 2012 9:50 PM
>>>> To: Bhushan Bharat-R65777
>>>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan
>>>> Bharat-R65777
>>>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>>>> 
>>>> 
>>>> On 21.08.2012, at 15:52, Bharat Bhushan wrote:
>>>> 
>>>>> This patch adds the debug stub support on booke/bookehv.
>>>>> Now QEMU debug stub can use hw breakpoint, watchpoint and software
>>>>> breakpoint to debug guest.
>>>>> 
>>>>> Signed-off-by: Bharat Bhushan 
>>>>> ---
>>>>> arch/powerpc/include/asm/kvm.h|   29 ++-
>>>>> arch/powerpc/include/asm/kvm_host.h   |5 +
>>>>> arch/powerpc/kernel/asm-offsets.c |   26 ++
>>>>> arch/powerpc/kvm/booke.c  |  144 
>>>>> +--
>> --
>>>>> arch/powerpc/kvm/booke_interrupts.S   |  110 +
>>>>> arch/powerpc/kvm/bookehv_interrupts.S |  141
>> +++-
>>>>> arch/powerpc/kvm/e500mc.c |3 +-
>>>>> 7 files changed, 435 insertions(+), 23 deletions(-)
>>>>> 
>>>>> diff --git a/arch/powerpc/include/asm/kvm.h
>>>>> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
>>>>> --- a/arch/powerpc/include/asm/kvm.h
>>>>> +++ b/arch/powerpc/include/asm/kvm.h
>>>>> @@ -25,6 +25,7 @@
>>>>> /* Select powerpc specific features in  */ #define
>>>>> __KVM_HAVE_SPAPR_TCE #define __KVM_HAVE_PPC_SMT
>>>>> +#define __KVM_HAVE_GUEST_DEBUG
>>>>> 
>>>>> struct kvm_regs {
>>>>>   __u64 pc;
>>>>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>>>>   __u64 fpr[32];
>>>>> };
>>>>> 
>>>>> +
>>>>> +/*
>>>>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>>>>> + * software breakpoint.
>>>>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
>>>>> + * for KVM_DEBUG_EXIT.
>>>>> + */
>>>>> +#define KVMPPC_DEBUG_NONE0x0
>>>>> +#define KVMPPC_DEBUG_BREAKPOINT  (1UL << 1)
>>>>> +#define KVMPPC_DEBUG_WATCH_WRITE (1UL << 2)
>>>>> +#define KVMPPC_DEBUG_WATCH_READ  (1UL << 3)
>>>>> struct kvm_debug_exit_arch {
>>>>> + __u64 pc;
>>>>> + /*
>>>>> +  * exception -> returns the exception number. If the KVM_DEBUG_EXIT
>>>>> +  * exit is not handled (say not h/w breakpoint or software breakpoint
>>>>> +  * set for this address) by qemu then it is supposed to inject this
>>>>> +  * exception to guest.
>>>>> +  */
>>>>> + __u32 exception;
>>>>> + /*
>>>>> +  * exiting to userspace because of h/w breakpoint, watchpoint
>>>>> +  * (read, write or both) and software breakpoint.
>>>>> +  */
>>>>> + __u32 status;
>>>>> };
>>>>> 
>>>>> /* for KVM_SET_GUEST_DEBUG */
>>>>> @@ -276,10 +301,6 @@ struct kvm_guest_debug_arch {
>>>>>* Type denotes h/w breakpoint, read watchpoint, write
>>>>>* watchpoint or watchpoint (both read and write).
>>>>>*/
>>>>> -#define KVMPPC_DEBUG_NOTYPE  0x0
>>>>> -#define KVMPPC_DEBUG_BREAKPOINT  (1UL << 1)
>>>>> -#define KVMPPC_DEBUG_WATCH_WRITE (1UL << 2)
>>>>> -#define KVMPPC_DEBUG_WATCH_READ  (1UL << 3)
>>>>>   __u32 type;
>>>>>   __u32 pad1;
>>>>>   __u64 pad2;
>>

RE: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-10-04 Thread Bhushan Bharat-R65777


> -Original Message-
> From: Alexander Graf [mailto:ag...@suse.de]
> Sent: Thursday, October 04, 2012 4:56 PM
> To: Bhushan Bharat-R65777
> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
> 
> 
> On 04.10.2012, at 13:06, Bhushan Bharat-R65777 wrote:
> 
> >
> >
> >> -Original Message-
> >> From: Alexander Graf [mailto:ag...@suse.de]
> >> Sent: Monday, September 24, 2012 9:50 PM
> >> To: Bhushan Bharat-R65777
> >> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan
> >> Bharat-R65777
> >> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
> >>
> >>
> >> On 21.08.2012, at 15:52, Bharat Bhushan wrote:
> >>
> >>> This patch adds the debug stub support on booke/bookehv.
> >>> Now QEMU debug stub can use hw breakpoint, watchpoint and software
> >>> breakpoint to debug guest.
> >>>
> >>> Signed-off-by: Bharat Bhushan 
> >>> ---
> >>> arch/powerpc/include/asm/kvm.h|   29 ++-
> >>> arch/powerpc/include/asm/kvm_host.h   |5 +
> >>> arch/powerpc/kernel/asm-offsets.c |   26 ++
> >>> arch/powerpc/kvm/booke.c  |  144 
> >>> +--
> --
> >>> arch/powerpc/kvm/booke_interrupts.S   |  110 +
> >>> arch/powerpc/kvm/bookehv_interrupts.S |  141
> +++-
> >>> arch/powerpc/kvm/e500mc.c |3 +-
> >>> 7 files changed, 435 insertions(+), 23 deletions(-)
> >>>
> >>> diff --git a/arch/powerpc/include/asm/kvm.h
> >>> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
> >>> --- a/arch/powerpc/include/asm/kvm.h
> >>> +++ b/arch/powerpc/include/asm/kvm.h
> >>> @@ -25,6 +25,7 @@
> >>> /* Select powerpc specific features in  */ #define
> >>> __KVM_HAVE_SPAPR_TCE #define __KVM_HAVE_PPC_SMT
> >>> +#define __KVM_HAVE_GUEST_DEBUG
> >>>
> >>> struct kvm_regs {
> >>>   __u64 pc;
> >>> @@ -264,7 +265,31 @@ struct kvm_fpu {
> >>>   __u64 fpr[32];
> >>> };
> >>>
> >>> +
> >>> +/*
> >>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
> >>> + * software breakpoint.
> >>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
> >>> + * for KVM_DEBUG_EXIT.
> >>> + */
> >>> +#define KVMPPC_DEBUG_NONE0x0
> >>> +#define KVMPPC_DEBUG_BREAKPOINT  (1UL << 1)
> >>> +#define KVMPPC_DEBUG_WATCH_WRITE (1UL << 2)
> >>> +#define KVMPPC_DEBUG_WATCH_READ  (1UL << 3)
> >>> struct kvm_debug_exit_arch {
> >>> + __u64 pc;
> >>> + /*
> >>> +  * exception -> returns the exception number. If the KVM_DEBUG_EXIT
> >>> +  * exit is not handled (say not h/w breakpoint or software breakpoint
> >>> +  * set for this address) by qemu then it is supposed to inject this
> >>> +  * exception to guest.
> >>> +  */
> >>> + __u32 exception;
> >>> + /*
> >>> +  * exiting to userspace because of h/w breakpoint, watchpoint
> >>> +  * (read, write or both) and software breakpoint.
> >>> +  */
> >>> + __u32 status;
> >>> };
> >>>
> >>> /* for KVM_SET_GUEST_DEBUG */
> >>> @@ -276,10 +301,6 @@ struct kvm_guest_debug_arch {
> >>>* Type denotes h/w breakpoint, read watchpoint, write
> >>>* watchpoint or watchpoint (both read and write).
> >>>*/
> >>> -#define KVMPPC_DEBUG_NOTYPE  0x0
> >>> -#define KVMPPC_DEBUG_BREAKPOINT  (1UL << 1)
> >>> -#define KVMPPC_DEBUG_WATCH_WRITE (1UL << 2)
> >>> -#define KVMPPC_DEBUG_WATCH_READ  (1UL << 3)
> >>>   __u32 type;
> >>>   __u32 pad1;
> >>>   __u64 pad2;
> >>> diff --git a/arch/powerpc/include/asm/kvm_host.h
> >> b/arch/powerpc/include/asm/kvm_host.h
> >>> index c7219c1..3ba465a 100644
> >>> --- a/arch/powerpc/include/asm/kvm_host.h
> >>> +++ b/arch/powerpc/include/asm/kvm_host.h
> >>> @@ -496,7 +496,12 @@ struct kvm_vcpu_arch {
> >>>   u32 mmucf

Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-10-04 Thread Alexander Graf

On 04.10.2012, at 13:06, Bhushan Bharat-R65777 wrote:

> 
> 
>> -Original Message-
>> From: Alexander Graf [mailto:ag...@suse.de]
>> Sent: Monday, September 24, 2012 9:50 PM
>> To: Bhushan Bharat-R65777
>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan Bharat-R65777
>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>> 
>> 
>> On 21.08.2012, at 15:52, Bharat Bhushan wrote:
>> 
>>> This patch adds the debug stub support on booke/bookehv.
>>> Now QEMU debug stub can use hw breakpoint, watchpoint and
>>> software breakpoint to debug guest.
>>> 
>>> Signed-off-by: Bharat Bhushan 
>>> ---
>>> arch/powerpc/include/asm/kvm.h|   29 ++-
>>> arch/powerpc/include/asm/kvm_host.h   |5 +
>>> arch/powerpc/kernel/asm-offsets.c |   26 ++
>>> arch/powerpc/kvm/booke.c  |  144 
>>> +
>>> arch/powerpc/kvm/booke_interrupts.S   |  110 +
>>> arch/powerpc/kvm/bookehv_interrupts.S |  141 
>>> +++-
>>> arch/powerpc/kvm/e500mc.c |3 +-
>>> 7 files changed, 435 insertions(+), 23 deletions(-)
>>> 
>>> diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
>>> index 61b197e..53479ea 100644
>>> --- a/arch/powerpc/include/asm/kvm.h
>>> +++ b/arch/powerpc/include/asm/kvm.h
>>> @@ -25,6 +25,7 @@
>>> /* Select powerpc specific features in  */
>>> #define __KVM_HAVE_SPAPR_TCE
>>> #define __KVM_HAVE_PPC_SMT
>>> +#define __KVM_HAVE_GUEST_DEBUG
>>> 
>>> struct kvm_regs {
>>> __u64 pc;
>>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>> __u64 fpr[32];
>>> };
>>> 
>>> +
>>> +/*
>>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>>> + * software breakpoint.
>>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
>>> + * for KVM_DEBUG_EXIT.
>>> + */
>>> +#define KVMPPC_DEBUG_NONE  0x0
>>> +#define KVMPPC_DEBUG_BREAKPOINT(1UL << 1)
>>> +#define KVMPPC_DEBUG_WATCH_WRITE   (1UL << 2)
>>> +#define KVMPPC_DEBUG_WATCH_READ(1UL << 3)
>>> struct kvm_debug_exit_arch {
>>> +   __u64 pc;
>>> +   /*
>>> +* exception -> returns the exception number. If the KVM_DEBUG_EXIT
>>> +* exit is not handled (say not h/w breakpoint or software breakpoint
>>> +* set for this address) by qemu then it is supposed to inject this
>>> +* exception to guest.
>>> +*/
>>> +   __u32 exception;
>>> +   /*
>>> +* exiting to userspace because of h/w breakpoint, watchpoint
>>> +* (read, write or both) and software breakpoint.
>>> +*/
>>> +   __u32 status;
>>> };
>>> 
>>> /* for KVM_SET_GUEST_DEBUG */
>>> @@ -276,10 +301,6 @@ struct kvm_guest_debug_arch {
>>>  * Type denotes h/w breakpoint, read watchpoint, write
>>>  * watchpoint or watchpoint (both read and write).
>>>  */
>>> -#define KVMPPC_DEBUG_NOTYPE0x0
>>> -#define KVMPPC_DEBUG_BREAKPOINT(1UL << 1)
>>> -#define KVMPPC_DEBUG_WATCH_WRITE   (1UL << 2)
>>> -#define KVMPPC_DEBUG_WATCH_READ(1UL << 3)
>>> __u32 type;
>>> __u32 pad1;
>>> __u64 pad2;
>>> diff --git a/arch/powerpc/include/asm/kvm_host.h
>> b/arch/powerpc/include/asm/kvm_host.h
>>> index c7219c1..3ba465a 100644
>>> --- a/arch/powerpc/include/asm/kvm_host.h
>>> +++ b/arch/powerpc/include/asm/kvm_host.h
>>> @@ -496,7 +496,12 @@ struct kvm_vcpu_arch {
>>> u32 mmucfg;
>>> u32 epr;
>>> u32 crit_save;
>>> +   /* guest debug registers*/
>>> struct kvmppc_booke_debug_reg dbg_reg;
>>> +   /* shadow debug registers */
>>> +   struct kvmppc_booke_debug_reg shadow_dbg_reg;
>>> +   /* host debug registers*/
>>> +   struct kvmppc_booke_debug_reg host_dbg_reg;
>>> #endif
>>> gpa_t paddr_accessed;
>>> gva_t vaddr_accessed;
>>> diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-
>> offsets.c
>>> index 555448e..6987821 100644
>>> --- a/arch/powerpc/kernel/asm-offsets.c
>>> +++ b/

RE: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-10-04 Thread Bhushan Bharat-R65777


> -Original Message-
> From: Alexander Graf [mailto:ag...@suse.de]
> Sent: Monday, September 24, 2012 9:50 PM
> To: Bhushan Bharat-R65777
> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan Bharat-R65777
> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
> 
> 
> On 21.08.2012, at 15:52, Bharat Bhushan wrote:
> 
> > This patch adds the debug stub support on booke/bookehv.
> > Now QEMU debug stub can use hw breakpoint, watchpoint and
> > software breakpoint to debug guest.
> >
> > Signed-off-by: Bharat Bhushan 
> > ---
> > arch/powerpc/include/asm/kvm.h|   29 ++-
> > arch/powerpc/include/asm/kvm_host.h   |5 +
> > arch/powerpc/kernel/asm-offsets.c |   26 ++
> > arch/powerpc/kvm/booke.c  |  144 
> > +
> > arch/powerpc/kvm/booke_interrupts.S   |  110 +
> > arch/powerpc/kvm/bookehv_interrupts.S |  141 
> > +++-
> > arch/powerpc/kvm/e500mc.c |3 +-
> > 7 files changed, 435 insertions(+), 23 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
> > index 61b197e..53479ea 100644
> > --- a/arch/powerpc/include/asm/kvm.h
> > +++ b/arch/powerpc/include/asm/kvm.h
> > @@ -25,6 +25,7 @@
> > /* Select powerpc specific features in  */
> > #define __KVM_HAVE_SPAPR_TCE
> > #define __KVM_HAVE_PPC_SMT
> > +#define __KVM_HAVE_GUEST_DEBUG
> >
> > struct kvm_regs {
> > __u64 pc;
> > @@ -264,7 +265,31 @@ struct kvm_fpu {
> > __u64 fpr[32];
> > };
> >
> > +
> > +/*
> > + * Defines for h/w breakpoint, watchpoint (read, write or both) and
> > + * software breakpoint.
> > + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
> > + * for KVM_DEBUG_EXIT.
> > + */
> > +#define KVMPPC_DEBUG_NONE  0x0
> > +#define KVMPPC_DEBUG_BREAKPOINT(1UL << 1)
> > +#define KVMPPC_DEBUG_WATCH_WRITE   (1UL << 2)
> > +#define KVMPPC_DEBUG_WATCH_READ(1UL << 3)
> > struct kvm_debug_exit_arch {
> > +   __u64 pc;
> > +   /*
> > +* exception -> returns the exception number. If the KVM_DEBUG_EXIT
> > +* exit is not handled (say not h/w breakpoint or software breakpoint
> > +* set for this address) by qemu then it is supposed to inject this
> > +* exception to guest.
> > +*/
> > +   __u32 exception;
> > +   /*
> > +* exiting to userspace because of h/w breakpoint, watchpoint
> > +* (read, write or both) and software breakpoint.
> > +*/
> > +   __u32 status;
> > };
> >
> > /* for KVM_SET_GUEST_DEBUG */
> > @@ -276,10 +301,6 @@ struct kvm_guest_debug_arch {
> >  * Type denotes h/w breakpoint, read watchpoint, write
> >  * watchpoint or watchpoint (both read and write).
> >  */
> > -#define KVMPPC_DEBUG_NOTYPE0x0
> > -#define KVMPPC_DEBUG_BREAKPOINT(1UL << 1)
> > -#define KVMPPC_DEBUG_WATCH_WRITE   (1UL << 2)
> > -#define KVMPPC_DEBUG_WATCH_READ(1UL << 3)
> > __u32 type;
> > __u32 pad1;
> > __u64 pad2;
> > diff --git a/arch/powerpc/include/asm/kvm_host.h
> b/arch/powerpc/include/asm/kvm_host.h
> > index c7219c1..3ba465a 100644
> > --- a/arch/powerpc/include/asm/kvm_host.h
> > +++ b/arch/powerpc/include/asm/kvm_host.h
> > @@ -496,7 +496,12 @@ struct kvm_vcpu_arch {
> > u32 mmucfg;
> > u32 epr;
> > u32 crit_save;
> > +   /* guest debug registers*/
> > struct kvmppc_booke_debug_reg dbg_reg;
> > +   /* shadow debug registers */
> > +   struct kvmppc_booke_debug_reg shadow_dbg_reg;
> > +   /* host debug registers*/
> > +   struct kvmppc_booke_debug_reg host_dbg_reg;
> > #endif
> > gpa_t paddr_accessed;
> > gva_t vaddr_accessed;
> > diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-
> offsets.c
> > index 555448e..6987821 100644
> > --- a/arch/powerpc/kernel/asm-offsets.c
> > +++ b/arch/powerpc/kernel/asm-offsets.c
> > @@ -564,6 +564,32 @@ int main(void)
> > DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear));
> > DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr));
> > DEFINE(VCPU_CRIT_SAVE, offsetof(struct kvm_vcpu, arch.crit_save));
> > +   DEFINE(VCPU_DBSR, offsetof(struct kvm_vcpu, arch.dbsr)

Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-25 Thread Alexander Graf

On 25.09.2012, at 13:06, Jan Kiszka wrote:

> On 2012-09-25 12:58, Alexander Graf wrote:
>> 
>> On 25.09.2012, at 12:56, Jan Kiszka wrote:
>> 
>>> On 2012-09-25 12:47, Alexander Graf wrote:
>>>> 
>>>> On 25.09.2012, at 12:38, Jan Kiszka wrote:
>>>> 
>>>>> On 2012-09-24 16:46, Alexander Graf wrote:
>>>>>> 
>>>>>> On 07.09.2012, at 00:56, Scott Wood wrote:
>>>>>> 
>>>>>>> On 09/06/2012 09:56 AM, Bhushan Bharat-R65777 wrote:
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> -Original Message-
>>>>>>>>> From: Wood Scott-B07421
>>>>>>>>> Sent: Thursday, September 06, 2012 4:57 AM
>>>>>>>>> To: Bhushan Bharat-R65777
>>>>>>>>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; ag...@suse.de; 
>>>>>>>>> Bhushan Bharat-
>>>>>>>>> R65777
>>>>>>>>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>>>>>>>>> 
>>>>>>>>> On 09/05/2012 06:23 PM, Scott Wood wrote:
>>>>>>>>>> On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
>>>>>>>>>>> This patch adds the debug stub support on booke/bookehv.
>>>>>>>>>>> Now QEMU debug stub can use hw breakpoint, watchpoint and software
>>>>>>>>>>> breakpoint to debug guest.
>>>>>>>>>>> 
>>>>>>>>>>> Signed-off-by: Bharat Bhushan 
>>>>>>>>>>> ---
>>>>>>>>>>> arch/powerpc/include/asm/kvm.h|   29 ++-
>>>>>>>>>>> arch/powerpc/include/asm/kvm_host.h   |5 +
>>>>>>>>>>> arch/powerpc/kernel/asm-offsets.c |   26 ++
>>>>>>>>>>> arch/powerpc/kvm/booke.c  |  144 
>>>>>>>>>>> +--
>>>>>>>>> --
>>>>>>>>>>> arch/powerpc/kvm/booke_interrupts.S   |  110 
>>>>>>>>>>> +
>>>>>>>>>>> arch/powerpc/kvm/bookehv_interrupts.S |  141
>>>>>>>>> +++-
>>>>>>>>>>> arch/powerpc/kvm/e500mc.c |3 +-
>>>>>>>>>>> 7 files changed, 435 insertions(+), 23 deletions(-)
>>>>>>>>>>> 
>>>>>>>>>>> diff --git a/arch/powerpc/include/asm/kvm.h
>>>>>>>>>>> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
>>>>>>>>>>> --- a/arch/powerpc/include/asm/kvm.h
>>>>>>>>>>> +++ b/arch/powerpc/include/asm/kvm.h
>>>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>>>> /* Select powerpc specific features in  */  #define
>>>>>>>>>>> __KVM_HAVE_SPAPR_TCE  #define __KVM_HAVE_PPC_SMT
>>>>>>>>>>> +#define __KVM_HAVE_GUEST_DEBUG
>>>>>>>>>>> 
>>>>>>>>>>> struct kvm_regs {
>>>>>>>>>>> __u64 pc;
>>>>>>>>>>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>>>>>>>>>> __u64 fpr[32];
>>>>>>>>>>> };
>>>>>>>>>>> 
>>>>>>>>>>> +
>>>>>>>>>>> +/*
>>>>>>>>>>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>>>>>>>>>>> + * software breakpoint.
>>>>>>>>>>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and 
>>>>>>>>>>> "status"
>>>>>>>>>>> + * for KVM_DEBUG_EXIT.
>>>>>>>>>>> + */
>>>>>>>>>>> +#define KVMPPC_DEBUG_NONE  0x0
>>>>>>>>>>> +#define KVMPPC_DEBUG_BREAKPOINT(1UL << 1)
>>>>>>>>>>> +#define KVMPPC_DEBUG_WATCH_WRITE   (1UL << 2)
>>>>>>>>>>> +#define KVMPPC_DEBUG_WATCH_READ   

Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-25 Thread Jan Kiszka
On 2012-09-25 12:58, Alexander Graf wrote:
> 
> On 25.09.2012, at 12:56, Jan Kiszka wrote:
> 
>> On 2012-09-25 12:47, Alexander Graf wrote:
>>>
>>> On 25.09.2012, at 12:38, Jan Kiszka wrote:
>>>
>>>> On 2012-09-24 16:46, Alexander Graf wrote:
>>>>>
>>>>> On 07.09.2012, at 00:56, Scott Wood wrote:
>>>>>
>>>>>> On 09/06/2012 09:56 AM, Bhushan Bharat-R65777 wrote:
>>>>>>>
>>>>>>>
>>>>>>>> -Original Message-
>>>>>>>> From: Wood Scott-B07421
>>>>>>>> Sent: Thursday, September 06, 2012 4:57 AM
>>>>>>>> To: Bhushan Bharat-R65777
>>>>>>>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; ag...@suse.de; 
>>>>>>>> Bhushan Bharat-
>>>>>>>> R65777
>>>>>>>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>>>>>>>>
>>>>>>>> On 09/05/2012 06:23 PM, Scott Wood wrote:
>>>>>>>>> On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
>>>>>>>>>> This patch adds the debug stub support on booke/bookehv.
>>>>>>>>>> Now QEMU debug stub can use hw breakpoint, watchpoint and software
>>>>>>>>>> breakpoint to debug guest.
>>>>>>>>>>
>>>>>>>>>> Signed-off-by: Bharat Bhushan 
>>>>>>>>>> ---
>>>>>>>>>> arch/powerpc/include/asm/kvm.h|   29 ++-
>>>>>>>>>> arch/powerpc/include/asm/kvm_host.h   |5 +
>>>>>>>>>> arch/powerpc/kernel/asm-offsets.c |   26 ++
>>>>>>>>>> arch/powerpc/kvm/booke.c  |  144 
>>>>>>>>>> +--
>>>>>>>> --
>>>>>>>>>> arch/powerpc/kvm/booke_interrupts.S   |  110 
>>>>>>>>>> +
>>>>>>>>>> arch/powerpc/kvm/bookehv_interrupts.S |  141
>>>>>>>> +++-
>>>>>>>>>> arch/powerpc/kvm/e500mc.c |3 +-
>>>>>>>>>> 7 files changed, 435 insertions(+), 23 deletions(-)
>>>>>>>>>>
>>>>>>>>>> diff --git a/arch/powerpc/include/asm/kvm.h
>>>>>>>>>> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
>>>>>>>>>> --- a/arch/powerpc/include/asm/kvm.h
>>>>>>>>>> +++ b/arch/powerpc/include/asm/kvm.h
>>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>>> /* Select powerpc specific features in  */  #define
>>>>>>>>>> __KVM_HAVE_SPAPR_TCE  #define __KVM_HAVE_PPC_SMT
>>>>>>>>>> +#define __KVM_HAVE_GUEST_DEBUG
>>>>>>>>>>
>>>>>>>>>> struct kvm_regs {
>>>>>>>>>>  __u64 pc;
>>>>>>>>>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>>>>>>>>>  __u64 fpr[32];
>>>>>>>>>> };
>>>>>>>>>>
>>>>>>>>>> +
>>>>>>>>>> +/*
>>>>>>>>>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>>>>>>>>>> + * software breakpoint.
>>>>>>>>>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and 
>>>>>>>>>> "status"
>>>>>>>>>> + * for KVM_DEBUG_EXIT.
>>>>>>>>>> + */
>>>>>>>>>> +#define KVMPPC_DEBUG_NONE   0x0
>>>>>>>>>> +#define KVMPPC_DEBUG_BREAKPOINT (1UL << 1)
>>>>>>>>>> +#define KVMPPC_DEBUG_WATCH_WRITE(1UL << 2)
>>>>>>>>>> +#define KVMPPC_DEBUG_WATCH_READ (1UL << 3)
>>>>>>>>>> struct kvm_debug_exit_arch {
>>>>>>>>>
>>>>>>>>> That says "arch", but it's not in an arch-specific file.
>>>>>>>>
>>>>>>>> Sigh, I can't read today apparentl

Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-25 Thread Alexander Graf

On 25.09.2012, at 12:56, Jan Kiszka wrote:

> On 2012-09-25 12:47, Alexander Graf wrote:
>> 
>> On 25.09.2012, at 12:38, Jan Kiszka wrote:
>> 
>>> On 2012-09-24 16:46, Alexander Graf wrote:
>>>> 
>>>> On 07.09.2012, at 00:56, Scott Wood wrote:
>>>> 
>>>>> On 09/06/2012 09:56 AM, Bhushan Bharat-R65777 wrote:
>>>>>> 
>>>>>> 
>>>>>>> -Original Message-
>>>>>>> From: Wood Scott-B07421
>>>>>>> Sent: Thursday, September 06, 2012 4:57 AM
>>>>>>> To: Bhushan Bharat-R65777
>>>>>>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; ag...@suse.de; 
>>>>>>> Bhushan Bharat-
>>>>>>> R65777
>>>>>>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>>>>>>> 
>>>>>>> On 09/05/2012 06:23 PM, Scott Wood wrote:
>>>>>>>> On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
>>>>>>>>> This patch adds the debug stub support on booke/bookehv.
>>>>>>>>> Now QEMU debug stub can use hw breakpoint, watchpoint and software
>>>>>>>>> breakpoint to debug guest.
>>>>>>>>> 
>>>>>>>>> Signed-off-by: Bharat Bhushan 
>>>>>>>>> ---
>>>>>>>>> arch/powerpc/include/asm/kvm.h|   29 ++-
>>>>>>>>> arch/powerpc/include/asm/kvm_host.h   |5 +
>>>>>>>>> arch/powerpc/kernel/asm-offsets.c |   26 ++
>>>>>>>>> arch/powerpc/kvm/booke.c  |  144 
>>>>>>>>> +--
>>>>>>> --
>>>>>>>>> arch/powerpc/kvm/booke_interrupts.S   |  110 +
>>>>>>>>> arch/powerpc/kvm/bookehv_interrupts.S |  141
>>>>>>> +++-
>>>>>>>>> arch/powerpc/kvm/e500mc.c |3 +-
>>>>>>>>> 7 files changed, 435 insertions(+), 23 deletions(-)
>>>>>>>>> 
>>>>>>>>> diff --git a/arch/powerpc/include/asm/kvm.h
>>>>>>>>> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
>>>>>>>>> --- a/arch/powerpc/include/asm/kvm.h
>>>>>>>>> +++ b/arch/powerpc/include/asm/kvm.h
>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>> /* Select powerpc specific features in  */  #define
>>>>>>>>> __KVM_HAVE_SPAPR_TCE  #define __KVM_HAVE_PPC_SMT
>>>>>>>>> +#define __KVM_HAVE_GUEST_DEBUG
>>>>>>>>> 
>>>>>>>>> struct kvm_regs {
>>>>>>>>>   __u64 pc;
>>>>>>>>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>>>>>>>>   __u64 fpr[32];
>>>>>>>>> };
>>>>>>>>> 
>>>>>>>>> +
>>>>>>>>> +/*
>>>>>>>>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>>>>>>>>> + * software breakpoint.
>>>>>>>>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
>>>>>>>>> + * for KVM_DEBUG_EXIT.
>>>>>>>>> + */
>>>>>>>>> +#define KVMPPC_DEBUG_NONE0x0
>>>>>>>>> +#define KVMPPC_DEBUG_BREAKPOINT  (1UL << 1)
>>>>>>>>> +#define KVMPPC_DEBUG_WATCH_WRITE (1UL << 2)
>>>>>>>>> +#define KVMPPC_DEBUG_WATCH_READ  (1UL << 3)
>>>>>>>>> struct kvm_debug_exit_arch {
>>>>>>>> 
>>>>>>>> That says "arch", but it's not in an arch-specific file.
>>>>>>> 
>>>>>>> Sigh, I can't read today apparently.
>>>>>>> 
>>>>>>>>> + __u64 pc;
>>>>>>>>> + /*
>>>>>>>>> +  * exception -> returns the exception number. If the 
>>>>>>>>> KVM_DEBUG_EXIT
>>>>>>>>> +  * exit is not handled (say not h/w breakpoint or software 
>>>

Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-25 Thread Jan Kiszka
On 2012-09-25 12:47, Alexander Graf wrote:
> 
> On 25.09.2012, at 12:38, Jan Kiszka wrote:
> 
>> On 2012-09-24 16:46, Alexander Graf wrote:
>>>
>>> On 07.09.2012, at 00:56, Scott Wood wrote:
>>>
>>>> On 09/06/2012 09:56 AM, Bhushan Bharat-R65777 wrote:
>>>>>
>>>>>
>>>>>> -Original Message-
>>>>>> From: Wood Scott-B07421
>>>>>> Sent: Thursday, September 06, 2012 4:57 AM
>>>>>> To: Bhushan Bharat-R65777
>>>>>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; ag...@suse.de; 
>>>>>> Bhushan Bharat-
>>>>>> R65777
>>>>>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>>>>>>
>>>>>> On 09/05/2012 06:23 PM, Scott Wood wrote:
>>>>>>> On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
>>>>>>>> This patch adds the debug stub support on booke/bookehv.
>>>>>>>> Now QEMU debug stub can use hw breakpoint, watchpoint and software
>>>>>>>> breakpoint to debug guest.
>>>>>>>>
>>>>>>>> Signed-off-by: Bharat Bhushan 
>>>>>>>> ---
>>>>>>>> arch/powerpc/include/asm/kvm.h|   29 ++-
>>>>>>>> arch/powerpc/include/asm/kvm_host.h   |5 +
>>>>>>>> arch/powerpc/kernel/asm-offsets.c |   26 ++
>>>>>>>> arch/powerpc/kvm/booke.c  |  144 
>>>>>>>> +--
>>>>>> --
>>>>>>>> arch/powerpc/kvm/booke_interrupts.S   |  110 +
>>>>>>>> arch/powerpc/kvm/bookehv_interrupts.S |  141
>>>>>> +++-
>>>>>>>> arch/powerpc/kvm/e500mc.c |3 +-
>>>>>>>> 7 files changed, 435 insertions(+), 23 deletions(-)
>>>>>>>>
>>>>>>>> diff --git a/arch/powerpc/include/asm/kvm.h
>>>>>>>> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
>>>>>>>> --- a/arch/powerpc/include/asm/kvm.h
>>>>>>>> +++ b/arch/powerpc/include/asm/kvm.h
>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>> /* Select powerpc specific features in  */  #define
>>>>>>>> __KVM_HAVE_SPAPR_TCE  #define __KVM_HAVE_PPC_SMT
>>>>>>>> +#define __KVM_HAVE_GUEST_DEBUG
>>>>>>>>
>>>>>>>> struct kvm_regs {
>>>>>>>>__u64 pc;
>>>>>>>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>>>>>>>__u64 fpr[32];
>>>>>>>> };
>>>>>>>>
>>>>>>>> +
>>>>>>>> +/*
>>>>>>>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>>>>>>>> + * software breakpoint.
>>>>>>>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
>>>>>>>> + * for KVM_DEBUG_EXIT.
>>>>>>>> + */
>>>>>>>> +#define KVMPPC_DEBUG_NONE 0x0
>>>>>>>> +#define KVMPPC_DEBUG_BREAKPOINT   (1UL << 1)
>>>>>>>> +#define KVMPPC_DEBUG_WATCH_WRITE  (1UL << 2)
>>>>>>>> +#define KVMPPC_DEBUG_WATCH_READ   (1UL << 3)
>>>>>>>> struct kvm_debug_exit_arch {
>>>>>>>
>>>>>>> That says "arch", but it's not in an arch-specific file.
>>>>>>
>>>>>> Sigh, I can't read today apparently.
>>>>>>
>>>>>>>> +  __u64 pc;
>>>>>>>> +  /*
>>>>>>>> +   * exception -> returns the exception number. If the 
>>>>>>>> KVM_DEBUG_EXIT
>>>>>>>> +   * exit is not handled (say not h/w breakpoint or software 
>>>>>>>> breakpoint
>>>>>>>> +   * set for this address) by qemu then it is supposed to inject 
>>>>>>>> this
>>>>>>>> +   * exception to guest.
>>>>>>>> +   */
>>>>>>>> +  __u32 exception;
>>>>>>

Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-25 Thread Jan Kiszka
On 2012-09-24 16:46, Alexander Graf wrote:
> 
> On 07.09.2012, at 00:56, Scott Wood wrote:
> 
>> On 09/06/2012 09:56 AM, Bhushan Bharat-R65777 wrote:
>>>
>>>
>>>> -Original Message-
>>>> From: Wood Scott-B07421
>>>> Sent: Thursday, September 06, 2012 4:57 AM
>>>> To: Bhushan Bharat-R65777
>>>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; ag...@suse.de; Bhushan 
>>>> Bharat-
>>>> R65777
>>>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>>>>
>>>> On 09/05/2012 06:23 PM, Scott Wood wrote:
>>>>> On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
>>>>>> This patch adds the debug stub support on booke/bookehv.
>>>>>> Now QEMU debug stub can use hw breakpoint, watchpoint and software
>>>>>> breakpoint to debug guest.
>>>>>>
>>>>>> Signed-off-by: Bharat Bhushan 
>>>>>> ---
>>>>>> arch/powerpc/include/asm/kvm.h|   29 ++-
>>>>>> arch/powerpc/include/asm/kvm_host.h   |5 +
>>>>>> arch/powerpc/kernel/asm-offsets.c |   26 ++
>>>>>> arch/powerpc/kvm/booke.c  |  144 
>>>>>> +--
>>>> --
>>>>>> arch/powerpc/kvm/booke_interrupts.S   |  110 +
>>>>>> arch/powerpc/kvm/bookehv_interrupts.S |  141
>>>> +++-
>>>>>> arch/powerpc/kvm/e500mc.c |3 +-
>>>>>> 7 files changed, 435 insertions(+), 23 deletions(-)
>>>>>>
>>>>>> diff --git a/arch/powerpc/include/asm/kvm.h
>>>>>> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
>>>>>> --- a/arch/powerpc/include/asm/kvm.h
>>>>>> +++ b/arch/powerpc/include/asm/kvm.h
>>>>>> @@ -25,6 +25,7 @@
>>>>>> /* Select powerpc specific features in  */  #define
>>>>>> __KVM_HAVE_SPAPR_TCE  #define __KVM_HAVE_PPC_SMT
>>>>>> +#define __KVM_HAVE_GUEST_DEBUG
>>>>>>
>>>>>> struct kvm_regs {
>>>>>>  __u64 pc;
>>>>>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>>>>>  __u64 fpr[32];
>>>>>> };
>>>>>>
>>>>>> +
>>>>>> +/*
>>>>>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>>>>>> + * software breakpoint.
>>>>>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
>>>>>> + * for KVM_DEBUG_EXIT.
>>>>>> + */
>>>>>> +#define KVMPPC_DEBUG_NONE   0x0
>>>>>> +#define KVMPPC_DEBUG_BREAKPOINT (1UL << 1)
>>>>>> +#define KVMPPC_DEBUG_WATCH_WRITE(1UL << 2)
>>>>>> +#define KVMPPC_DEBUG_WATCH_READ (1UL << 3)
>>>>>> struct kvm_debug_exit_arch {
>>>>>
>>>>> That says "arch", but it's not in an arch-specific file.
>>>>
>>>> Sigh, I can't read today apparently.
>>>>
>>>>>> +__u64 pc;
>>>>>> +/*
>>>>>> + * exception -> returns the exception number. If the 
>>>>>> KVM_DEBUG_EXIT
>>>>>> + * exit is not handled (say not h/w breakpoint or software 
>>>>>> breakpoint
>>>>>> + * set for this address) by qemu then it is supposed to inject 
>>>>>> this
>>>>>> + * exception to guest.
>>>>>> + */
>>>>>> +__u32 exception;
>>>>>> +/*
>>>>>> + * exiting to userspace because of h/w breakpoint, watchpoint
>>>>>> + * (read, write or both) and software breakpoint.
>>>>>> + */
>>>>>> +__u32 status;
>>>>>> };
>>>>>
>>>>> What does "exception number" mean in a generic API?
>>>>
>>>> Still, "exception number" is not a well-defined concept powerpc-wide.
>>>
>>> Just for background why we added is that, on x86 this exception number is 
>>> used to inject the exception to guest if QEMU is not able to handle the 
>>> debug excep

Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-25 Thread Alexander Graf

On 25.09.2012, at 12:38, Jan Kiszka wrote:

> On 2012-09-24 16:46, Alexander Graf wrote:
>> 
>> On 07.09.2012, at 00:56, Scott Wood wrote:
>> 
>>> On 09/06/2012 09:56 AM, Bhushan Bharat-R65777 wrote:
>>>> 
>>>> 
>>>>> -Original Message-
>>>>> From: Wood Scott-B07421
>>>>> Sent: Thursday, September 06, 2012 4:57 AM
>>>>> To: Bhushan Bharat-R65777
>>>>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; ag...@suse.de; Bhushan 
>>>>> Bharat-
>>>>> R65777
>>>>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>>>>> 
>>>>> On 09/05/2012 06:23 PM, Scott Wood wrote:
>>>>>> On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
>>>>>>> This patch adds the debug stub support on booke/bookehv.
>>>>>>> Now QEMU debug stub can use hw breakpoint, watchpoint and software
>>>>>>> breakpoint to debug guest.
>>>>>>> 
>>>>>>> Signed-off-by: Bharat Bhushan 
>>>>>>> ---
>>>>>>> arch/powerpc/include/asm/kvm.h|   29 ++-
>>>>>>> arch/powerpc/include/asm/kvm_host.h   |5 +
>>>>>>> arch/powerpc/kernel/asm-offsets.c |   26 ++
>>>>>>> arch/powerpc/kvm/booke.c  |  144 
>>>>>>> +--
>>>>> --
>>>>>>> arch/powerpc/kvm/booke_interrupts.S   |  110 +
>>>>>>> arch/powerpc/kvm/bookehv_interrupts.S |  141
>>>>> +++-
>>>>>>> arch/powerpc/kvm/e500mc.c |3 +-
>>>>>>> 7 files changed, 435 insertions(+), 23 deletions(-)
>>>>>>> 
>>>>>>> diff --git a/arch/powerpc/include/asm/kvm.h
>>>>>>> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
>>>>>>> --- a/arch/powerpc/include/asm/kvm.h
>>>>>>> +++ b/arch/powerpc/include/asm/kvm.h
>>>>>>> @@ -25,6 +25,7 @@
>>>>>>> /* Select powerpc specific features in  */  #define
>>>>>>> __KVM_HAVE_SPAPR_TCE  #define __KVM_HAVE_PPC_SMT
>>>>>>> +#define __KVM_HAVE_GUEST_DEBUG
>>>>>>> 
>>>>>>> struct kvm_regs {
>>>>>>> __u64 pc;
>>>>>>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>>>>>> __u64 fpr[32];
>>>>>>> };
>>>>>>> 
>>>>>>> +
>>>>>>> +/*
>>>>>>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>>>>>>> + * software breakpoint.
>>>>>>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
>>>>>>> + * for KVM_DEBUG_EXIT.
>>>>>>> + */
>>>>>>> +#define KVMPPC_DEBUG_NONE  0x0
>>>>>>> +#define KVMPPC_DEBUG_BREAKPOINT(1UL << 1)
>>>>>>> +#define KVMPPC_DEBUG_WATCH_WRITE   (1UL << 2)
>>>>>>> +#define KVMPPC_DEBUG_WATCH_READ(1UL << 3)
>>>>>>> struct kvm_debug_exit_arch {
>>>>>> 
>>>>>> That says "arch", but it's not in an arch-specific file.
>>>>> 
>>>>> Sigh, I can't read today apparently.
>>>>> 
>>>>>>> +   __u64 pc;
>>>>>>> +   /*
>>>>>>> +* exception -> returns the exception number. If the 
>>>>>>> KVM_DEBUG_EXIT
>>>>>>> +* exit is not handled (say not h/w breakpoint or software 
>>>>>>> breakpoint
>>>>>>> +* set for this address) by qemu then it is supposed to inject 
>>>>>>> this
>>>>>>> +* exception to guest.
>>>>>>> +*/
>>>>>>> +   __u32 exception;
>>>>>>> +   /*
>>>>>>> +* exiting to userspace because of h/w breakpoint, watchpoint
>>>>>>> +* (read, write or both) and software breakpoint.
>>>>>>> +*/
>>>>>>> +   __u32 status;
>>>>>>> };
>>>>&

Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-24 Thread Alexander Graf

On 21.08.2012, at 15:52, Bharat Bhushan wrote:

> This patch adds the debug stub support on booke/bookehv.
> Now QEMU debug stub can use hw breakpoint, watchpoint and
> software breakpoint to debug guest.
> 
> Signed-off-by: Bharat Bhushan 
> ---
> arch/powerpc/include/asm/kvm.h|   29 ++-
> arch/powerpc/include/asm/kvm_host.h   |5 +
> arch/powerpc/kernel/asm-offsets.c |   26 ++
> arch/powerpc/kvm/booke.c  |  144 +
> arch/powerpc/kvm/booke_interrupts.S   |  110 +
> arch/powerpc/kvm/bookehv_interrupts.S |  141 +++-
> arch/powerpc/kvm/e500mc.c |3 +-
> 7 files changed, 435 insertions(+), 23 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
> index 61b197e..53479ea 100644
> --- a/arch/powerpc/include/asm/kvm.h
> +++ b/arch/powerpc/include/asm/kvm.h
> @@ -25,6 +25,7 @@
> /* Select powerpc specific features in  */
> #define __KVM_HAVE_SPAPR_TCE
> #define __KVM_HAVE_PPC_SMT
> +#define __KVM_HAVE_GUEST_DEBUG
> 
> struct kvm_regs {
>   __u64 pc;
> @@ -264,7 +265,31 @@ struct kvm_fpu {
>   __u64 fpr[32];
> };
> 
> +
> +/*
> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
> + * software breakpoint.
> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
> + * for KVM_DEBUG_EXIT.
> + */
> +#define KVMPPC_DEBUG_NONE0x0
> +#define KVMPPC_DEBUG_BREAKPOINT  (1UL << 1)
> +#define KVMPPC_DEBUG_WATCH_WRITE (1UL << 2)
> +#define KVMPPC_DEBUG_WATCH_READ  (1UL << 3)
> struct kvm_debug_exit_arch {
> + __u64 pc;
> + /*
> +  * exception -> returns the exception number. If the KVM_DEBUG_EXIT
> +  * exit is not handled (say not h/w breakpoint or software breakpoint
> +  * set for this address) by qemu then it is supposed to inject this
> +  * exception to guest.
> +  */
> + __u32 exception;
> + /*
> +  * exiting to userspace because of h/w breakpoint, watchpoint
> +  * (read, write or both) and software breakpoint.
> +  */
> + __u32 status;
> };
> 
> /* for KVM_SET_GUEST_DEBUG */
> @@ -276,10 +301,6 @@ struct kvm_guest_debug_arch {
>* Type denotes h/w breakpoint, read watchpoint, write
>* watchpoint or watchpoint (both read and write).
>*/
> -#define KVMPPC_DEBUG_NOTYPE  0x0
> -#define KVMPPC_DEBUG_BREAKPOINT  (1UL << 1)
> -#define KVMPPC_DEBUG_WATCH_WRITE (1UL << 2)
> -#define KVMPPC_DEBUG_WATCH_READ  (1UL << 3)
>   __u32 type;
>   __u32 pad1;
>   __u64 pad2;
> diff --git a/arch/powerpc/include/asm/kvm_host.h 
> b/arch/powerpc/include/asm/kvm_host.h
> index c7219c1..3ba465a 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -496,7 +496,12 @@ struct kvm_vcpu_arch {
>   u32 mmucfg;
>   u32 epr;
>   u32 crit_save;
> + /* guest debug registers*/
>   struct kvmppc_booke_debug_reg dbg_reg;
> + /* shadow debug registers */
> + struct kvmppc_booke_debug_reg shadow_dbg_reg;
> + /* host debug registers*/
> + struct kvmppc_booke_debug_reg host_dbg_reg;
> #endif
>   gpa_t paddr_accessed;
>   gva_t vaddr_accessed;
> diff --git a/arch/powerpc/kernel/asm-offsets.c 
> b/arch/powerpc/kernel/asm-offsets.c
> index 555448e..6987821 100644
> --- a/arch/powerpc/kernel/asm-offsets.c
> +++ b/arch/powerpc/kernel/asm-offsets.c
> @@ -564,6 +564,32 @@ int main(void)
>   DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear));
>   DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr));
>   DEFINE(VCPU_CRIT_SAVE, offsetof(struct kvm_vcpu, arch.crit_save));
> + DEFINE(VCPU_DBSR, offsetof(struct kvm_vcpu, arch.dbsr));
> + DEFINE(VCPU_SHADOW_DBG, offsetof(struct kvm_vcpu, arch.shadow_dbg_reg));
> + DEFINE(VCPU_HOST_DBG, offsetof(struct kvm_vcpu, arch.host_dbg_reg));
> + DEFINE(KVMPPC_DBG_DBCR0, offsetof(struct kvmppc_booke_debug_reg,
> +   dbcr0));
> + DEFINE(KVMPPC_DBG_DBCR1, offsetof(struct kvmppc_booke_debug_reg,
> +   dbcr1));
> + DEFINE(KVMPPC_DBG_DBCR2, offsetof(struct kvmppc_booke_debug_reg,
> +   dbcr2));
> +#ifdef CONFIG_KVM_E500MC
> + DEFINE(KVMPPC_DBG_DBCR4, offsetof(struct kvmppc_booke_debug_reg,
> +   dbcr4));
> +#endif
> + DEFINE(KVMPPC_DBG_IAC1, offsetof(struct kvmppc_booke_debug_reg,
> +  iac[0]));
> + DEFINE(KVMPPC_DBG_IAC2, offsetof(struct kvmppc_booke_debug_reg,
> +  iac[1]));
> + DEFINE(KVMPPC_DBG_IAC3, offsetof(struct kvmppc_booke_debug_reg,
> +  iac[2]));
> + DEFINE(KVMPPC_DBG_IAC4, offsetof(stru

Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-24 Thread Alexander Graf

On 07.09.2012, at 00:56, Scott Wood wrote:

> On 09/06/2012 09:56 AM, Bhushan Bharat-R65777 wrote:
>> 
>> 
>>> -Original Message-
>>> From: Wood Scott-B07421
>>> Sent: Thursday, September 06, 2012 4:57 AM
>>> To: Bhushan Bharat-R65777
>>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; ag...@suse.de; Bhushan 
>>> Bharat-
>>> R65777
>>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>>> 
>>> On 09/05/2012 06:23 PM, Scott Wood wrote:
>>>> On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
>>>>> This patch adds the debug stub support on booke/bookehv.
>>>>> Now QEMU debug stub can use hw breakpoint, watchpoint and software
>>>>> breakpoint to debug guest.
>>>>> 
>>>>> Signed-off-by: Bharat Bhushan 
>>>>> ---
>>>>> arch/powerpc/include/asm/kvm.h|   29 ++-
>>>>> arch/powerpc/include/asm/kvm_host.h   |5 +
>>>>> arch/powerpc/kernel/asm-offsets.c |   26 ++
>>>>> arch/powerpc/kvm/booke.c  |  144 
>>>>> +--
>>> --
>>>>> arch/powerpc/kvm/booke_interrupts.S   |  110 +
>>>>> arch/powerpc/kvm/bookehv_interrupts.S |  141
>>> +++-
>>>>> arch/powerpc/kvm/e500mc.c |3 +-
>>>>> 7 files changed, 435 insertions(+), 23 deletions(-)
>>>>> 
>>>>> diff --git a/arch/powerpc/include/asm/kvm.h
>>>>> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
>>>>> --- a/arch/powerpc/include/asm/kvm.h
>>>>> +++ b/arch/powerpc/include/asm/kvm.h
>>>>> @@ -25,6 +25,7 @@
>>>>> /* Select powerpc specific features in  */  #define
>>>>> __KVM_HAVE_SPAPR_TCE  #define __KVM_HAVE_PPC_SMT
>>>>> +#define __KVM_HAVE_GUEST_DEBUG
>>>>> 
>>>>> struct kvm_regs {
>>>>>   __u64 pc;
>>>>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>>>>   __u64 fpr[32];
>>>>> };
>>>>> 
>>>>> +
>>>>> +/*
>>>>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>>>>> + * software breakpoint.
>>>>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
>>>>> + * for KVM_DEBUG_EXIT.
>>>>> + */
>>>>> +#define KVMPPC_DEBUG_NONE0x0
>>>>> +#define KVMPPC_DEBUG_BREAKPOINT  (1UL << 1)
>>>>> +#define KVMPPC_DEBUG_WATCH_WRITE (1UL << 2)
>>>>> +#define KVMPPC_DEBUG_WATCH_READ  (1UL << 3)
>>>>> struct kvm_debug_exit_arch {
>>>> 
>>>> That says "arch", but it's not in an arch-specific file.
>>> 
>>> Sigh, I can't read today apparently.
>>> 
>>>>> + __u64 pc;
>>>>> + /*
>>>>> +  * exception -> returns the exception number. If the KVM_DEBUG_EXIT
>>>>> +  * exit is not handled (say not h/w breakpoint or software breakpoint
>>>>> +  * set for this address) by qemu then it is supposed to inject this
>>>>> +  * exception to guest.
>>>>> +  */
>>>>> + __u32 exception;
>>>>> + /*
>>>>> +  * exiting to userspace because of h/w breakpoint, watchpoint
>>>>> +  * (read, write or both) and software breakpoint.
>>>>> +  */
>>>>> + __u32 status;
>>>>> };
>>>> 
>>>> What does "exception number" mean in a generic API?
>>> 
>>> Still, "exception number" is not a well-defined concept powerpc-wide.
>> 
>> Just for background why we added is that, on x86 this exception number is 
>> used to inject the exception to guest if QEMU is not able to handle the 
>> debug exception.
>> 
>> Should we just through a print with clearing the exception condition? Or 
>> something else you would like to suggest?
> 
> We can pass up the exception type; it just needs more documentation
> about what exactly you're referring to, and probably some enumeration
> that says which exception numberspace it is.
> 
> For booke the exception number should probably be related to the fixed
> offsets rather than the IVOR number, as IVORs are phased out.

Jan, I would like to get your comment on this one.

Since we don't have standardized exception vectors like x86 does, we need to 
convert things between different semantics in user space if we want to make use 
of the exception type. Do we actually need to know about it in user space or do 
we only need to store it in case we get a migration at that point?

If it's the latter, can we maybe keep the reinjection logic internal to KVM and 
make DEBUG exits non-migratable similar to how we already handle MMIO/PIO exits 
today?


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-06 Thread Scott Wood
On 09/06/2012 09:56 AM, Bhushan Bharat-R65777 wrote:
> 
> 
>> -Original Message-
>> From: Wood Scott-B07421
>> Sent: Thursday, September 06, 2012 4:57 AM
>> To: Bhushan Bharat-R65777
>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; ag...@suse.de; Bhushan 
>> Bharat-
>> R65777
>> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
>>
>> On 09/05/2012 06:23 PM, Scott Wood wrote:
>>> On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
>>>> This patch adds the debug stub support on booke/bookehv.
>>>> Now QEMU debug stub can use hw breakpoint, watchpoint and software
>>>> breakpoint to debug guest.
>>>>
>>>> Signed-off-by: Bharat Bhushan 
>>>> ---
>>>>  arch/powerpc/include/asm/kvm.h|   29 ++-
>>>>  arch/powerpc/include/asm/kvm_host.h   |5 +
>>>>  arch/powerpc/kernel/asm-offsets.c |   26 ++
>>>>  arch/powerpc/kvm/booke.c  |  144 
>>>> +--
>> --
>>>>  arch/powerpc/kvm/booke_interrupts.S   |  110 +
>>>>  arch/powerpc/kvm/bookehv_interrupts.S |  141
>> +++-
>>>>  arch/powerpc/kvm/e500mc.c |3 +-
>>>>  7 files changed, 435 insertions(+), 23 deletions(-)
>>>>
>>>> diff --git a/arch/powerpc/include/asm/kvm.h
>>>> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
>>>> --- a/arch/powerpc/include/asm/kvm.h
>>>> +++ b/arch/powerpc/include/asm/kvm.h
>>>> @@ -25,6 +25,7 @@
>>>>  /* Select powerpc specific features in  */  #define
>>>> __KVM_HAVE_SPAPR_TCE  #define __KVM_HAVE_PPC_SMT
>>>> +#define __KVM_HAVE_GUEST_DEBUG
>>>>
>>>>  struct kvm_regs {
>>>>__u64 pc;
>>>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>>>__u64 fpr[32];
>>>>  };
>>>>
>>>> +
>>>> +/*
>>>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>>>> + * software breakpoint.
>>>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
>>>> + * for KVM_DEBUG_EXIT.
>>>> + */
>>>> +#define KVMPPC_DEBUG_NONE 0x0
>>>> +#define KVMPPC_DEBUG_BREAKPOINT   (1UL << 1)
>>>> +#define KVMPPC_DEBUG_WATCH_WRITE  (1UL << 2)
>>>> +#define KVMPPC_DEBUG_WATCH_READ   (1UL << 3)
>>>>  struct kvm_debug_exit_arch {
>>>
>>> That says "arch", but it's not in an arch-specific file.
>>
>> Sigh, I can't read today apparently.
>>
>>>> +  __u64 pc;
>>>> +  /*
>>>> +   * exception -> returns the exception number. If the KVM_DEBUG_EXIT
>>>> +   * exit is not handled (say not h/w breakpoint or software breakpoint
>>>> +   * set for this address) by qemu then it is supposed to inject this
>>>> +   * exception to guest.
>>>> +   */
>>>> +  __u32 exception;
>>>> +  /*
>>>> +   * exiting to userspace because of h/w breakpoint, watchpoint
>>>> +   * (read, write or both) and software breakpoint.
>>>> +   */
>>>> +  __u32 status;
>>>>  };
>>>
>>> What does "exception number" mean in a generic API?
>>
>> Still, "exception number" is not a well-defined concept powerpc-wide.
> 
> Just for background why we added is that, on x86 this exception number is 
> used to inject the exception to guest if QEMU is not able to handle the debug 
> exception.
> 
> Should we just through a print with clearing the exception condition? Or 
> something else you would like to suggest?

We can pass up the exception type; it just needs more documentation
about what exactly you're referring to, and probably some enumeration
that says which exception numberspace it is.

For booke the exception number should probably be related to the fixed
offsets rather than the IVOR number, as IVORs are phased out.

-Scott


--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-06 Thread Bhushan Bharat-R65777


> -Original Message-
> From: Wood Scott-B07421
> Sent: Thursday, September 06, 2012 4:57 AM
> To: Bhushan Bharat-R65777
> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; ag...@suse.de; Bhushan 
> Bharat-
> R65777
> Subject: Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support
> 
> On 09/05/2012 06:23 PM, Scott Wood wrote:
> > On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
> >> This patch adds the debug stub support on booke/bookehv.
> >> Now QEMU debug stub can use hw breakpoint, watchpoint and software
> >> breakpoint to debug guest.
> >>
> >> Signed-off-by: Bharat Bhushan 
> >> ---
> >>  arch/powerpc/include/asm/kvm.h|   29 ++-
> >>  arch/powerpc/include/asm/kvm_host.h   |5 +
> >>  arch/powerpc/kernel/asm-offsets.c |   26 ++
> >>  arch/powerpc/kvm/booke.c  |  144 
> >> +--
> --
> >>  arch/powerpc/kvm/booke_interrupts.S   |  110 +
> >>  arch/powerpc/kvm/bookehv_interrupts.S |  141
> +++-
> >>  arch/powerpc/kvm/e500mc.c |3 +-
> >>  7 files changed, 435 insertions(+), 23 deletions(-)
> >>
> >> diff --git a/arch/powerpc/include/asm/kvm.h
> >> b/arch/powerpc/include/asm/kvm.h index 61b197e..53479ea 100644
> >> --- a/arch/powerpc/include/asm/kvm.h
> >> +++ b/arch/powerpc/include/asm/kvm.h
> >> @@ -25,6 +25,7 @@
> >>  /* Select powerpc specific features in  */  #define
> >> __KVM_HAVE_SPAPR_TCE  #define __KVM_HAVE_PPC_SMT
> >> +#define __KVM_HAVE_GUEST_DEBUG
> >>
> >>  struct kvm_regs {
> >>__u64 pc;
> >> @@ -264,7 +265,31 @@ struct kvm_fpu {
> >>__u64 fpr[32];
> >>  };
> >>
> >> +
> >> +/*
> >> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
> >> + * software breakpoint.
> >> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
> >> + * for KVM_DEBUG_EXIT.
> >> + */
> >> +#define KVMPPC_DEBUG_NONE 0x0
> >> +#define KVMPPC_DEBUG_BREAKPOINT   (1UL << 1)
> >> +#define KVMPPC_DEBUG_WATCH_WRITE  (1UL << 2)
> >> +#define KVMPPC_DEBUG_WATCH_READ   (1UL << 3)
> >>  struct kvm_debug_exit_arch {
> >
> > That says "arch", but it's not in an arch-specific file.
> 
> Sigh, I can't read today apparently.
> 
> >> +  __u64 pc;
> >> +  /*
> >> +   * exception -> returns the exception number. If the KVM_DEBUG_EXIT
> >> +   * exit is not handled (say not h/w breakpoint or software breakpoint
> >> +   * set for this address) by qemu then it is supposed to inject this
> >> +   * exception to guest.
> >> +   */
> >> +  __u32 exception;
> >> +  /*
> >> +   * exiting to userspace because of h/w breakpoint, watchpoint
> >> +   * (read, write or both) and software breakpoint.
> >> +   */
> >> +  __u32 status;
> >>  };
> >
> > What does "exception number" mean in a generic API?
> 
> Still, "exception number" is not a well-defined concept powerpc-wide.

Just for background why we added is that, on x86 this exception number is used 
to inject the exception to guest if QEMU is not able to handle the debug 
exception.

Should we just through a print with clearing the exception condition? Or 
something else you would like to suggest?

Thanks
-Bharat



Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-05 Thread Scott Wood
On 09/05/2012 06:23 PM, Scott Wood wrote:
> On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
>> This patch adds the debug stub support on booke/bookehv.
>> Now QEMU debug stub can use hw breakpoint, watchpoint and
>> software breakpoint to debug guest.
>>
>> Signed-off-by: Bharat Bhushan 
>> ---
>>  arch/powerpc/include/asm/kvm.h|   29 ++-
>>  arch/powerpc/include/asm/kvm_host.h   |5 +
>>  arch/powerpc/kernel/asm-offsets.c |   26 ++
>>  arch/powerpc/kvm/booke.c  |  144 
>> +
>>  arch/powerpc/kvm/booke_interrupts.S   |  110 +
>>  arch/powerpc/kvm/bookehv_interrupts.S |  141 
>> +++-
>>  arch/powerpc/kvm/e500mc.c |3 +-
>>  7 files changed, 435 insertions(+), 23 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
>> index 61b197e..53479ea 100644
>> --- a/arch/powerpc/include/asm/kvm.h
>> +++ b/arch/powerpc/include/asm/kvm.h
>> @@ -25,6 +25,7 @@
>>  /* Select powerpc specific features in  */
>>  #define __KVM_HAVE_SPAPR_TCE
>>  #define __KVM_HAVE_PPC_SMT
>> +#define __KVM_HAVE_GUEST_DEBUG
>>  
>>  struct kvm_regs {
>>  __u64 pc;
>> @@ -264,7 +265,31 @@ struct kvm_fpu {
>>  __u64 fpr[32];
>>  };
>>  
>> +
>> +/*
>> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
>> + * software breakpoint.
>> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
>> + * for KVM_DEBUG_EXIT.
>> + */
>> +#define KVMPPC_DEBUG_NONE   0x0
>> +#define KVMPPC_DEBUG_BREAKPOINT (1UL << 1)
>> +#define KVMPPC_DEBUG_WATCH_WRITE(1UL << 2)
>> +#define KVMPPC_DEBUG_WATCH_READ (1UL << 3)
>>  struct kvm_debug_exit_arch {
> 
> That says "arch", but it's not in an arch-specific file.

Sigh, I can't read today apparently.

>> +__u64 pc;
>> +/*
>> + * exception -> returns the exception number. If the KVM_DEBUG_EXIT
>> + * exit is not handled (say not h/w breakpoint or software breakpoint
>> + * set for this address) by qemu then it is supposed to inject this
>> + * exception to guest.
>> + */
>> +__u32 exception;
>> +/*
>> + * exiting to userspace because of h/w breakpoint, watchpoint
>> + * (read, write or both) and software breakpoint.
>> + */
>> +__u32 status;
>>  };
> 
> What does "exception number" mean in a generic API?

Still, "exception number" is not a well-defined concept powerpc-wide.

-Scott


--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/6] KVM: booke/bookehv: Add debug stub support

2012-09-05 Thread Scott Wood
On 08/21/2012 08:52 AM, Bharat Bhushan wrote:
> This patch adds the debug stub support on booke/bookehv.
> Now QEMU debug stub can use hw breakpoint, watchpoint and
> software breakpoint to debug guest.
> 
> Signed-off-by: Bharat Bhushan 
> ---
>  arch/powerpc/include/asm/kvm.h|   29 ++-
>  arch/powerpc/include/asm/kvm_host.h   |5 +
>  arch/powerpc/kernel/asm-offsets.c |   26 ++
>  arch/powerpc/kvm/booke.c  |  144 
> +
>  arch/powerpc/kvm/booke_interrupts.S   |  110 +
>  arch/powerpc/kvm/bookehv_interrupts.S |  141 +++-
>  arch/powerpc/kvm/e500mc.c |3 +-
>  7 files changed, 435 insertions(+), 23 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
> index 61b197e..53479ea 100644
> --- a/arch/powerpc/include/asm/kvm.h
> +++ b/arch/powerpc/include/asm/kvm.h
> @@ -25,6 +25,7 @@
>  /* Select powerpc specific features in  */
>  #define __KVM_HAVE_SPAPR_TCE
>  #define __KVM_HAVE_PPC_SMT
> +#define __KVM_HAVE_GUEST_DEBUG
>  
>  struct kvm_regs {
>   __u64 pc;
> @@ -264,7 +265,31 @@ struct kvm_fpu {
>   __u64 fpr[32];
>  };
>  
> +
> +/*
> + * Defines for h/w breakpoint, watchpoint (read, write or both) and
> + * software breakpoint.
> + * These are used as "type" in KVM_SET_GUEST_DEBUG ioctl and "status"
> + * for KVM_DEBUG_EXIT.
> + */
> +#define KVMPPC_DEBUG_NONE0x0
> +#define KVMPPC_DEBUG_BREAKPOINT  (1UL << 1)
> +#define KVMPPC_DEBUG_WATCH_WRITE (1UL << 2)
> +#define KVMPPC_DEBUG_WATCH_READ  (1UL << 3)
>  struct kvm_debug_exit_arch {

That says "arch", but it's not in an arch-specific file.

> + __u64 pc;
> + /*
> +  * exception -> returns the exception number. If the KVM_DEBUG_EXIT
> +  * exit is not handled (say not h/w breakpoint or software breakpoint
> +  * set for this address) by qemu then it is supposed to inject this
> +  * exception to guest.
> +  */
> + __u32 exception;
> + /*
> +  * exiting to userspace because of h/w breakpoint, watchpoint
> +  * (read, write or both) and software breakpoint.
> +  */
> + __u32 status;
>  };

What does "exception number" mean in a generic API?

What values can go in "status"?

> + addir7, r4, VCPU_HOST_DBG
> + mfspr   r9, SPRN_DBCR0
> + lwz r8, KVMPPC_DBG_DBCR0(r7)
> + andis.  r9, r9, DBCR0_AC_BITS@h
> + beq skip_load_host_debug
> + li  r9, 0
> + mtspr   SPRN_DBCR0, r9  /* disable all debug event */
> + lwz r9, KVMPPC_DBG_DBCR1(r7)
> + mtspr   SPRN_DBCR1, r9
> + lwz r9, KVMPPC_DBG_DBCR2(r7)
> + mtspr   SPRN_DBCR2, r9
> + lwz r9, KVMPPC_DBG_IAC1+4(r7)
> + mtspr   SPRN_IAC1, r9
> + lwz r9, KVMPPC_DBG_IAC2+4(r7)
> + mtspr   SPRN_IAC2, r9
> +#if CONFIG_PPC_ADV_DEBUG_IACS > 2
> + lwz r9, KVMPPC_DBG_IAC3+4(r7)
> + mtspr   SPRN_IAC3, r9
> + lwz r9, KVMPPC_DBG_IAC4+4(r7)
> + mtspr   SPRN_IAC4, r9
> +#endif

What if CONFIG_PPC_ADV_DEBUG_REGS isn't set?

-Scott


--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html