diff options
author | Bharat Bhushan <r65777@freescale.com> | 2013-02-27 13:13:10 -0500 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2013-03-21 20:21:09 -0400 |
commit | 15b708beee6841e0a59ded702c8bfe3042a5b5a4 (patch) | |
tree | dedda86eb2701221dbfdb21acae28a6b22439d58 /arch | |
parent | 78accda4f888c77122cf3da6185f905d4677eb07 (diff) |
KVM: PPC: booke: Added debug handler
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: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/asm-offsets.c | 1 | ||||
-rw-r--r-- | arch/powerpc/kvm/booke_interrupts.S | 42 |
3 files changed, 41 insertions, 3 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index d1bb86074721..e34f8fee9080 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h | |||
@@ -504,6 +504,7 @@ struct kvm_vcpu_arch { | |||
504 | u32 tlbcfg[4]; | 504 | u32 tlbcfg[4]; |
505 | u32 mmucfg; | 505 | u32 mmucfg; |
506 | u32 epr; | 506 | u32 epr; |
507 | u32 crit_save; | ||
507 | struct kvmppc_booke_debug_reg dbg_reg; | 508 | struct kvmppc_booke_debug_reg dbg_reg; |
508 | #endif | 509 | #endif |
509 | gpa_t paddr_accessed; | 510 | gpa_t paddr_accessed; |
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index b6c17ec9b169..d87c90886c75 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c | |||
@@ -596,6 +596,7 @@ int main(void) | |||
596 | DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, arch.last_inst)); | 596 | DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, arch.last_inst)); |
597 | DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear)); | 597 | DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear)); |
598 | DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr)); | 598 | DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr)); |
599 | DEFINE(VCPU_CRIT_SAVE, offsetof(struct kvm_vcpu, arch.crit_save)); | ||
599 | #endif /* CONFIG_PPC_BOOK3S */ | 600 | #endif /* CONFIG_PPC_BOOK3S */ |
600 | #endif /* CONFIG_KVM */ | 601 | #endif /* CONFIG_KVM */ |
601 | 602 | ||
diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S index f4bb55c96517..2c6deb5ef2fe 100644 --- a/arch/powerpc/kvm/booke_interrupts.S +++ b/arch/powerpc/kvm/booke_interrupts.S | |||
@@ -54,8 +54,7 @@ | |||
54 | (1<<BOOKE_INTERRUPT_DTLB_MISS) | \ | 54 | (1<<BOOKE_INTERRUPT_DTLB_MISS) | \ |
55 | (1<<BOOKE_INTERRUPT_ALIGNMENT)) | 55 | (1<<BOOKE_INTERRUPT_ALIGNMENT)) |
56 | 56 | ||
57 | .macro KVM_HANDLER ivor_nr scratch srr0 | 57 | .macro __KVM_HANDLER ivor_nr scratch srr0 |
58 | _GLOBAL(kvmppc_handler_\ivor_nr) | ||
59 | /* Get pointer to vcpu and record exit number. */ | 58 | /* Get pointer to vcpu and record exit number. */ |
60 | mtspr \scratch , r4 | 59 | mtspr \scratch , r4 |
61 | mfspr r4, SPRN_SPRG_THREAD | 60 | mfspr r4, SPRN_SPRG_THREAD |
@@ -76,6 +75,43 @@ _GLOBAL(kvmppc_handler_\ivor_nr) | |||
76 | bctr | 75 | bctr |
77 | .endm | 76 | .endm |
78 | 77 | ||
78 | .macro KVM_HANDLER ivor_nr scratch srr0 | ||
79 | _GLOBAL(kvmppc_handler_\ivor_nr) | ||
80 | __KVM_HANDLER \ivor_nr \scratch \srr0 | ||
81 | .endm | ||
82 | |||
83 | .macro KVM_DBG_HANDLER ivor_nr scratch srr0 | ||
84 | _GLOBAL(kvmppc_handler_\ivor_nr) | ||
85 | mtspr \scratch, r4 | ||
86 | mfspr r4, SPRN_SPRG_THREAD | ||
87 | lwz r4, THREAD_KVM_VCPU(r4) | ||
88 | stw r3, VCPU_CRIT_SAVE(r4) | ||
89 | mfcr r3 | ||
90 | mfspr r4, SPRN_CSRR1 | ||
91 | andi. r4, r4, MSR_PR | ||
92 | bne 1f | ||
93 | /* debug interrupt happened in enter/exit path */ | ||
94 | mfspr r4, SPRN_CSRR1 | ||
95 | rlwinm r4, r4, 0, ~MSR_DE | ||
96 | mtspr SPRN_CSRR1, r4 | ||
97 | lis r4, 0xffff | ||
98 | ori r4, r4, 0xffff | ||
99 | mtspr SPRN_DBSR, r4 | ||
100 | mfspr r4, SPRN_SPRG_THREAD | ||
101 | lwz r4, THREAD_KVM_VCPU(r4) | ||
102 | mtcr r3 | ||
103 | lwz r3, VCPU_CRIT_SAVE(r4) | ||
104 | mfspr r4, \scratch | ||
105 | rfci | ||
106 | 1: /* debug interrupt happened in guest */ | ||
107 | mtcr r3 | ||
108 | mfspr r4, SPRN_SPRG_THREAD | ||
109 | lwz r4, THREAD_KVM_VCPU(r4) | ||
110 | lwz r3, VCPU_CRIT_SAVE(r4) | ||
111 | mfspr r4, \scratch | ||
112 | __KVM_HANDLER \ivor_nr \scratch \srr0 | ||
113 | .endm | ||
114 | |||
79 | .macro KVM_HANDLER_ADDR ivor_nr | 115 | .macro KVM_HANDLER_ADDR ivor_nr |
80 | .long kvmppc_handler_\ivor_nr | 116 | .long kvmppc_handler_\ivor_nr |
81 | .endm | 117 | .endm |
@@ -100,7 +136,7 @@ KVM_HANDLER BOOKE_INTERRUPT_FIT SPRN_SPRG_RSCRATCH0 SPRN_SRR0 | |||
100 | KVM_HANDLER BOOKE_INTERRUPT_WATCHDOG SPRN_SPRG_RSCRATCH_CRIT SPRN_CSRR0 | 136 | KVM_HANDLER BOOKE_INTERRUPT_WATCHDOG SPRN_SPRG_RSCRATCH_CRIT SPRN_CSRR0 |
101 | KVM_HANDLER BOOKE_INTERRUPT_DTLB_MISS SPRN_SPRG_RSCRATCH0 SPRN_SRR0 | 137 | KVM_HANDLER BOOKE_INTERRUPT_DTLB_MISS SPRN_SPRG_RSCRATCH0 SPRN_SRR0 |
102 | KVM_HANDLER BOOKE_INTERRUPT_ITLB_MISS SPRN_SPRG_RSCRATCH0 SPRN_SRR0 | 138 | KVM_HANDLER BOOKE_INTERRUPT_ITLB_MISS SPRN_SPRG_RSCRATCH0 SPRN_SRR0 |
103 | KVM_HANDLER BOOKE_INTERRUPT_DEBUG SPRN_SPRG_RSCRATCH_CRIT SPRN_CSRR0 | 139 | KVM_DBG_HANDLER BOOKE_INTERRUPT_DEBUG SPRN_SPRG_RSCRATCH_CRIT SPRN_CSRR0 |
104 | KVM_HANDLER BOOKE_INTERRUPT_SPE_UNAVAIL SPRN_SPRG_RSCRATCH0 SPRN_SRR0 | 140 | KVM_HANDLER BOOKE_INTERRUPT_SPE_UNAVAIL SPRN_SPRG_RSCRATCH0 SPRN_SRR0 |
105 | KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_DATA SPRN_SPRG_RSCRATCH0 SPRN_SRR0 | 141 | KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_DATA SPRN_SPRG_RSCRATCH0 SPRN_SRR0 |
106 | KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_ROUND SPRN_SPRG_RSCRATCH0 SPRN_SRR0 | 142 | KVM_HANDLER BOOKE_INTERRUPT_SPE_FP_ROUND SPRN_SPRG_RSCRATCH0 SPRN_SRR0 |