Skip to content

Commit a011eeb

Browse files
Janosch Frankborntraeger
authored andcommitted
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: Janosch Frank <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
1 parent 022bd2d commit a011eeb

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

arch/s390/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ struct kvm_vcpu_stat {
255255
u32 instruction_stctg;
256256
u32 exit_program_interruption;
257257
u32 exit_instr_and_program;
258+
u32 exit_operation_exception;
258259
u32 deliver_external_call;
259260
u32 deliver_emergency_signal;
260261
u32 deliver_service_signal;

arch/s390/kvm/intercept.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,15 @@ static int handle_partial_execution(struct kvm_vcpu *vcpu)
349349
return -EOPNOTSUPP;
350350
}
351351

352+
static int handle_operexc(struct kvm_vcpu *vcpu)
353+
{
354+
vcpu->stat.exit_operation_exception++;
355+
trace_kvm_s390_handle_operexc(vcpu, vcpu->arch.sie_block->ipa,
356+
vcpu->arch.sie_block->ipb);
357+
358+
return kvm_s390_inject_program_int(vcpu, PGM_OPERATION);
359+
}
360+
352361
int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
353362
{
354363
if (kvm_is_ucontrol(vcpu->kvm))
@@ -370,6 +379,8 @@ int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
370379
return handle_validity(vcpu);
371380
case 0x28:
372381
return handle_stop(vcpu);
382+
case 0x2c:
383+
return handle_operexc(vcpu);
373384
case 0x38:
374385
return handle_partial_execution(vcpu);
375386
default:

arch/s390/kvm/kvm-s390.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
6363
{ "exit_instruction", VCPU_STAT(exit_instruction) },
6464
{ "exit_program_interruption", VCPU_STAT(exit_program_interruption) },
6565
{ "exit_instr_and_program_int", VCPU_STAT(exit_instr_and_program) },
66+
{ "exit_operation_exception", VCPU_STAT(exit_operation_exception) },
6667
{ "halt_successful_poll", VCPU_STAT(halt_successful_poll) },
6768
{ "halt_attempted_poll", VCPU_STAT(halt_attempted_poll) },
6869
{ "halt_poll_invalid", VCPU_STAT(halt_poll_invalid) },

arch/s390/kvm/trace.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,27 @@ TRACE_EVENT(kvm_s390_handle_stsi,
412412
__entry->addr)
413413
);
414414

415+
TRACE_EVENT(kvm_s390_handle_operexc,
416+
TP_PROTO(VCPU_PROTO_COMMON, __u16 ipa, __u32 ipb),
417+
TP_ARGS(VCPU_ARGS_COMMON, ipa, ipb),
418+
419+
TP_STRUCT__entry(
420+
VCPU_FIELD_COMMON
421+
__field(__u64, instruction)
422+
),
423+
424+
TP_fast_assign(
425+
VCPU_ASSIGN_COMMON
426+
__entry->instruction = ((__u64)ipa << 48) |
427+
((__u64)ipb << 16);
428+
),
429+
430+
VCPU_TP_PRINTK("operation exception on instruction %016llx (%s)",
431+
__entry->instruction,
432+
__print_symbolic(icpt_insn_decoder(__entry->instruction),
433+
icpt_insn_codes))
434+
);
435+
415436
#endif /* _TRACE_KVM_H */
416437

417438
/* This part must be outside protection */

0 commit comments

Comments
 (0)