Commit a011eeb2 authored by Janosch Frank's avatar Janosch Frank Committed by Christian Borntraeger

KVM: s390: Add operation exception interception handler

This commit introduces code that handles operation exception
interceptions. With this handler we can emulate instructions by using
illegal opcodes.
Signed-off-by: default avatarJanosch Frank <frankja@linux.vnet.ibm.com>
Reviewed-by: default avatarDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
parent 022bd2d1
...@@ -255,6 +255,7 @@ struct kvm_vcpu_stat { ...@@ -255,6 +255,7 @@ struct kvm_vcpu_stat {
u32 instruction_stctg; u32 instruction_stctg;
u32 exit_program_interruption; u32 exit_program_interruption;
u32 exit_instr_and_program; u32 exit_instr_and_program;
u32 exit_operation_exception;
u32 deliver_external_call; u32 deliver_external_call;
u32 deliver_emergency_signal; u32 deliver_emergency_signal;
u32 deliver_service_signal; u32 deliver_service_signal;
......
...@@ -349,6 +349,15 @@ static int handle_partial_execution(struct kvm_vcpu *vcpu) ...@@ -349,6 +349,15 @@ static int handle_partial_execution(struct kvm_vcpu *vcpu)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int handle_operexc(struct kvm_vcpu *vcpu)
{
vcpu->stat.exit_operation_exception++;
trace_kvm_s390_handle_operexc(vcpu, vcpu->arch.sie_block->ipa,
vcpu->arch.sie_block->ipb);
return kvm_s390_inject_program_int(vcpu, PGM_OPERATION);
}
int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu) int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
{ {
if (kvm_is_ucontrol(vcpu->kvm)) if (kvm_is_ucontrol(vcpu->kvm))
...@@ -370,6 +379,8 @@ int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu) ...@@ -370,6 +379,8 @@ int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
return handle_validity(vcpu); return handle_validity(vcpu);
case 0x28: case 0x28:
return handle_stop(vcpu); return handle_stop(vcpu);
case 0x2c:
return handle_operexc(vcpu);
case 0x38: case 0x38:
return handle_partial_execution(vcpu); return handle_partial_execution(vcpu);
default: default:
......
...@@ -63,6 +63,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { ...@@ -63,6 +63,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
{ "exit_instruction", VCPU_STAT(exit_instruction) }, { "exit_instruction", VCPU_STAT(exit_instruction) },
{ "exit_program_interruption", VCPU_STAT(exit_program_interruption) }, { "exit_program_interruption", VCPU_STAT(exit_program_interruption) },
{ "exit_instr_and_program_int", VCPU_STAT(exit_instr_and_program) }, { "exit_instr_and_program_int", VCPU_STAT(exit_instr_and_program) },
{ "exit_operation_exception", VCPU_STAT(exit_operation_exception) },
{ "halt_successful_poll", VCPU_STAT(halt_successful_poll) }, { "halt_successful_poll", VCPU_STAT(halt_successful_poll) },
{ "halt_attempted_poll", VCPU_STAT(halt_attempted_poll) }, { "halt_attempted_poll", VCPU_STAT(halt_attempted_poll) },
{ "halt_poll_invalid", VCPU_STAT(halt_poll_invalid) }, { "halt_poll_invalid", VCPU_STAT(halt_poll_invalid) },
......
...@@ -412,6 +412,27 @@ TRACE_EVENT(kvm_s390_handle_stsi, ...@@ -412,6 +412,27 @@ TRACE_EVENT(kvm_s390_handle_stsi,
__entry->addr) __entry->addr)
); );
TRACE_EVENT(kvm_s390_handle_operexc,
TP_PROTO(VCPU_PROTO_COMMON, __u16 ipa, __u32 ipb),
TP_ARGS(VCPU_ARGS_COMMON, ipa, ipb),
TP_STRUCT__entry(
VCPU_FIELD_COMMON
__field(__u64, instruction)
),
TP_fast_assign(
VCPU_ASSIGN_COMMON
__entry->instruction = ((__u64)ipa << 48) |
((__u64)ipb << 16);
),
VCPU_TP_PRINTK("operation exception on instruction %016llx (%s)",
__entry->instruction,
__print_symbolic(icpt_insn_decoder(__entry->instruction),
icpt_insn_codes))
);
#endif /* _TRACE_KVM_H */ #endif /* _TRACE_KVM_H */
/* This part must be outside protection */ /* This part must be outside protection */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment