Re: [PATCH 8/8] KVM:PPC:booke: Allow debug interrupt injection to guest

2013-02-01 Thread Scott Wood

On 01/31/2013 06:11:32 PM, Alexander Graf wrote:


On 31.01.2013, at 23:40, Scott Wood wrote:

> On 01/31/2013 01:20:39 PM, Alexander Graf wrote:
>> On 31.01.2013, at 20:05, Alexander Graf wrote:
>> >
>> > On 31.01.2013, at 19:54, Scott Wood wrote:
>> >
>> >> On 01/31/2013 12:52:41 PM, Alexander Graf wrote:
>> >>> On 31.01.2013, at 19:43, Scott Wood wrote:
>>  On 01/31/2013 12:21:07 PM, Alexander Graf wrote:
>> > How about something like this? Then both targets at least  
suck as much :).

>> 
>>  I'm not sure that should be the goal...
>> 
>> > Thanks to e500mc's awful hardware design, we don't know who  
sets the MSR_DE bit. Once we forced it onto the guest, we have no  
change to know whether the guest also set it or not. We could only  
guess.

>> 
>>  MSRP[DEP] can prevent the guest from modifying MSR[DE] -- but  
we still need to set it in the first place.

>> 
>>  According to ISA V2.06B, the hypervisor should set DBCR0[EDM]  
to let the guest know that the debug resources are not available, and  
that "the value of MSR[DE] is not specified and not modifiable".
>> >>> So what would the guest do then to tell the hypervisor that it  
actually wants to know about debug events?

>> >>
>> >> The guest is out of luck, just as if a JTAG were in use.
>> >
>> > Hrm.
>> >
>> > Can we somehow generalize this "out of luck" behavior?
>> >
>> > Every time we would set or clear an MSR bit in shadow_msr on  
e500v2, we would instead set or clear it in the real MSR. That way  
only e500mc is out of luck, but the code would still be shared.

>
> I don't follow.  e500v2 is just as out-of-luck.  The mechanism  
simply does not support sharing debug resources.


For e500v2 we have 2 fields

  * MSR as the guest sees it
  * MSR as we execute when the guest runs

Since we know the MSR when the guest sees it, we can decide what to  
do when we get an unhandled debug interrupt.


That's not the same thing as making the real MSR[DE] show up in the  
guest MSR[DE].


There are other problems with sharing -- what happens when both host  
and guest try to write to a particular IAC or DAC?


Also, performance would be pretty awful if the guest has e.g. single  
stepping in DBCR0 enabled but MSR[DE]=0, and the host doesn't care  
about single stepping (but does want debugging enabled in general).


> What do you mean by "the real MSR"?  The real MSR is shadow_msr,  
and MSR_DE must always be set there if the host is debugging the  
guest.  As for reflecting it into the guest MSR, we could, but I  
don't really see the point.  We're never going to actually send a  
debug exception to the guest when the host owns the debug resources.


Why not? That's the whole point of jumping through user space.


That's still needed for software breakpoints, which don't rely on the  
debug resources.



  1) guest exits with debug interrupt
  2) QEMU gets a debug exit
  3) QEMU checks in its list whether it belongs to its own debug  
points

  4) if not, it reinjects the interrupt into the guest

Step 4 is pretty difficult to do when we don't know whether the guest  
is actually capable of handling debug interrupts at that moment.


Software breakpoints take a Program interrupt rather than a Debug  
interrupt, unless MSR[DE]=1 and DBCR0[TRAP]=1.  If the guest does not  
own debug resources we should always send it to the Program interrupt,  
so MSR[DE] doesn't matter.


> The "&= ~MSR_DE" line is pointless on bookehv, and makes it harder  
to read.  I had to stare at it a while before noticing that you  
initially set is_debug from the guest MSR and that you'd never really  
clear MSR_DE here on bookehv.


Well, I'm mostly bouncing ideas here to find a way to express what  
we're trying to say in a way that someone who hasn't read this email  
thread would still understand what's going on :).


