Message ID | 1343977723-25341-3-git-send-email-Bharat.Bhushan@freescale.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 03.08.2012, at 09:08, Bharat Bhushan wrote: > 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 <yu.liu@freescale.com> > [bharat.bhushan@freescale.com: Substantial changes] > Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com> > > Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com> > --- > arch/powerpc/include/asm/kvm_host.h | 1 + > arch/powerpc/kernel/asm-offsets.c | 1 + > arch/powerpc/kvm/booke_interrupts.S | 45 +++++++++++++++++++++++++++++++++++ > 3 files changed, 47 insertions(+), 0 deletions(-) > > diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h > index dcee499..bd78523 100644 > --- a/arch/powerpc/include/asm/kvm_host.h > +++ b/arch/powerpc/include/asm/kvm_host.h > @@ -494,6 +494,7 @@ struct kvm_vcpu_arch { > u32 tlbcfg[4]; > u32 mmucfg; > u32 epr; > + u32 crit_save; > #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 85b05c4..92f149b 100644 > --- a/arch/powerpc/kernel/asm-offsets.c > +++ b/arch/powerpc/kernel/asm-offsets.c > @@ -563,6 +563,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 3539805..890673c 100644 > --- a/arch/powerpc/kvm/booke_interrupts.S > +++ b/arch/powerpc/kvm/booke_interrupts.S > @@ -73,6 +73,51 @@ _GLOBAL(kvmppc_handler_\ivor_nr) > bctr > .endm > > +.macro KVM_DBG_HANDLER ivor_nr scratch srr0 This is a lot of asm code. Any chance to share a good share of it with the generic handler? Alex > +_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) > + mfcr r3 > + 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 > + lis r4, 0xffff > + ori r4, r4, 0xffff > + mtspr SPRN_DBSR, r4 > + mfspr r4, SPRN_SPRG_THREAD > + lwz r4, THREAD_KVM_VCPU(r4) > + mtcr r3 > + lwz r3, VCPU_CRIT_SAVE(r4) > + mfspr r4, \scratch > + rfci > +1: /* debug interrupt happened in guest */ > + mfspr r4, \scratch > + mtcr r3 > + mr r3, r4 > + mfspr r4, SPRN_SPRG_THREAD > + lwz r4, THREAD_KVM_VCPU(r4) > + stw r3, VCPU_GPR(R4)(r4) > + stw r5, VCPU_GPR(R5)(r4) > + stw r6, VCPU_GPR(R6)(r4) > + lwz r3, VCPU_CRIT_SAVE(r4) > + mfspr r5, \srr0 > + stw r3, VCPU_GPR(R3)(r4) > + stw r5, VCPU_PC(r4) > + mfctr r5 > + lis r6, kvmppc_resume_host@h > + stw r5, VCPU_CTR(r4) > + li r5, \ivor_nr > + ori r6, r6, kvmppc_resume_host@l > + mtctr r6 > + bctr > +.endm > + > .macro KVM_HANDLER_ADDR ivor_nr > .long kvmppc_handler_\ivor_nr > .endm > -- > 1.7.0.4 > > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> -----Original Message----- > From: kvm-ppc-owner@vger.kernel.org [mailto:kvm-ppc-owner@vger.kernel.org] On > Behalf Of Alexander Graf > Sent: Tuesday, August 07, 2012 4:18 PM > To: Bhushan Bharat-R65777 > Cc: kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Bhushan Bharat-R65777 > Subject: Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler > > > On 03.08.2012, at 09:08, Bharat Bhushan wrote: > > > 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 <yu.liu@freescale.com> > > [bharat.bhushan@freescale.com: Substantial changes] > > Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com> > > > > Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com> > > --- > > arch/powerpc/include/asm/kvm_host.h | 1 + > > arch/powerpc/kernel/asm-offsets.c | 1 + > > arch/powerpc/kvm/booke_interrupts.S | 45 +++++++++++++++++++++++++++++++++++ > > 3 files changed, 47 insertions(+), 0 deletions(-) > > > > diff --git a/arch/powerpc/include/asm/kvm_host.h > > b/arch/powerpc/include/asm/kvm_host.h > > index dcee499..bd78523 100644 > > --- a/arch/powerpc/include/asm/kvm_host.h > > +++ b/arch/powerpc/include/asm/kvm_host.h > > @@ -494,6 +494,7 @@ struct kvm_vcpu_arch { > > u32 tlbcfg[4]; > > u32 mmucfg; > > u32 epr; > > + u32 crit_save; > > #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 85b05c4..92f149b 100644 > > --- a/arch/powerpc/kernel/asm-offsets.c > > +++ b/arch/powerpc/kernel/asm-offsets.c > > @@ -563,6 +563,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 3539805..890673c 100644 > > --- a/arch/powerpc/kvm/booke_interrupts.S > > +++ b/arch/powerpc/kvm/booke_interrupts.S > > @@ -73,6 +73,51 @@ _GLOBAL(kvmppc_handler_\ivor_nr) > > bctr > > .endm > > > > +.macro KVM_DBG_HANDLER ivor_nr scratch srr0 > > This is a lot of asm code. Any chance to share a good share of it with the > generic handler? Yes it is a lot of code but I am finding it difficult. Thanks -Bharat > > > Alex > > > +_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) > > + mfcr r3 > > + 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 > > + lis r4, 0xffff > > + ori r4, r4, 0xffff > > + mtspr SPRN_DBSR, r4 > > + mfspr r4, SPRN_SPRG_THREAD > > + lwz r4, THREAD_KVM_VCPU(r4) > > + mtcr r3 > > + lwz r3, VCPU_CRIT_SAVE(r4) > > + mfspr r4, \scratch > > + rfci > > +1: /* debug interrupt happened in guest */ > > + mfspr r4, \scratch > > + mtcr r3 > > + mr r3, r4 > > + mfspr r4, SPRN_SPRG_THREAD > > + lwz r4, THREAD_KVM_VCPU(r4) > > + stw r3, VCPU_GPR(R4)(r4) > > + stw r5, VCPU_GPR(R5)(r4) > > + stw r6, VCPU_GPR(R6)(r4) > > + lwz r3, VCPU_CRIT_SAVE(r4) > > + mfspr r5, \srr0 > > + stw r3, VCPU_GPR(R3)(r4) > > + stw r5, VCPU_PC(r4) > > + mfctr r5 > > + lis r6, kvmppc_resume_host@h > > + stw r5, VCPU_CTR(r4) > > + li r5, \ivor_nr > > + ori r6, r6, kvmppc_resume_host@l > > + mtctr r6 > > + bctr > > +.endm > > + > > .macro KVM_HANDLER_ADDR ivor_nr > > .long kvmppc_handler_\ivor_nr > > .endm > > -- > > 1.7.0.4 > > > > > > -- > To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body > of a message to majordomo@vger.kernel.org More majordomo info at > http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/07/2012 05:47 AM, Alexander Graf wrote: >> diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S >> index 3539805..890673c 100644 >> --- a/arch/powerpc/kvm/booke_interrupts.S >> +++ b/arch/powerpc/kvm/booke_interrupts.S >> @@ -73,6 +73,51 @@ _GLOBAL(kvmppc_handler_\ivor_nr) >> bctr >> .endm >> >> +.macro KVM_DBG_HANDLER ivor_nr scratch srr0 > > This is a lot of asm code. Any chance to share a good share of it with the generic handler? That entire file could use an update to lok more like bookehv_interrupts.S and its use of asm macros. -Scott -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogV29vZCBTY290dC1CMDc0 MjENCj4gU2VudDogV2VkbmVzZGF5LCBBdWd1c3QgMDgsIDIwMTIgMjoxNSBBTQ0KPiBUbzogQWxl eGFuZGVyIEdyYWYNCj4gQ2M6IEJodXNoYW4gQmhhcmF0LVI2NTc3Nzsga3ZtLXBwY0B2Z2VyLmtl cm5lbC5vcmc7IGt2bUB2Z2VyLmtlcm5lbC5vcmc7IEJodXNoYW4NCj4gQmhhcmF0LVI2NTc3Nw0K PiBTdWJqZWN0OiBSZTogW1BBVENIIDMvM10gS1ZNOiBQUEM6IGJvb2tlOiBBZGRlZCBkZWJ1ZyBo YW5kbGVyDQo+IA0KPiBPbiAwOC8wNy8yMDEyIDA1OjQ3IEFNLCBBbGV4YW5kZXIgR3JhZiB3cm90 ZToNCj4gPj4gZGlmZiAtLWdpdCBhL2FyY2gvcG93ZXJwYy9rdm0vYm9va2VfaW50ZXJydXB0cy5T DQo+ID4+IGIvYXJjaC9wb3dlcnBjL2t2bS9ib29rZV9pbnRlcnJ1cHRzLlMNCj4gPj4gaW5kZXgg MzUzOTgwNS4uODkwNjczYyAxMDA2NDQNCj4gPj4gLS0tIGEvYXJjaC9wb3dlcnBjL2t2bS9ib29r ZV9pbnRlcnJ1cHRzLlMNCj4gPj4gKysrIGIvYXJjaC9wb3dlcnBjL2t2bS9ib29rZV9pbnRlcnJ1 cHRzLlMNCj4gPj4gQEAgLTczLDYgKzczLDUxIEBAIF9HTE9CQUwoa3ZtcHBjX2hhbmRsZXJfXGl2 b3JfbnIpDQo+ID4+IAliY3RyDQo+ID4+IC5lbmRtDQo+ID4+DQo+ID4+ICsubWFjcm8gS1ZNX0RC R19IQU5ETEVSIGl2b3JfbnIgc2NyYXRjaCBzcnIwDQo+ID4NCj4gPiBUaGlzIGlzIGEgbG90IG9m IGFzbSBjb2RlLiBBbnkgY2hhbmNlIHRvIHNoYXJlIGEgZ29vZCBzaGFyZSBvZiBpdCB3aXRoIHRo ZQ0KPiBnZW5lcmljIGhhbmRsZXI/DQo+IA0KPiBUaGF0IGVudGlyZSBmaWxlIGNvdWxkIHVzZSBh biB1cGRhdGUgdG8gbG9rIG1vcmUgbGlrZSBib29rZWh2X2ludGVycnVwdHMuUyBhbmQNCj4gaXRz IHVzZSBvZiBhc20gbWFjcm9zLg0KDQpJbiBib29rZSB0aGVyZSBpcyBhc3N1bXB0aW9uIHRoYXQg c2l6ZSBvZiBLVk0gSVZPUnMgd2lsbCBub3QgbWUgbW9yZSB0aGFuIGhvc3QgSVZPUnMgc2l6ZSBz byB0aGF0IG9ubHkgSVZQUiBpcyBjaGFuZ2VkLiANCg0KSSB0cmllZCB0byBnaXZlIGl0IHRoYXQg c2hhcGUgb2YgYm9va2Vodl9pbnRlcnJ1cHRzLlMgIGFuZCBmb3VuZCB0aGF0IHNpemUgb2Ygc29t ZSBJVk9ScyBiZWNvbWUgbW9yZSB0aGFuIGhvc3QgSVZPUnMuDQoNClRoYW5rcw0KLUJoYXJhdA0K -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08.08.2012, at 03:02, Bhushan Bharat-R65777 wrote: > > >> -----Original Message----- >> From: Wood Scott-B07421 >> Sent: Wednesday, August 08, 2012 2:15 AM >> To: Alexander Graf >> Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Bhushan >> Bharat-R65777 >> Subject: Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler >> >> On 08/07/2012 05:47 AM, Alexander Graf wrote: >>>> diff --git a/arch/powerpc/kvm/booke_interrupts.S >>>> b/arch/powerpc/kvm/booke_interrupts.S >>>> index 3539805..890673c 100644 >>>> --- a/arch/powerpc/kvm/booke_interrupts.S >>>> +++ b/arch/powerpc/kvm/booke_interrupts.S >>>> @@ -73,6 +73,51 @@ _GLOBAL(kvmppc_handler_\ivor_nr) >>>> bctr >>>> .endm >>>> >>>> +.macro KVM_DBG_HANDLER ivor_nr scratch srr0 >>> >>> This is a lot of asm code. Any chance to share a good share of it with the >> generic handler? >> >> That entire file could use an update to lok more like bookehv_interrupts.S and >> its use of asm macros. > > In booke there is assumption that size of KVM IVORs will not me more than host IVORs size so that only IVPR is changed. > > I tried to give it that shape of bookehv_interrupts.S and found that size of some IVORs become more than host IVORs. We can always jump off to another (more generic?) function and only have a small stub in the IVOR referenced code. Alex -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> -----Original Message----- > From: kvm-ppc-owner@vger.kernel.org [mailto:kvm-ppc-owner@vger.kernel.org] On > Behalf Of Alexander Graf > Sent: Wednesday, August 08, 2012 4:41 PM > To: Bhushan Bharat-R65777 > Cc: Wood Scott-B07421; kvm-ppc@vger.kernel.org; kvm@vger.kernel.org > Subject: Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler > > > On 08.08.2012, at 03:02, Bhushan Bharat-R65777 wrote: > > > > > > >> -----Original Message----- > >> From: Wood Scott-B07421 > >> Sent: Wednesday, August 08, 2012 2:15 AM > >> To: Alexander Graf > >> Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org; > >> kvm@vger.kernel.org; Bhushan > >> Bharat-R65777 > >> Subject: Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler > >> > >> On 08/07/2012 05:47 AM, Alexander Graf wrote: > >>>> diff --git a/arch/powerpc/kvm/booke_interrupts.S > >>>> b/arch/powerpc/kvm/booke_interrupts.S > >>>> index 3539805..890673c 100644 > >>>> --- a/arch/powerpc/kvm/booke_interrupts.S > >>>> +++ b/arch/powerpc/kvm/booke_interrupts.S > >>>> @@ -73,6 +73,51 @@ _GLOBAL(kvmppc_handler_\ivor_nr) > >>>> bctr > >>>> .endm > >>>> > >>>> +.macro KVM_DBG_HANDLER ivor_nr scratch srr0 > >>> > >>> This is a lot of asm code. Any chance to share a good share of it > >>> with the > >> generic handler? > >> > >> That entire file could use an update to lok more like > >> bookehv_interrupts.S and its use of asm macros. > > > > In booke there is assumption that size of KVM IVORs will not me more than host > IVORs size so that only IVPR is changed. > > > > I tried to give it that shape of bookehv_interrupts.S and found that size of > some IVORs become more than host IVORs. > > We can always jump off to another (more generic?) function and only have a small > stub in the IVOR referenced code. What extra KVM_DBG_HANDLER have from KVM_HANDLER is the handing of debug single step (which is similar to host). So do you want a jump in assembly for handling the debug single step? Or you really think of moving something from the KVM_HANDLER to more generic? Thanks -Bharat -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 10.08.2012, at 08:55, Bhushan Bharat-R65777 wrote: > > >> -----Original Message----- >> From: kvm-ppc-owner@vger.kernel.org [mailto:kvm-ppc-owner@vger.kernel.org] On >> Behalf Of Alexander Graf >> Sent: Wednesday, August 08, 2012 4:41 PM >> To: Bhushan Bharat-R65777 >> Cc: Wood Scott-B07421; kvm-ppc@vger.kernel.org; kvm@vger.kernel.org >> Subject: Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler >> >> >> On 08.08.2012, at 03:02, Bhushan Bharat-R65777 wrote: >> >>> >>> >>>> -----Original Message----- >>>> From: Wood Scott-B07421 >>>> Sent: Wednesday, August 08, 2012 2:15 AM >>>> To: Alexander Graf >>>> Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org; >>>> kvm@vger.kernel.org; Bhushan >>>> Bharat-R65777 >>>> Subject: Re: [PATCH 3/3] KVM: PPC: booke: Added debug handler >>>> >>>> On 08/07/2012 05:47 AM, Alexander Graf wrote: >>>>>> diff --git a/arch/powerpc/kvm/booke_interrupts.S >>>>>> b/arch/powerpc/kvm/booke_interrupts.S >>>>>> index 3539805..890673c 100644 >>>>>> --- a/arch/powerpc/kvm/booke_interrupts.S >>>>>> +++ b/arch/powerpc/kvm/booke_interrupts.S >>>>>> @@ -73,6 +73,51 @@ _GLOBAL(kvmppc_handler_\ivor_nr) >>>>>> bctr >>>>>> .endm >>>>>> >>>>>> +.macro KVM_DBG_HANDLER ivor_nr scratch srr0 >>>>> >>>>> This is a lot of asm code. Any chance to share a good share of it >>>>> with the >>>> generic handler? >>>> >>>> That entire file could use an update to lok more like >>>> bookehv_interrupts.S and its use of asm macros. >>> >>> In booke there is assumption that size of KVM IVORs will not me more than host >> IVORs size so that only IVPR is changed. >>> >>> I tried to give it that shape of bookehv_interrupts.S and found that size of >> some IVORs become more than host IVORs. >> >> We can always jump off to another (more generic?) function and only have a small >> stub in the IVOR referenced code. > > What extra KVM_DBG_HANDLER have from KVM_HANDLER is the handing of debug single step (which is similar to host). > So do you want a jump in assembly for handling the debug single step? Or you really think of moving something from the KVM_HANDLER to more generic? I'm thinking of "if we don't have enough space in block A, create another block B that has more space to handle things again" :). I'll leave the implementation details to you :D Alex -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index dcee499..bd78523 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h @@ -494,6 +494,7 @@ struct kvm_vcpu_arch { u32 tlbcfg[4]; u32 mmucfg; u32 epr; + u32 crit_save; #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 85b05c4..92f149b 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -563,6 +563,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 3539805..890673c 100644 --- a/arch/powerpc/kvm/booke_interrupts.S +++ b/arch/powerpc/kvm/booke_interrupts.S @@ -73,6 +73,51 @@ _GLOBAL(kvmppc_handler_\ivor_nr) bctr .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) + mfcr r3 + 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 + lis r4, 0xffff + ori r4, r4, 0xffff + mtspr SPRN_DBSR, r4 + mfspr r4, SPRN_SPRG_THREAD + lwz r4, THREAD_KVM_VCPU(r4) + mtcr r3 + lwz r3, VCPU_CRIT_SAVE(r4) + mfspr r4, \scratch + rfci +1: /* debug interrupt happened in guest */ + mfspr r4, \scratch + mtcr r3 + mr r3, r4 + mfspr r4, SPRN_SPRG_THREAD + lwz r4, THREAD_KVM_VCPU(r4) + stw r3, VCPU_GPR(R4)(r4) + stw r5, VCPU_GPR(R5)(r4) + stw r6, VCPU_GPR(R6)(r4) + lwz r3, VCPU_CRIT_SAVE(r4) + mfspr r5, \srr0 + stw r3, VCPU_GPR(R3)(r4) + stw r5, VCPU_PC(r4) + mfctr r5 + lis r6, kvmppc_resume_host@h + stw r5, VCPU_CTR(r4) + li r5, \ivor_nr + ori r6, r6, kvmppc_resume_host@l + mtctr r6 + bctr +.endm + .macro KVM_HANDLER_ADDR ivor_nr .long kvmppc_handler_\ivor_nr .endm