Skip to content

Commit e029ae5

Browse files
huthChristian Borntraeger
authored andcommitted
KVM: s390: Add clock comparator and CPU timer IRQ injection
Add an interface to inject clock comparator and CPU timer interrupts into the guest. This is needed for handling the external interrupt interception. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
1 parent fcc9aec commit e029ae5

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎Documentation/virtual/kvm/api.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,8 @@ KVM_S390_SIGP_STOP (vcpu) - sigp restart
22112211
KVM_S390_PROGRAM_INT (vcpu) - program check; code in parm
22122212
KVM_S390_SIGP_SET_PREFIX (vcpu) - sigp set prefix; prefix address in parm
22132213
KVM_S390_RESTART (vcpu) - restart
2214+
KVM_S390_INT_CLOCK_COMP (vcpu) - clock comparator interrupt
2215+
KVM_S390_INT_CPU_TIMER (vcpu) - CPU timer interrupt
22142216
KVM_S390_INT_VIRTIO (vm) - virtio external interrupt; external interrupt
22152217
parameters in parm and parm64
22162218
KVM_S390_INT_SERVICE (vm) - sclp external interrupt; sclp parameter in parm

‎arch/s390/kvm/interrupt.c‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#define IOINT_CSSID_MASK 0x03fc0000
2828
#define IOINT_AI_MASK 0x04000000
2929

30+
static void deliver_ckc_interrupt(struct kvm_vcpu *vcpu);
31+
3032
static int is_ioint(u64 type)
3133
{
3234
return ((type & 0xfffe0000u) != 0xfffe0000u);
@@ -89,6 +91,14 @@ static int __interrupt_is_deliverable(struct kvm_vcpu *vcpu,
8991
if (vcpu->arch.sie_block->gcr[0] & 0x4000ul)
9092
return 1;
9193
return 0;
94+
case KVM_S390_INT_CLOCK_COMP:
95+
return ckc_interrupts_enabled(vcpu);
96+
case KVM_S390_INT_CPU_TIMER:
97+
if (psw_extint_disabled(vcpu))
98+
return 0;
99+
if (vcpu->arch.sie_block->gcr[0] & 0x400ul)
100+
return 1;
101+
return 0;
92102
case KVM_S390_INT_SERVICE:
93103
case KVM_S390_INT_PFAULT_INIT:
94104
case KVM_S390_INT_PFAULT_DONE:
@@ -166,6 +176,8 @@ static void __set_intercept_indicator(struct kvm_vcpu *vcpu,
166176
case KVM_S390_INT_PFAULT_INIT:
167177
case KVM_S390_INT_PFAULT_DONE:
168178
case KVM_S390_INT_VIRTIO:
179+
case KVM_S390_INT_CLOCK_COMP:
180+
case KVM_S390_INT_CPU_TIMER:
169181
if (psw_extint_disabled(vcpu))
170182
__set_cpuflag(vcpu, CPUSTAT_EXT_INT);
171183
else
@@ -326,6 +338,24 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
326338
&vcpu->arch.sie_block->gpsw,
327339
sizeof(psw_t));
328340
break;
341+
case KVM_S390_INT_CLOCK_COMP:
342+
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type,
343+
inti->ext.ext_params, 0);
344+
deliver_ckc_interrupt(vcpu);
345+
break;
346+
case KVM_S390_INT_CPU_TIMER:
347+
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type,
348+
inti->ext.ext_params, 0);
349+
rc = put_guest_lc(vcpu, EXT_IRQ_CPU_TIMER,
350+
(u16 *)__LC_EXT_INT_CODE);
351+
rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW,
352+
&vcpu->arch.sie_block->gpsw,
353+
sizeof(psw_t));
354+
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW,
355+
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
356+
rc |= put_guest_lc(vcpu, inti->ext.ext_params,
357+
(u32 *)__LC_EXT_PARAMS);
358+
break;
329359
case KVM_S390_INT_SERVICE:
330360
VCPU_EVENT(vcpu, 4, "interrupt: sclp parm:%x",
331361
inti->ext.ext_params);
@@ -984,6 +1014,8 @@ int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
9841014
break;
9851015
case KVM_S390_SIGP_STOP:
9861016
case KVM_S390_RESTART:
1017+
case KVM_S390_INT_CLOCK_COMP:
1018+
case KVM_S390_INT_CPU_TIMER:
9871019
VCPU_EVENT(vcpu, 3, "inject: type %x", s390int->type);
9881020
inti->type = s390int->type;
9891021
break;

‎include/uapi/linux/kvm.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ struct kvm_s390_psw {
416416
#define KVM_S390_INT_PFAULT_INIT 0xfffe0004u
417417
#define KVM_S390_INT_PFAULT_DONE 0xfffe0005u
418418
#define KVM_S390_MCHK 0xfffe1000u
419+
#define KVM_S390_INT_CLOCK_COMP 0xffff1004u
420+
#define KVM_S390_INT_CPU_TIMER 0xffff1005u
419421
#define KVM_S390_INT_VIRTIO 0xffff2603u
420422
#define KVM_S390_INT_SERVICE 0xffff2401u
421423
#define KVM_S390_INT_EMERGENCY 0xffff1201u

0 commit comments

Comments
 (0)