I think it's already straightforward enough if you accept that shared  
debug resources aren't supported, and that we are either in a mode  
where the real MSR[DE] reflects the guest MSR[DE], or a mode where the  
real MSR[DE] is always on in guest mode and the guest MSR[DE] is  
irrelevant.



How about this version?


diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 38a62ef..9929c41 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -133,6 +133,28 @@ static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu  
*vcpu)

 #endif
 }

+static void kvmppc_vcpu_sync_debug(struct kvm_vcpu *vcpu)
+{
+#ifndef CONFIG_KVM_BOOKE_HV
+	/* Synchronize guest's desire to get debug interrupts into  
shadow MSR */

+   vcpu->arch.shadow_msr &= ~MSR_DE;
+   vcpu->arch.shadow_msr |= vcpu->arch.shared->msr & MSR_DE;
+#endif
+
+	/* Force enable debug interrupts when user space wants to debug  
*/

+   if (vcpu->guest_debug) {
+#ifdef CONFIG_KVM_BOOKE_HV
+   /*
+		 * Since there is no shadow MSR, sync MSR_DE into the  
guest

+* visible MSR.
+*/
+   

RE: [PATCH 0/8] KVM: BOOKE/BOOKEHV : Added debug stub support

2013-02-01 Thread Bhushan Bharat-R65777


> -Original Message-
> From: Alexander Graf [mailto:ag...@suse.de]
> Sent: Friday, February 01, 2013 1:34 PM
> To: Bhushan Bharat-R65777
> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
> Subject: Re: [PATCH 0/8] KVM: BOOKE/BOOKEHV : Added debug stub support
> 
> 
> On 01.02.2013, at 04:49, Bhushan Bharat-R65777 wrote:
> 
> >
> >
> >> -Original Message-
> >> From: kvm-ppc-ow...@vger.kernel.org
> >> [mailto:kvm-ppc-ow...@vger.kernel.org] On Behalf Of Alexander Graf
> >> Sent: Friday, January 25, 2013 6:08 PM
> >> To: Bhushan Bharat-R65777
> >> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan
> >> Bharat-R65777
> >> Subject: Re: [PATCH 0/8] KVM: BOOKE/BOOKEHV : Added debug stub
> >> support
> >>
> >>
> >> On 16.01.2013, at 09:20, Bharat Bhushan wrote:
> >>
> >>> This patchset adds the QEMU debug stub support for powerpc 
> >>> (booke/bookehv).
> >>> [1/8] KVM: PPC: booke: use vcpu reference from thread_struct
> >>>   - This is a cleanup patch to use vcpu reference from thread struct
> >>> [2/8] KVM: PPC: booke: Allow multiple exception types [3/8] KVM: PPC:
> >>> booke: Added debug handler
> >>>   - These two patches install the KVM debug handler.
> >>> [4/8] Added ONE_REG interface for debug instruction
> >>>   - Add the ioctl interface to get the debug instruction for
> >>> setting software breakpoint from QEMU debug stub.
> >>> [5/8] KVM: PPC: debug stub interface parameter defined [6/8] booke:
> >>> Added DBCR4 SPR number [7/8] KVM: booke/bookehv: Add debug stub
> >>> support
> >>>   - Add the debug stub interface on booke/bookehv [8/8] KVM:PPC:booke:
> >>> Allow debug interrupt injection to guest
> >>>   -- with this qemu can inject debug interrupt to guest
> >>
> >> Thanks, applied 1/8, 2/8, 6/8.
> >
> >
> > Alex I cannot see these 3 patches on kvm-ppc-next branch. Are those applied 
> > on
> some other branch ?
> 
> Yes, my staging tree is now kvm-ppc-queue, as I'm not allowed to rebase 
> kvm-ppc-
> next...

On which branch we should send our patches on kvm-ppc-queue or kmv-ppc-next?

Thanks
-Bharat

--
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 3/8] KVM: PPC: booke: Added debug handler

2013-02-01 Thread Bhushan Bharat-R65777


> -Original Message-
> From: Alexander Graf [mailto:ag...@suse.de]
> Sent: Friday, February 01, 2013 1:36 PM
> To: Bhushan Bharat-R65777
> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
> Subject: Re: [PATCH 3/8] KVM: PPC: booke: Added debug handler
> 
> 
> On 01.02.2013, at 06:04, Bhushan Bharat-R65777 wrote:
> 
> >
> >
> >> -Original Message-
> >> From: kvm-ppc-ow...@vger.kernel.org
> >> [mailto:kvm-ppc-ow...@vger.kernel.org] On Behalf Of Alexander Graf
> >> Sent: Thursday, January 31, 2013 10:38 PM
> >> To: Bhushan Bharat-R65777
> >> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
> >> Subject: Re: [PATCH 3/8] KVM: PPC: booke: Added debug handler
> >>
> >>
> >> On 31.01.2013, at 17:58, Bhushan Bharat-R65777 wrote:
> >>
> >>>
> >>>
>  -Original Message-
>  From: Alexander Graf [mailto:ag...@suse.de]
>  Sent: Thursday, January 31, 2013 5:47 PM
>  To: Bhushan Bharat-R65777
>  Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
>  Subject: Re: [PATCH 3/8] KVM: PPC: booke: Added debug handler
> 
> 
>  On 30.01.2013, at 12:30, Bhushan Bharat-R65777 wrote:
> 
> >
> >
> >> -Original Message-
> >> From: Alexander Graf [mailto:ag...@suse.de]
> >> Sent: Friday, January 25, 2013 5:13 PM
> >> To: Bhushan Bharat-R65777
> >> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan
> >> Bharat-R65777
> >> Subject: Re: [PATCH 3/8] KVM: PPC: booke: Added debug handler
> >>
> >>
> >> On 16.01.2013, at 09:24, Bharat Bhushan wrote:
> >>
> >>> From: Bharat Bhushan 
> >>>
> >>> Installed debug handler will be used for guest debug support and
> >>> debug facility emulation features (patches for these features
> >>> will follow this patch).
> >>>
> >>> Signed-off-by: Liu Yu 
> >>> [bharat.bhus...@freescale.com: Substantial changes]
> >>> Signed-off-by: Bharat Bhushan 
> >>> ---
> >>> arch/powerpc/include/asm/kvm_host.h |1 +
> >>> arch/powerpc/kernel/asm-offsets.c   |1 +
> >>> arch/powerpc/kvm/booke_interrupts.S |   49
> ++-
> >> --
>  --
> >>> 3 files changed, 44 insertions(+), 7 deletions(-)
> >>>
> >>> diff --git a/arch/powerpc/include/asm/kvm_host.h
> >>> b/arch/powerpc/include/asm/kvm_host.h
> >>> index 8a72d59..f4ba881 100644
> >>> --- a/arch/powerpc/include/asm/kvm_host.h
> >>> +++ b/arch/powerpc/include/asm/kvm_host.h
> >>> @@ -503,6 +503,7 @@ struct kvm_vcpu_arch {
> >>>   u32 tlbcfg[4];
> >>>   u32 mmucfg;
> >>>   u32 epr;
> >>> + u32 crit_save;
> >>>   struct kvmppc_booke_debug_reg dbg_reg; #endif
> >>>   gpa_t paddr_accessed;
> >>> diff --git a/arch/powerpc/kernel/asm-offsets.c
> >>> b/arch/powerpc/kernel/asm-offsets.c
> >>> index 46f6afd..02048f3 100644
> >>> --- a/arch/powerpc/kernel/asm-offsets.c
> >>> +++ b/arch/powerpc/kernel/asm-offsets.c
> >>> @@ -562,6 +562,7 @@ int main(void)
> >>>   DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, 
> >>> arch.last_inst));
> >>>   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));
> >>> #endif /* CONFIG_PPC_BOOK3S */
> >>> #endif /* CONFIG_KVM */
> >>>
> >>> diff --git a/arch/powerpc/kvm/booke_interrupts.S
> >>> b/arch/powerpc/kvm/booke_interrupts.S
> >>> index eae8483..dd9c5d4 100644
> >>> --- a/arch/powerpc/kvm/booke_interrupts.S
> >>> +++ b/arch/powerpc/kvm/booke_interrupts.S
> >>> @@ -52,12 +52,7 @@
> >>> (1< >>> (1< >>>
> >>> -.macro KVM_HANDLER ivor_nr scratch srr0
> >>> -_GLOBAL(kvmppc_handler_\ivor_nr)
> >>> - /* Get pointer to vcpu and record exit number. */
> >>> - mtspr   \scratch , r4
> >>> - mfspr   r4, SPRN_SPRG_THREAD
> >>> - lwz r4, THREAD_KVM_VCPU(r4)
> >>> +.macro __KVM_HANDLER ivor_nr scratch srr0
> >>>   stw r3, VCPU_GPR(R3)(r4)
> >>>   stw r5, VCPU_GPR(R5)(r4)
> >>>   stw r6, VCPU_GPR(R6)(r4)
> >>> @@ -74,6 +69,46 @@ _GLOBAL(kvmppc_handler_\ivor_nr)
> >>>   bctr
> >>> .endm
> >>>
> >>> +.macro KVM_HANDLER ivor_nr scratch srr0
> >>> +_GLOBAL(kvmppc_handler_\ivor_nr)
> >>> + /* Get pointer to vcpu and record exit number. */
> >>> + mtspr   \scratch , r4
> >>> + mfspr   r4, SPRN_SPRG_THREAD
> >>> + lwz r4, THREAD_KVM_VCPU(r4)
> >>> + __KVM_HANDLER \ivor_nr \scratch \srr0 .endm
> >>> +
> >>> +.macro KVM_DBG_HANDLER ivor_nr scratch srr0
> >>> +_GLOBAL(kvmppc_handler_\ivor_nr)
> >>> + mtspr   \scratch, r4
> >>> + mfspr   r4, SPRN_SPRG_THREAD
> >>

RE: Query about SPE operation fault in e500v2 KVM. thanks.

2013-02-01 Thread Gao Guanhua-B22826
Hi Alex,

The new patch works well.


Regards,
Guanhua

> -Original Message-
> From: Alexander Graf [mailto:ag...@suse.de]
> Sent: Friday, February 01, 2013 4:15 PM
> To: Gao Guanhua-B22826
> Cc: kvm-ppc@vger.kernel.org
> Subject: Re: Query about SPE operation fault in e500v2 KVM. thanks.
> 
> On 01.02.2013, at 07:09, Gao Guanhua-B22826 wrote:
> 
> > Hi Alex,
> >
> > The guest will not be hung after applying the patch, but the test
> result is still wrong.
> >
> > root@model:/media/ram# ./spe_align_e500v2 high in 0x1 out 0x
> > low in 0x1 out 0x spe test failed!
> > Segmentation fault
> >
> > Then we made some more modifications, the test result is right finally.
> >
> > In arch/powerpc/kvm/booke.c  kvmppc_booke_irqprio_deliver:
> >case BOOKE_IRQPRIO_ALIGNMENT:
> >update_dear = true;
> >allowed = 1;
> >msr_mask = MSR_CE | MSR_ME | MSR_DE;
> >int_class = INT_CLASS_NONCRIT;
> >break;
> > In arch/powerpc/kvm/booke_interrupts.S
> > #define NEED_DEAR_MASK ((1< >(1< >(1< >
> > Test result:
> > root@model:/media/ram# ./spe_align_e500v2 high in 0x64 out 0x64 low in
> > 0x64 out 0x64
> 
> Thanks a lot for testing and fixing this one :). I'm glad it works for
> you. I've written up a patch that does this slightly differently and also
> takes EPR into account. Could you please check whether that one works as
> well?
> 
> 
> Thanks,
> 
> 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 7/8] KVM: PPC: booke/bookehv: Add debug stub support

