Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/kvm: common sw breakpoint instr across ppc

This patch extends the use of illegal instruction as software
breakpoint instruction across the ppc platform. Patch extends
booke program interrupt code to support software breakpoint.

Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
[agraf: Fix bookehv]
Signed-off-by: Alexander Graf <agraf@suse.de>

authored by

Madhavan Srinivasan and committed by
Alexander Graf
033aaa14 a59c1d9e

+20 -5
-2
arch/powerpc/include/asm/kvm_booke.h
··· 33 33 #define EHPRIV_OC_SHIFT 11 34 34 /* "ehpriv 1" : ehpriv with OC = 1 is used for debug emulation */ 35 35 #define EHPRIV_OC_DEBUG 1 36 - #define KVMPPC_INST_EHPRIV_DEBUG (KVMPPC_INST_EHPRIV | \ 37 - (EHPRIV_OC_DEBUG << EHPRIV_OC_SHIFT)) 38 36 39 37 static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) 40 38 {
+18 -1
arch/powerpc/kvm/booke.c
··· 994 994 case BOOKE_INTERRUPT_HV_PRIV: 995 995 emulated = kvmppc_get_last_inst(vcpu, false, &last_inst); 996 996 break; 997 + case BOOKE_INTERRUPT_PROGRAM: 998 + /* SW breakpoints arrive as illegal instructions on HV */ 999 + if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) 1000 + emulated = kvmppc_get_last_inst(vcpu, false, &last_inst); 1001 + break; 997 1002 default: 998 1003 break; 999 1004 } ··· 1076 1071 break; 1077 1072 1078 1073 case BOOKE_INTERRUPT_PROGRAM: 1074 + if ((vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) && 1075 + (last_inst == KVMPPC_INST_SW_BREAKPOINT)) { 1076 + /* 1077 + * We are here because of an SW breakpoint instr, 1078 + * so lets return to host to handle. 1079 + */ 1080 + r = kvmppc_handle_debug(run, vcpu); 1081 + run->exit_reason = KVM_EXIT_DEBUG; 1082 + kvmppc_account_exit(vcpu, DEBUG_EXITS); 1083 + break; 1084 + } 1085 + 1079 1086 if (vcpu->arch.shared->msr & (MSR_PR | MSR_GS)) { 1080 1087 /* 1081 1088 * Program traps generated by user-level software must ··· 1664 1647 *val = get_reg_val(id, vcpu->arch.tsr); 1665 1648 break; 1666 1649 case KVM_REG_PPC_DEBUG_INST: 1667 - *val = get_reg_val(id, KVMPPC_INST_EHPRIV_DEBUG); 1650 + *val = get_reg_val(id, KVMPPC_INST_SW_BREAKPOINT); 1668 1651 break; 1669 1652 case KVM_REG_PPC_VRSAVE: 1670 1653 *val = get_reg_val(id, vcpu->arch.vrsave);
+2 -2
arch/powerpc/kvm/bookehv_interrupts.S
··· 238 238 kvm_handler BOOKE_INTERRUPT_ALIGNMENT, EX_PARAMS(GEN), \ 239 239 SPRN_SRR0, SPRN_SRR1,(NEED_DEAR | NEED_ESR) 240 240 kvm_handler BOOKE_INTERRUPT_PROGRAM, EX_PARAMS(GEN), \ 241 - SPRN_SRR0, SPRN_SRR1,NEED_ESR 241 + SPRN_SRR0, SPRN_SRR1, (NEED_ESR | NEED_EMU) 242 242 kvm_handler BOOKE_INTERRUPT_FP_UNAVAIL, EX_PARAMS(GEN), \ 243 243 SPRN_SRR0, SPRN_SRR1, 0 244 244 kvm_handler BOOKE_INTERRUPT_AP_UNAVAIL, EX_PARAMS(GEN), \ ··· 348 348 kvm_handler BOOKE_INTERRUPT_EXTERNAL, SPRN_SRR0, SPRN_SRR1, 0 349 349 kvm_handler BOOKE_INTERRUPT_ALIGNMENT, \ 350 350 SPRN_SRR0, SPRN_SRR1, (NEED_DEAR | NEED_ESR) 351 - kvm_handler BOOKE_INTERRUPT_PROGRAM, SPRN_SRR0, SPRN_SRR1, NEED_ESR 351 + kvm_handler BOOKE_INTERRUPT_PROGRAM, SPRN_SRR0, SPRN_SRR1, (NEED_ESR | NEED_EMU) 352 352 kvm_handler BOOKE_INTERRUPT_FP_UNAVAIL, SPRN_SRR0, SPRN_SRR1, 0 353 353 kvm_handler BOOKE_INTERRUPT_SYSCALL, SPRN_SRR0, SPRN_SRR1, 0 354 354 kvm_handler BOOKE_INTERRUPT_AP_UNAVAIL, SPRN_SRR0, SPRN_SRR1, 0