diff options
author | James Hogan <james.hogan@imgtec.com> | 2015-02-06 11:03:57 -0500 |
---|---|---|
committer | James Hogan <james.hogan@imgtec.com> | 2015-03-27 17:25:07 -0400 |
commit | 0a5604272d80c985f87de959f0bb7e36fd53d3c7 (patch) | |
tree | 391bbee989a6ab6ab22d7b4b32a0b7850602d5be /arch/mips/include/asm | |
parent | 64bedffe496820dbb6b53302d80dd0f04db33d8e (diff) |
MIPS: KVM: Handle TRAP exceptions from guest kernel
Trap instructions are used by Linux to implement BUG_ON(), however KVM
doesn't pass trap exceptions on to the guest if they occur in guest
kernel mode, instead triggering an internal error "Exception Code: 13,
not yet handled". The guest kernel then doesn't get a chance to print
the usual BUG message and stack trace.
Implement handling of the trap exception so that it gets passed to the
guest and the user is left with a more useful log message.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: kvm@vger.kernel.org
Cc: linux-mips@linux-mips.org
Diffstat (limited to 'arch/mips/include/asm')
-rw-r--r-- | arch/mips/include/asm/kvm_host.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h index f722b0528c25..8fc3ba2872f0 100644 --- a/arch/mips/include/asm/kvm_host.h +++ b/arch/mips/include/asm/kvm_host.h | |||
@@ -119,6 +119,7 @@ struct kvm_vcpu_stat { | |||
119 | u32 syscall_exits; | 119 | u32 syscall_exits; |
120 | u32 resvd_inst_exits; | 120 | u32 resvd_inst_exits; |
121 | u32 break_inst_exits; | 121 | u32 break_inst_exits; |
122 | u32 trap_inst_exits; | ||
122 | u32 flush_dcache_exits; | 123 | u32 flush_dcache_exits; |
123 | u32 halt_successful_poll; | 124 | u32 halt_successful_poll; |
124 | u32 halt_wakeup; | 125 | u32 halt_wakeup; |
@@ -138,6 +139,7 @@ enum kvm_mips_exit_types { | |||
138 | SYSCALL_EXITS, | 139 | SYSCALL_EXITS, |
139 | RESVD_INST_EXITS, | 140 | RESVD_INST_EXITS, |
140 | BREAK_INST_EXITS, | 141 | BREAK_INST_EXITS, |
142 | TRAP_INST_EXITS, | ||
141 | FLUSH_DCACHE_EXITS, | 143 | FLUSH_DCACHE_EXITS, |
142 | MAX_KVM_MIPS_EXIT_TYPES | 144 | MAX_KVM_MIPS_EXIT_TYPES |
143 | }; | 145 | }; |
@@ -579,6 +581,7 @@ struct kvm_mips_callbacks { | |||
579 | int (*handle_syscall)(struct kvm_vcpu *vcpu); | 581 | int (*handle_syscall)(struct kvm_vcpu *vcpu); |
580 | int (*handle_res_inst)(struct kvm_vcpu *vcpu); | 582 | int (*handle_res_inst)(struct kvm_vcpu *vcpu); |
581 | int (*handle_break)(struct kvm_vcpu *vcpu); | 583 | int (*handle_break)(struct kvm_vcpu *vcpu); |
584 | int (*handle_trap)(struct kvm_vcpu *vcpu); | ||
582 | int (*handle_msa_disabled)(struct kvm_vcpu *vcpu); | 585 | int (*handle_msa_disabled)(struct kvm_vcpu *vcpu); |
583 | int (*vm_init)(struct kvm *kvm); | 586 | int (*vm_init)(struct kvm *kvm); |
584 | int (*vcpu_init)(struct kvm_vcpu *vcpu); | 587 | int (*vcpu_init)(struct kvm_vcpu *vcpu); |
@@ -713,6 +716,11 @@ extern enum emulation_result kvm_mips_emulate_bp_exc(unsigned long cause, | |||
713 | struct kvm_run *run, | 716 | struct kvm_run *run, |
714 | struct kvm_vcpu *vcpu); | 717 | struct kvm_vcpu *vcpu); |
715 | 718 | ||
719 | extern enum emulation_result kvm_mips_emulate_trap_exc(unsigned long cause, | ||
720 | uint32_t *opc, | ||
721 | struct kvm_run *run, | ||
722 | struct kvm_vcpu *vcpu); | ||
723 | |||
716 | extern enum emulation_result kvm_mips_complete_mmio_load(struct kvm_vcpu *vcpu, | 724 | extern enum emulation_result kvm_mips_complete_mmio_load(struct kvm_vcpu *vcpu, |
717 | struct kvm_run *run); | 725 | struct kvm_run *run); |
718 | 726 | ||