2013-02-01 Thread Alexander Graf

On 01.02.2013, at 07:31, Bhushan Bharat-R65777 wrote:

> 
> 
>> -Original Message-
>> From: Alexander Graf [mailto:ag...@suse.de]
>> Sent: Friday, January 25, 2013 5:37 PM
>> To: Bhushan Bharat-R65777
>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan Bharat-R65777
>> Subject: Re: [PATCH 7/8] KVM: PPC: booke/bookehv: Add debug stub support
>> 
>> 
>> On 16.01.2013, at 09:24, 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_host.h   |5 +
>>> arch/powerpc/include/asm/kvm_ppc.h|2 +
>>> arch/powerpc/include/uapi/asm/kvm.h   |   22 -
>>> arch/powerpc/kernel/asm-offsets.c |   26 ++
>>> arch/powerpc/kvm/booke.c  |  124 +
>>> arch/powerpc/kvm/booke_interrupts.S   |  114 ++
>>> arch/powerpc/kvm/bookehv_interrupts.S |  145 
>>> -
>>> arch/powerpc/kvm/e500_emulate.c   |6 ++
>>> arch/powerpc/kvm/e500mc.c |3 +-
>>> 9 files changed, 422 insertions(+), 25 deletions(-)
>>> 
>>> diff --git a/arch/powerpc/include/asm/kvm_host.h
>>> b/arch/powerpc/include/asm/kvm_host.h
>>> index f4ba881..a9feeb0 100644
>>> --- a/arch/powerpc/include/asm/kvm_host.h
>>> +++ b/arch/powerpc/include/asm/kvm_host.h
>>> @@ -504,7 +504,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/include/asm/kvm_ppc.h
>>> b/arch/powerpc/include/asm/kvm_ppc.h
>>> index b3c481e..e4b3398 100644
>>> --- a/arch/powerpc/include/asm/kvm_ppc.h
>>> +++ b/arch/powerpc/include/asm/kvm_ppc.h
>>> @@ -45,6 +45,8 @@ enum emulation_result {
>>> EMULATE_FAIL, /* can't emulate this instruction */
>>> EMULATE_AGAIN,/* something went wrong. go again */
>>> EMULATE_DO_PAPR,  /* kvm_run filled with PAPR request */
>>> +   EMULATE_DEBUG_INST,   /* debug instruction for software
>>> +breakpoint, exit to userspace */
>> 
>> Does this do something different from DO_PAPR? Maybe it makes sense to have 
>> an
>> exit code EMULATE_EXIT_USER?
> 
> I think EMULATE_DO_PAPR does something similar but the name is confusing. May 
> be we can rename EMULATE_DO_PAPR to 
> EMULATE_EXIT_USER.

Yeah, please check that it actually does the right thing still for PAPR exits 
then :).


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


[PATCH] KVM: PPC: BookE: Handle alignment interrupts

2013-02-01 Thread Alexander Graf
When the guest triggers an alignment interrupt, we don't handle it properly
today and instead BUG_ON(). This really shouldn't happen.

Instead, we should just pass the interrupt back into the guest so it can deal
with it.

Reported-by: Gao Guanhua-B22826 
Signed-off-by: Alexander Graf 
---
 arch/powerpc/kvm/booke.c|   16 +++-
 arch/powerpc/kvm/booke_interrupts.S |6 --
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index d2f502d..020923e 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -182,6 +182,14 @@ static void kvmppc_core_queue_inst_storage(struct kvm_vcpu 
*vcpu,
kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_INST_STORAGE);
 }
 
+static void kvmppc_core_queue_alignment(struct kvm_vcpu *vcpu, ulong 
dear_flags,
+   ulong esr_flags)
+{
+   vcpu->arch.queued_dear = dear_flags;
+   vcpu->arch.queued_esr = esr_flags;
+   kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_ALIGNMENT);
+}
+
 void kvmppc_core_queue_program(struct kvm_vcpu *vcpu, ulong esr_flags)
 {
vcpu->arch.queued_esr = esr_flags;
@@ -345,6 +353,7 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu 
*vcpu,
switch (priority) {
case BOOKE_IRQPRIO_DTLB_MISS:
case BOOKE_IRQPRIO_DATA_STORAGE:
+   case BOOKE_IRQPRIO_ALIGNMENT:
update_dear = true;
/* fall through */
case BOOKE_IRQPRIO_INST_STORAGE:
@@ -358,7 +367,6 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu 
*vcpu,
case BOOKE_IRQPRIO_SPE_FP_DATA:
case BOOKE_IRQPRIO_SPE_FP_ROUND:
case BOOKE_IRQPRIO_AP_UNAVAIL:
-   case BOOKE_IRQPRIO_ALIGNMENT:
allowed = 1;
msr_mask = MSR_CE | MSR_ME | MSR_DE;
int_class = INT_CLASS_NONCRIT;
@@ -971,6 +979,12 @@ int kvmppc_handle_exit(struct kvm_run *run, struct 
kvm_vcpu *vcpu,
r = RESUME_GUEST;
break;
 
+   case BOOKE_INTERRUPT_ALIGNMENT:
+   kvmppc_core_queue_alignment(vcpu, vcpu->arch.fault_dear,
+   vcpu->arch.fault_esr);
+   r = RESUME_GUEST;
+   break;
+
 #ifdef CONFIG_KVM_BOOKE_HV
case BOOKE_INTERRUPT_HV_SYSCALL:
if (!(vcpu->arch.shared->msr & MSR_PR)) {
diff --git a/arch/powerpc/kvm/booke_interrupts.S 
b/arch/powerpc/kvm/booke_interrupts.S
index eae8483..7fa4167 100644
--- a/arch/powerpc/kvm/booke_interrupts.S
+++ b/arch/powerpc/kvm/booke_interrupts.S
@@ -45,12 +45,14 @@
 (1

Re: Query about SPE operation fault in e500v2 KVM. thanks.

2013-02-01 Thread Alexander Graf
On 01.02.2013, at 07:09, Gao Guanhua-B22826 wrote:

> Hi Alex,
> 
> The guest will not be hung after applying the patch, but the test result is 
> still wrong.
> 
> root@model:/media/ram# ./spe_align_e500v2
> high in 0x1 out 0x
> low in 0x1 out 0x
> spe test failed!
> Segmentation fault
> 
> Then we made some more modifications, the test result is right finally.
> 
> In arch/powerpc/kvm/booke.c  kvmppc_booke_irqprio_deliver:
>case BOOKE_IRQPRIO_ALIGNMENT:
>update_dear = true;
>allowed = 1;
>msr_mask = MSR_CE | MSR_ME | MSR_DE;
>int_class = INT_CLASS_NONCRIT;
>break;
> In arch/powerpc/kvm/booke_interrupts.S
> #define NEED_DEAR_MASK ((1<(1<(1< 
> Test result:
> root@model:/media/ram# ./spe_align_e500v2
> high in 0x64 out 0x64
> low in 0x64 out 0x64

Thanks a lot for testing and fixing this one :). I'm glad it works for you. 
I've written up a patch that does this slightly differently and also takes EPR 
into account. Could you please check whether that one works as well?


Thanks,

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 3/8] KVM: PPC: booke: Added debug handler

2013-02-01 Thread Alexander Graf

On 01.02.2013, at 06:04, Bhushan Bharat-R65777 wrote:

> 
> 
>> -Original Message-
>> From: kvm-ppc-ow...@vger.kernel.org [mailto:kvm-ppc-ow...@vger.kernel.org] On
>> Behalf Of Alexander Graf
>> Sent: Thursday, January 31, 2013 10:38 PM
>> To: Bhushan Bharat-R65777
>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
>> Subject: Re: [PATCH 3/8] KVM: PPC: booke: Added debug handler
>> 
>> 
>> On 31.01.2013, at 17:58, Bhushan Bharat-R65777 wrote:
>> 
>>> 
>>> 
 -Original Message-
 From: Alexander Graf [mailto:ag...@suse.de]
 Sent: Thursday, January 31, 2013 5:47 PM
 To: Bhushan Bharat-R65777
 Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org
 Subject: Re: [PATCH 3/8] KVM: PPC: booke: Added debug handler
 
 
 On 30.01.2013, at 12:30, Bhushan Bharat-R65777 wrote:
 
> 
> 
>> -Original Message-
>> From: Alexander Graf [mailto:ag...@suse.de]
>> Sent: Friday, January 25, 2013 5:13 PM
>> To: Bhushan Bharat-R65777
>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan
>> Bharat-R65777
>> Subject: Re: [PATCH 3/8] KVM: PPC: booke: Added debug handler
>> 
>> 
>> On 16.01.2013, at 09:24, Bharat Bhushan wrote:
>> 
>>> From: Bharat Bhushan 
>>> 
>>> Installed debug handler will be used for guest debug support and
>>> debug facility emulation features (patches for these features will
>>> follow this patch).
>>> 
>>> Signed-off-by: Liu Yu 
>>> [bharat.bhus...@freescale.com: Substantial changes]
>>> Signed-off-by: Bharat Bhushan 
>>> ---
>>> arch/powerpc/include/asm/kvm_host.h |1 +
>>> arch/powerpc/kernel/asm-offsets.c   |1 +
>>> arch/powerpc/kvm/booke_interrupts.S |   49 
>>> ++-
>> --
 --
>>> 3 files changed, 44 insertions(+), 7 deletions(-)
>>> 
>>> diff --git a/arch/powerpc/include/asm/kvm_host.h
>>> b/arch/powerpc/include/asm/kvm_host.h
>>> index 8a72d59..f4ba881 100644
>>> --- a/arch/powerpc/include/asm/kvm_host.h
>>> +++ b/arch/powerpc/include/asm/kvm_host.h
>>> @@ -503,6 +503,7 @@ struct kvm_vcpu_arch {
>>> u32 tlbcfg[4];
>>> u32 mmucfg;
>>> u32 epr;
>>> +   u32 crit_save;
>>> struct kvmppc_booke_debug_reg dbg_reg; #endif
>>> gpa_t paddr_accessed;
>>> diff --git a/arch/powerpc/kernel/asm-offsets.c
>>> b/arch/powerpc/kernel/asm-offsets.c
>>> index 46f6afd..02048f3 100644
>>> --- a/arch/powerpc/kernel/asm-offsets.c
>>> +++ b/arch/powerpc/kernel/asm-offsets.c
>>> @@ -562,6 +562,7 @@ int main(void)
>>> DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, 
>>> arch.last_inst));
>>> 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));
>>> #endif /* CONFIG_PPC_BOOK3S */
>>> #endif /* CONFIG_KVM */
>>> 
>>> diff --git a/arch/powerpc/kvm/booke_interrupts.S
>>> b/arch/powerpc/kvm/booke_interrupts.S
>>> index eae8483..dd9c5d4 100644
>>> --- a/arch/powerpc/kvm/booke_interrupts.S
>>> +++ b/arch/powerpc/kvm/booke_interrupts.S
>>> @@ -52,12 +52,7 @@
>>> (1<>> (1<>> 
>>> -.macro KVM_HANDLER ivor_nr scratch srr0
>>> -_GLOBAL(kvmppc_handler_\ivor_nr)
>>> -   /* Get pointer to vcpu and record exit number. */
>>> -   mtspr   \scratch , r4
>>> -   mfspr   r4, SPRN_SPRG_THREAD
>>> -   lwz r4, THREAD_KVM_VCPU(r4)
>>> +.macro __KVM_HANDLER ivor_nr scratch srr0
>>> stw r3, VCPU_GPR(R3)(r4)
>>> stw r5, VCPU_GPR(R5)(r4)
>>> stw r6, VCPU_GPR(R6)(r4)
>>> @@ -74,6 +69,46 @@ _GLOBAL(kvmppc_handler_\ivor_nr)
>>> bctr
>>> .endm
>>> 
>>> +.macro KVM_HANDLER ivor_nr scratch srr0
>>> +_GLOBAL(kvmppc_handler_\ivor_nr)
>>> +   /* Get pointer to vcpu and record exit number. */
>>> +   mtspr   \scratch , r4
>>> +   mfspr   r4, SPRN_SPRG_THREAD
>>> +   lwz r4, THREAD_KVM_VCPU(r4)
>>> +   __KVM_HANDLER \ivor_nr \scratch \srr0 .endm
>>> +
>>> +.macro KVM_DBG_HANDLER ivor_nr scratch srr0
>>> +_GLOBAL(kvmppc_handler_\ivor_nr)
>>> +   mtspr   \scratch, r4
>>> +   mfspr   r4, SPRN_SPRG_THREAD
>>> +   lwz r4, THREAD_KVM_VCPU(r4)
>>> +   stw r3, VCPU_CRIT_SAVE(r4)
>>> +   mfcrr3
>>> +   mfspr   r4, SPRN_CSRR1
>>> +   andi.   r4, r4, MSR_PR
>>> +   bne 1f
>> 
>> 
>>> +   /* debug interrupt happened in enter/exit path */
>>> +   mfspr   r4, SPRN_CSRR1
>>> +   rlwinm  r4, r4, 0, ~MSR_DE
>>> +   mtspr   SPRN_CSRR1, r4
>

Re: [PATCH 0/8] KVM: BOOKE/BOOKEHV : Added debug stub support

2013-02-01 Thread Alexander Graf

On 01.02.2013, at 04:49, Bhushan Bharat-R65777 wrote:

> 
> 
>> -Original Message-
>> From: kvm-ppc-ow...@vger.kernel.org [mailto:kvm-ppc-ow...@vger.kernel.org] On
>> Behalf Of Alexander Graf
>> Sent: Friday, January 25, 2013 6:08 PM
>> To: Bhushan Bharat-R65777
>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Bhushan Bharat-R65777
>> Subject: Re: [PATCH 0/8] KVM: BOOKE/BOOKEHV : Added debug stub support
>> 
>> 
>> On 16.01.2013, at 09:20, Bharat Bhushan wrote:
>> 
>>> This patchset adds the QEMU debug stub support for powerpc (booke/bookehv).
>>> [1/8] KVM: PPC: booke: use vcpu reference from thread_struct
>>> - This is a cleanup patch to use vcpu reference from thread struct
>>> [2/8] KVM: PPC: booke: Allow multiple exception types [3/8] KVM: PPC:
>>> booke: Added debug handler
>>> - These two patches install the KVM debug handler.
>>> [4/8] Added ONE_REG interface for debug instruction
>>> - Add the ioctl interface to get the debug instruction for
>>>   setting software breakpoint from QEMU debug stub.
>>> [5/8] KVM: PPC: debug stub interface parameter defined [6/8] booke:
>>> Added DBCR4 SPR number [7/8] KVM: booke/bookehv: Add debug stub
>>> support
>>> - Add the debug stub interface on booke/bookehv [8/8] KVM:PPC:booke:
>>> Allow debug interrupt injection to guest
>>> -- with this qemu can inject debug interrupt to guest
>> 
>> Thanks, applied 1/8, 2/8, 6/8.
> 
> 
> Alex I cannot see these 3 patches on kvm-ppc-next branch. Are those applied 
> on some other branch ?

Yes, my staging tree is now kvm-ppc-queue, as I'm not allowed to rebase 
kvm-ppc-next...


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