Lines Matching +full:li +full:-
1 // SPDX-License-Identifier: GPL-2.0
10 #define KMSG_COMPONENT "kvm-s390"
22 #include <asm/access-regs.h>
23 #include <asm/asm-offsets.h>
32 #include "kvm-s390.h"
34 #include "trace-s390.h"
52 read_lock(&vcpu->kvm->arch.sca_lock); in sca_ext_call_pending()
53 if (vcpu->kvm->arch.use_esca) { in sca_ext_call_pending()
54 struct esca_block *sca = vcpu->kvm->arch.sca; in sca_ext_call_pending()
56 sca->cpu[vcpu->vcpu_id].sigp_ctrl; in sca_ext_call_pending()
61 struct bsca_block *sca = vcpu->kvm->arch.sca; in sca_ext_call_pending()
63 sca->cpu[vcpu->vcpu_id].sigp_ctrl; in sca_ext_call_pending()
68 read_unlock(&vcpu->kvm->arch.sca_lock); in sca_ext_call_pending()
81 read_lock(&vcpu->kvm->arch.sca_lock); in sca_inject_ext_call()
82 if (vcpu->kvm->arch.use_esca) { in sca_inject_ext_call()
83 struct esca_block *sca = vcpu->kvm->arch.sca; in sca_inject_ext_call()
85 &(sca->cpu[vcpu->vcpu_id].sigp_ctrl); in sca_inject_ext_call()
94 rc = cmpxchg(&sigp_ctrl->value, old_val.value, new_val.value); in sca_inject_ext_call()
96 struct bsca_block *sca = vcpu->kvm->arch.sca; in sca_inject_ext_call()
98 &(sca->cpu[vcpu->vcpu_id].sigp_ctrl); in sca_inject_ext_call()
107 rc = cmpxchg(&sigp_ctrl->value, old_val.value, new_val.value); in sca_inject_ext_call()
109 read_unlock(&vcpu->kvm->arch.sca_lock); in sca_inject_ext_call()
113 return -EBUSY; in sca_inject_ext_call()
126 read_lock(&vcpu->kvm->arch.sca_lock); in sca_clear_ext_call()
127 if (vcpu->kvm->arch.use_esca) { in sca_clear_ext_call()
128 struct esca_block *sca = vcpu->kvm->arch.sca; in sca_clear_ext_call()
130 &(sca->cpu[vcpu->vcpu_id].sigp_ctrl); in sca_clear_ext_call()
135 rc = cmpxchg(&sigp_ctrl->value, old.value, 0); in sca_clear_ext_call()
137 struct bsca_block *sca = vcpu->kvm->arch.sca; in sca_clear_ext_call()
139 &(sca->cpu[vcpu->vcpu_id].sigp_ctrl); in sca_clear_ext_call()
144 rc = cmpxchg(&sigp_ctrl->value, old.value, 0); in sca_clear_ext_call()
146 read_unlock(&vcpu->kvm->arch.sca_lock); in sca_clear_ext_call()
152 return !(vcpu->arch.sie_block->gpsw.mask & PSW_MASK_EXT); in psw_extint_disabled()
157 return !(vcpu->arch.sie_block->gpsw.mask & PSW_MASK_IO); in psw_ioint_disabled()
162 return !(vcpu->arch.sie_block->gpsw.mask & PSW_MASK_MCHECK); in psw_mchk_disabled()
175 !(vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SUBMASK)) in ckc_interrupts_enabled()
185 const u64 now = kvm_s390_get_tod_clock_fast(vcpu->kvm); in ckc_irq_pending()
186 const u64 ckc = vcpu->arch.sie_block->ckc; in ckc_irq_pending()
188 if (vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SIGN) { in ckc_irq_pending()
200 (vcpu->arch.sie_block->gcr[0] & CR0_CPU_TIMER_SUBMASK); in cpu_timer_interrupts_enabled()
234 * gisa_set_iam - change the GISA interruption alert mask
244 * -EBUSY in case the gisa is part of the alert list
251 word = READ_ONCE(gisa->u64.word[0]); in gisa_set_iam()
253 return -EBUSY; in gisa_set_iam()
255 } while (cmpxchg(&gisa->u64.word[0], word, _word) != word); in gisa_set_iam()
261 * gisa_clear_ipm - clear the GISA interruption pending mask
274 word = READ_ONCE(gisa->u64.word[0]); in gisa_clear_ipm()
276 } while (cmpxchg(&gisa->u64.word[0], word, _word) != word); in gisa_clear_ipm()
280 * gisa_get_ipm_or_restore_iam - return IPM or restore GISA IAM
295 word = READ_ONCE(gi->origin->u64.word[0]); in gisa_get_ipm_or_restore_iam()
296 alert_mask = READ_ONCE(gi->alert.mask); in gisa_get_ipm_or_restore_iam()
301 } while (cmpxchg(&gi->origin->u64.word[0], word, _word) != word); in gisa_get_ipm_or_restore_iam()
313 return READ_ONCE(gisa->ipm); in gisa_get_ipm()
323 unsigned long pending = vcpu->kvm->arch.float_int.pending_irqs | in pending_irqs_no_gisa()
324 vcpu->arch.local_int.pending_irqs; in pending_irqs_no_gisa()
326 pending &= ~vcpu->kvm->arch.float_int.masked_irqs; in pending_irqs_no_gisa()
332 struct kvm_s390_gisa_interrupt *gi = &vcpu->kvm->arch.gisa_int; in pending_irqs()
336 if (gi->origin) in pending_irqs()
337 pending_mask |= gisa_get_ipm(gi->origin) << IRQ_PEND_IO_ISC_7; in pending_irqs()
343 return IRQ_PEND_IO_ISC_0 - isc; in isc_to_irq_type()
348 return IRQ_PEND_IO_ISC_0 - irq_type; in irq_type_to_isc()
357 if (!(vcpu->arch.sie_block->gcr[6] & isc_to_isc_bits(i))) in disable_iscs()
377 if (!(vcpu->arch.sie_block->gcr[0] & CR0_EXTERNAL_CALL_SUBMASK)) in deliverable_irqs()
379 if (!(vcpu->arch.sie_block->gcr[0] & CR0_EMERGENCY_SIGNAL_SUBMASK)) in deliverable_irqs()
381 if (!(vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SUBMASK)) in deliverable_irqs()
383 if (!(vcpu->arch.sie_block->gcr[0] & CR0_CPU_TIMER_SUBMASK)) in deliverable_irqs()
385 if (!(vcpu->arch.sie_block->gcr[0] & CR0_SERVICE_SIGNAL_SUBMASK)) { in deliverable_irqs()
393 vcpu->arch.sie_block->iictl != IICTL_CODE_NONE) in deliverable_irqs()
401 if (!(vcpu->arch.sie_block->gcr[14] & in deliverable_irqs()
402 (vcpu->kvm->arch.float_int.mchk.cr14 | in deliverable_irqs()
403 vcpu->arch.local_int.irq.mchk.cr14))) in deliverable_irqs()
418 set_bit(vcpu->vcpu_idx, vcpu->kvm->arch.idle_mask); in __set_cpu_idle()
424 clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.idle_mask); in __unset_cpu_idle()
431 vcpu->arch.sie_block->lctl = 0x0000; in __reset_intercept_indicators()
432 vcpu->arch.sie_block->ictl &= ~(ICTL_LPSW | ICTL_STCTL | ICTL_PINT); in __reset_intercept_indicators()
435 vcpu->arch.sie_block->lctl |= (LCTL_CR0 | LCTL_CR9 | in __reset_intercept_indicators()
437 vcpu->arch.sie_block->ictl |= (ICTL_STCTL | ICTL_PINT); in __reset_intercept_indicators()
448 vcpu->arch.sie_block->lctl |= LCTL_CR6; in set_intercept_indicators_io()
458 vcpu->arch.sie_block->lctl |= LCTL_CR0; in set_intercept_indicators_ext()
466 vcpu->arch.sie_block->ictl |= ICTL_LPSW; in set_intercept_indicators_mchk()
468 vcpu->arch.sie_block->lctl |= LCTL_CR14; in set_intercept_indicators_mchk()
477 /* Set interception request for non-deliverable interrupts */
488 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __deliver_cpu_timer() local
491 vcpu->stat.deliver_cputm++; in __deliver_cpu_timer()
492 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_CPU_TIMER, in __deliver_cpu_timer()
495 vcpu->arch.sie_block->iictl = IICTL_CODE_EXT; in __deliver_cpu_timer()
496 vcpu->arch.sie_block->eic = EXT_IRQ_CPU_TIMER; in __deliver_cpu_timer()
502 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_cpu_timer()
504 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_cpu_timer()
506 clear_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs); in __deliver_cpu_timer()
507 return rc ? -EFAULT : 0; in __deliver_cpu_timer()
512 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __deliver_ckc() local
515 vcpu->stat.deliver_ckc++; in __deliver_ckc()
516 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_CLOCK_COMP, in __deliver_ckc()
519 vcpu->arch.sie_block->iictl = IICTL_CODE_EXT; in __deliver_ckc()
520 vcpu->arch.sie_block->eic = EXT_IRQ_CLK_COMP; in __deliver_ckc()
526 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_ckc()
528 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_ckc()
530 clear_bit(IRQ_PEND_EXT_CLOCK_COMP, &li->pending_irqs); in __deliver_ckc()
531 return rc ? -EFAULT : 0; in __deliver_ckc()
536 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __deliver_pfault_init() local
540 spin_lock(&li->lock); in __deliver_pfault_init()
541 ext = li->irq.ext; in __deliver_pfault_init()
542 clear_bit(IRQ_PEND_PFAULT_INIT, &li->pending_irqs); in __deliver_pfault_init()
543 li->irq.ext.ext_params2 = 0; in __deliver_pfault_init()
544 spin_unlock(&li->lock); in __deliver_pfault_init()
548 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, in __deliver_pfault_init()
555 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_pfault_init()
557 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_pfault_init()
559 return rc ? -EFAULT : 0; in __deliver_pfault_init()
578 vcpu->arch.sie_block->iictl = IICTL_CODE_MCHK; in __write_machine_check()
579 vcpu->arch.sie_block->mcic = mchk->mcic; in __write_machine_check()
580 vcpu->arch.sie_block->faddr = mchk->failing_storage_address; in __write_machine_check()
581 vcpu->arch.sie_block->edc = mchk->ext_damage_code; in __write_machine_check()
585 mci.val = mchk->mcic; in __write_machine_check()
587 kvm_s390_fpu_store(vcpu->run); in __write_machine_check()
588 save_access_regs(vcpu->run->s.regs.acrs); in __write_machine_check()
589 if (MACHINE_HAS_GS && vcpu->arch.gs_enabled) in __write_machine_check()
590 save_gs_cb(current->thread.gs_cb); in __write_machine_check()
595 /* Only bits 0 through 63-LC are used for address formation */ in __write_machine_check()
597 if (test_kvm_facility(vcpu->kvm, 133)) { in __write_machine_check()
617 if (!rc && mci.vr && ext_sa_addr && test_kvm_facility(vcpu->kvm, 129)) { in __write_machine_check()
618 if (write_guest_abs(vcpu, ext_sa_addr, vcpu->run->s.regs.vrs, in __write_machine_check()
624 if (!rc && mci.gs && ext_sa_addr && test_kvm_facility(vcpu->kvm, 133) in __write_machine_check()
627 &vcpu->run->s.regs.gscb, 32)) in __write_machine_check()
636 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __write_machine_check()
638 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __write_machine_check()
641 /* Register-save areas */ in __write_machine_check()
643 convert_vx_to_fp(fprs, (__vector128 *) vcpu->run->s.regs.vrs); in __write_machine_check()
647 vcpu->run->s.regs.fprs, 128); in __write_machine_check()
650 vcpu->run->s.regs.gprs, 128); in __write_machine_check()
651 rc |= put_guest_lc(vcpu, vcpu->run->s.regs.fpc, in __write_machine_check()
653 rc |= put_guest_lc(vcpu, vcpu->arch.sie_block->todpr, in __write_machine_check()
657 rc |= put_guest_lc(vcpu, vcpu->arch.sie_block->ckc >> 8, in __write_machine_check()
660 &vcpu->run->s.regs.acrs, 64); in __write_machine_check()
662 &vcpu->arch.sie_block->gcr, 128); in __write_machine_check()
665 rc |= put_guest_lc(vcpu, mchk->ext_damage_code, in __write_machine_check()
667 rc |= put_guest_lc(vcpu, mchk->failing_storage_address, in __write_machine_check()
669 rc |= write_guest_lc(vcpu, __LC_PSW_SAVE_AREA, &mchk->fixed_logout, in __write_machine_check()
670 sizeof(mchk->fixed_logout)); in __write_machine_check()
671 return rc ? -EFAULT : 0; in __write_machine_check()
676 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; in __deliver_machine_check()
677 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __deliver_machine_check() local
682 spin_lock(&fi->lock); in __deliver_machine_check()
683 spin_lock(&li->lock); in __deliver_machine_check()
684 if (test_bit(IRQ_PEND_MCHK_EX, &li->pending_irqs) || in __deliver_machine_check()
685 test_bit(IRQ_PEND_MCHK_REP, &li->pending_irqs)) { in __deliver_machine_check()
692 mchk = li->irq.mchk; in __deliver_machine_check()
693 clear_bit(IRQ_PEND_MCHK_EX, &li->pending_irqs); in __deliver_machine_check()
694 clear_bit(IRQ_PEND_MCHK_REP, &li->pending_irqs); in __deliver_machine_check()
695 memset(&li->irq.mchk, 0, sizeof(mchk)); in __deliver_machine_check()
704 if (test_and_clear_bit(IRQ_PEND_MCHK_REP, &fi->pending_irqs)) { in __deliver_machine_check()
705 mchk.mcic |= fi->mchk.mcic; in __deliver_machine_check()
706 mchk.cr14 |= fi->mchk.cr14; in __deliver_machine_check()
707 memset(&fi->mchk, 0, sizeof(mchk)); in __deliver_machine_check()
710 spin_unlock(&li->lock); in __deliver_machine_check()
711 spin_unlock(&fi->lock); in __deliver_machine_check()
716 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, in __deliver_machine_check()
719 vcpu->stat.deliver_machine_check++; in __deliver_machine_check()
727 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __deliver_restart() local
731 vcpu->stat.deliver_restart_signal++; in __deliver_restart()
732 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_RESTART, 0, 0); in __deliver_restart()
735 vcpu->arch.sie_block->iictl = IICTL_CODE_RESTART; in __deliver_restart()
739 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_restart()
741 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_restart()
743 clear_bit(IRQ_PEND_RESTART, &li->pending_irqs); in __deliver_restart()
744 return rc ? -EFAULT : 0; in __deliver_restart()
749 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __deliver_set_prefix() local
752 spin_lock(&li->lock); in __deliver_set_prefix()
753 prefix = li->irq.prefix; in __deliver_set_prefix()
754 li->irq.prefix.address = 0; in __deliver_set_prefix()
755 clear_bit(IRQ_PEND_SET_PREFIX, &li->pending_irqs); in __deliver_set_prefix()
756 spin_unlock(&li->lock); in __deliver_set_prefix()
758 vcpu->stat.deliver_prefix_signal++; in __deliver_set_prefix()
759 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, in __deliver_set_prefix()
769 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __deliver_emergency_signal() local
773 spin_lock(&li->lock); in __deliver_emergency_signal()
774 cpu_addr = find_first_bit(li->sigp_emerg_pending, KVM_MAX_VCPUS); in __deliver_emergency_signal()
775 clear_bit(cpu_addr, li->sigp_emerg_pending); in __deliver_emergency_signal()
776 if (bitmap_empty(li->sigp_emerg_pending, KVM_MAX_VCPUS)) in __deliver_emergency_signal()
777 clear_bit(IRQ_PEND_EXT_EMERGENCY, &li->pending_irqs); in __deliver_emergency_signal()
778 spin_unlock(&li->lock); in __deliver_emergency_signal()
781 vcpu->stat.deliver_emergency_signal++; in __deliver_emergency_signal()
782 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_EMERGENCY, in __deliver_emergency_signal()
785 vcpu->arch.sie_block->iictl = IICTL_CODE_EXT; in __deliver_emergency_signal()
786 vcpu->arch.sie_block->eic = EXT_IRQ_EMERGENCY_SIG; in __deliver_emergency_signal()
787 vcpu->arch.sie_block->extcpuaddr = cpu_addr; in __deliver_emergency_signal()
795 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_emergency_signal()
797 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_emergency_signal()
798 return rc ? -EFAULT : 0; in __deliver_emergency_signal()
803 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __deliver_external_call() local
807 spin_lock(&li->lock); in __deliver_external_call()
808 extcall = li->irq.extcall; in __deliver_external_call()
809 li->irq.extcall.code = 0; in __deliver_external_call()
810 clear_bit(IRQ_PEND_EXT_EXTERNAL, &li->pending_irqs); in __deliver_external_call()
811 spin_unlock(&li->lock); in __deliver_external_call()
814 vcpu->stat.deliver_external_call++; in __deliver_external_call()
815 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, in __deliver_external_call()
819 vcpu->arch.sie_block->iictl = IICTL_CODE_EXT; in __deliver_external_call()
820 vcpu->arch.sie_block->eic = EXT_IRQ_EXTERNAL_CALL; in __deliver_external_call()
821 vcpu->arch.sie_block->extcpuaddr = extcall.code; in __deliver_external_call()
829 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_external_call()
830 rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW, &vcpu->arch.sie_block->gpsw, in __deliver_external_call()
832 return rc ? -EFAULT : 0; in __deliver_external_call()
839 vcpu->arch.sie_block->iictl = IICTL_CODE_SPECIFICATION; in __deliver_prog_pv()
842 vcpu->arch.sie_block->iictl = IICTL_CODE_OPERAND; in __deliver_prog_pv()
845 return -EINVAL; in __deliver_prog_pv()
852 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __deliver_prog() local
857 spin_lock(&li->lock); in __deliver_prog()
858 pgm_info = li->irq.pgm; in __deliver_prog()
859 clear_bit(IRQ_PEND_PROG, &li->pending_irqs); in __deliver_prog()
860 memset(&li->irq.pgm, 0, sizeof(pgm_info)); in __deliver_prog()
861 spin_unlock(&li->lock); in __deliver_prog()
866 vcpu->stat.deliver_program++; in __deliver_prog()
867 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_PROGRAM_INT, in __deliver_prog()
958 rc |= put_guest_lc(vcpu, vcpu->arch.sie_block->gbea, in __deliver_prog()
963 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_prog()
965 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in __deliver_prog()
966 return rc ? -EFAULT : 0; in __deliver_prog()
977 vcpu->arch.sie_block->iictl = IICTL_CODE_EXT; in write_sclp()
978 vcpu->arch.sie_block->eic = EXT_IRQ_SERVICE_SIG; in write_sclp()
979 vcpu->arch.sie_block->eiparams = parm; in write_sclp()
986 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in write_sclp()
988 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); in write_sclp()
992 return rc ? -EFAULT : 0; in write_sclp()
997 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; in __deliver_service()
1000 spin_lock(&fi->lock); in __deliver_service()
1001 if (test_bit(IRQ_PEND_EXT_SERVICE, &fi->masked_irqs) || in __deliver_service()
1002 !(test_bit(IRQ_PEND_EXT_SERVICE, &fi->pending_irqs))) { in __deliver_service()
1003 spin_unlock(&fi->lock); in __deliver_service()
1006 ext = fi->srv_signal; in __deliver_service()
1007 memset(&fi->srv_signal, 0, sizeof(ext)); in __deliver_service()
1008 clear_bit(IRQ_PEND_EXT_SERVICE, &fi->pending_irqs); in __deliver_service()
1009 clear_bit(IRQ_PEND_EXT_SERVICE_EV, &fi->pending_irqs); in __deliver_service()
1011 set_bit(IRQ_PEND_EXT_SERVICE, &fi->masked_irqs); in __deliver_service()
1012 spin_unlock(&fi->lock); in __deliver_service()
1016 vcpu->stat.deliver_service_signal++; in __deliver_service()
1017 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_SERVICE, in __deliver_service()
1025 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; in __deliver_service_ev()
1028 spin_lock(&fi->lock); in __deliver_service_ev()
1029 if (!(test_bit(IRQ_PEND_EXT_SERVICE_EV, &fi->pending_irqs))) { in __deliver_service_ev()
1030 spin_unlock(&fi->lock); in __deliver_service_ev()
1033 ext = fi->srv_signal; in __deliver_service_ev()
1035 fi->srv_signal.ext_params &= ~SCCB_EVENT_PENDING; in __deliver_service_ev()
1036 clear_bit(IRQ_PEND_EXT_SERVICE_EV, &fi->pending_irqs); in __deliver_service_ev()
1037 spin_unlock(&fi->lock); in __deliver_service_ev()
1040 vcpu->stat.deliver_service_signal++; in __deliver_service_ev()
1041 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_SERVICE, in __deliver_service_ev()
1049 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; in __deliver_pfault_done()
1053 spin_lock(&fi->lock); in __deliver_pfault_done()
1054 inti = list_first_entry_or_null(&fi->lists[FIRQ_LIST_PFAULT], in __deliver_pfault_done()
1058 list_del(&inti->list); in __deliver_pfault_done()
1059 fi->counters[FIRQ_CNTR_PFAULT] -= 1; in __deliver_pfault_done()
1061 if (list_empty(&fi->lists[FIRQ_LIST_PFAULT])) in __deliver_pfault_done()
1062 clear_bit(IRQ_PEND_PFAULT_DONE, &fi->pending_irqs); in __deliver_pfault_done()
1063 spin_unlock(&fi->lock); in __deliver_pfault_done()
1066 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, in __deliver_pfault_done()
1068 inti->ext.ext_params2); in __deliver_pfault_done()
1070 inti->ext.ext_params2); in __deliver_pfault_done()
1077 &vcpu->arch.sie_block->gpsw, in __deliver_pfault_done()
1080 &vcpu->arch.sie_block->gpsw, in __deliver_pfault_done()
1082 rc |= put_guest_lc(vcpu, inti->ext.ext_params2, in __deliver_pfault_done()
1086 return rc ? -EFAULT : 0; in __deliver_pfault_done()
1091 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; in __deliver_virtio()
1095 spin_lock(&fi->lock); in __deliver_virtio()
1096 inti = list_first_entry_or_null(&fi->lists[FIRQ_LIST_VIRTIO], in __deliver_virtio()
1102 inti->ext.ext_params, inti->ext.ext_params2); in __deliver_virtio()
1103 vcpu->stat.deliver_virtio++; in __deliver_virtio()
1104 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, in __deliver_virtio()
1105 inti->type, in __deliver_virtio()
1106 inti->ext.ext_params, in __deliver_virtio()
1107 inti->ext.ext_params2); in __deliver_virtio()
1108 list_del(&inti->list); in __deliver_virtio()
1109 fi->counters[FIRQ_CNTR_VIRTIO] -= 1; in __deliver_virtio()
1111 if (list_empty(&fi->lists[FIRQ_LIST_VIRTIO])) in __deliver_virtio()
1112 clear_bit(IRQ_PEND_VIRTIO, &fi->pending_irqs); in __deliver_virtio()
1113 spin_unlock(&fi->lock); in __deliver_virtio()
1121 &vcpu->arch.sie_block->gpsw, in __deliver_virtio()
1124 &vcpu->arch.sie_block->gpsw, in __deliver_virtio()
1126 rc |= put_guest_lc(vcpu, inti->ext.ext_params, in __deliver_virtio()
1128 rc |= put_guest_lc(vcpu, inti->ext.ext_params2, in __deliver_virtio()
1132 return rc ? -EFAULT : 0; in __deliver_virtio()
1140 vcpu->arch.sie_block->iictl = IICTL_CODE_IO; in __do_deliver_io()
1141 vcpu->arch.sie_block->subchannel_id = io->subchannel_id; in __do_deliver_io()
1142 vcpu->arch.sie_block->subchannel_nr = io->subchannel_nr; in __do_deliver_io()
1143 vcpu->arch.sie_block->io_int_parm = io->io_int_parm; in __do_deliver_io()
1144 vcpu->arch.sie_block->io_int_word = io->io_int_word; in __do_deliver_io()
1148 rc = put_guest_lc(vcpu, io->subchannel_id, (u16 *)__LC_SUBCHANNEL_ID); in __do_deliver_io()
1149 rc |= put_guest_lc(vcpu, io->subchannel_nr, (u16 *)__LC_SUBCHANNEL_NR); in __do_deliver_io()
1150 rc |= put_guest_lc(vcpu, io->io_int_parm, (u32 *)__LC_IO_INT_PARM); in __do_deliver_io()
1151 rc |= put_guest_lc(vcpu, io->io_int_word, (u32 *)__LC_IO_INT_WORD); in __do_deliver_io()
1153 &vcpu->arch.sie_block->gpsw, in __do_deliver_io()
1156 &vcpu->arch.sie_block->gpsw, in __do_deliver_io()
1158 return rc ? -EFAULT : 0; in __do_deliver_io()
1166 struct kvm_s390_gisa_interrupt *gi = &vcpu->kvm->arch.gisa_int; in __deliver_io()
1172 fi = &vcpu->kvm->arch.float_int; in __deliver_io()
1174 spin_lock(&fi->lock); in __deliver_io()
1176 isc_list = &fi->lists[isc]; in __deliver_io()
1181 if (inti->type & KVM_S390_INT_IO_AI_MASK) in __deliver_io()
1185 inti->io.subchannel_id >> 8, in __deliver_io()
1186 inti->io.subchannel_id >> 1 & 0x3, in __deliver_io()
1187 inti->io.subchannel_nr); in __deliver_io()
1189 vcpu->stat.deliver_io++; in __deliver_io()
1190 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, in __deliver_io()
1191 inti->type, in __deliver_io()
1192 ((__u32)inti->io.subchannel_id << 16) | in __deliver_io()
1193 inti->io.subchannel_nr, in __deliver_io()
1194 ((__u64)inti->io.io_int_parm << 32) | in __deliver_io()
1195 inti->io.io_int_word); in __deliver_io()
1196 list_del(&inti->list); in __deliver_io()
1197 fi->counters[FIRQ_CNTR_IO] -= 1; in __deliver_io()
1200 clear_bit(irq_type, &fi->pending_irqs); in __deliver_io()
1201 spin_unlock(&fi->lock); in __deliver_io()
1204 rc = __do_deliver_io(vcpu, &(inti->io)); in __deliver_io()
1209 if (gi->origin && gisa_tac_ipm_gisc(gi->origin, isc)) { in __deliver_io()
1217 vcpu->stat.deliver_io++; in __deliver_io()
1218 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, in __deliver_io()
1233 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in kvm_s390_ext_call_pending() local
1236 return test_bit(IRQ_PEND_EXT_EXTERNAL, &li->pending_irqs); in kvm_s390_ext_call_pending()
1252 (vcpu->arch.sie_block->gcr[0] & CR0_EXTERNAL_CALL_SUBMASK)) in kvm_s390_vcpu_has_irq()
1267 const u64 now = kvm_s390_get_tod_clock_fast(vcpu->kvm); in __calculate_sltime()
1268 const u64 ckc = vcpu->arch.sie_block->ckc; in __calculate_sltime()
1272 if (vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SIGN) { in __calculate_sltime()
1274 sltime = tod_to_ns((s64)ckc - (s64)now); in __calculate_sltime()
1276 sltime = tod_to_ns(ckc - now); in __calculate_sltime()
1299 struct kvm_s390_gisa_interrupt *gi = &vcpu->kvm->arch.gisa_int; in kvm_s390_handle_wait()
1302 vcpu->stat.exit_wait_state++; in kvm_s390_handle_wait()
1310 return -EOPNOTSUPP; /* disabled wait */ in kvm_s390_handle_wait()
1313 if (gi->origin && in kvm_s390_handle_wait()
1315 vcpu->arch.sie_block->gcr[6] >> 24)) in kvm_s390_handle_wait()
1330 hrtimer_start(&vcpu->arch.ckc_timer, sltime, HRTIMER_MODE_REL); in kvm_s390_handle_wait()
1335 vcpu->valid_wakeup = false; in kvm_s390_handle_wait()
1339 hrtimer_cancel(&vcpu->arch.ckc_timer); in kvm_s390_handle_wait()
1345 vcpu->valid_wakeup = true; in kvm_s390_vcpu_wakeup()
1375 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in kvm_s390_clear_local_irqs() local
1377 spin_lock(&li->lock); in kvm_s390_clear_local_irqs()
1378 li->pending_irqs = 0; in kvm_s390_clear_local_irqs()
1379 bitmap_zero(li->sigp_emerg_pending, KVM_MAX_VCPUS); in kvm_s390_clear_local_irqs()
1380 memset(&li->irq, 0, sizeof(li->irq)); in kvm_s390_clear_local_irqs()
1381 spin_unlock(&li->lock); in kvm_s390_clear_local_irqs()
1388 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in kvm_s390_deliver_pending_interrupts() local
1397 clear_bit(IRQ_PEND_EXT_CLOCK_COMP, &li->pending_irqs); in kvm_s390_deliver_pending_interrupts()
1399 set_bit(IRQ_PEND_EXT_CLOCK_COMP, &li->pending_irqs); in kvm_s390_deliver_pending_interrupts()
1402 clear_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs); in kvm_s390_deliver_pending_interrupts()
1404 set_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs); in kvm_s390_deliver_pending_interrupts()
1462 clear_bit(irq_type, &li->pending_irqs); in kvm_s390_deliver_pending_interrupts()
1472 struct kvm_debug_exit_arch *debug_exit = &vcpu->run->debug.arch; in kvm_s390_deliver_pending_interrupts()
1474 debug_exit->addr = vcpu->arch.sie_block->gpsw.addr; in kvm_s390_deliver_pending_interrupts()
1475 debug_exit->type = KVM_SINGLESTEP; in kvm_s390_deliver_pending_interrupts()
1476 vcpu->guest_debug |= KVM_GUESTDBG_EXIT_PENDING; in kvm_s390_deliver_pending_interrupts()
1486 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __inject_prog() local
1488 vcpu->stat.inject_program++; in __inject_prog()
1489 VCPU_EVENT(vcpu, 3, "inject: program irq code 0x%x", irq->u.pgm.code); in __inject_prog()
1490 trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_PROGRAM_INT, in __inject_prog()
1491 irq->u.pgm.code, 0); in __inject_prog()
1493 if (!(irq->u.pgm.flags & KVM_S390_PGM_FLAGS_ILC_VALID)) { in __inject_prog()
1495 irq->u.pgm.flags &= ~KVM_S390_PGM_FLAGS_ILC_MASK; in __inject_prog()
1496 irq->u.pgm.flags |= kvm_s390_get_ilen(vcpu); in __inject_prog()
1497 irq->u.pgm.flags |= KVM_S390_PGM_FLAGS_ILC_VALID; in __inject_prog()
1500 if (irq->u.pgm.code == PGM_PER) { in __inject_prog()
1501 li->irq.pgm.code |= PGM_PER; in __inject_prog()
1502 li->irq.pgm.flags = irq->u.pgm.flags; in __inject_prog()
1504 li->irq.pgm.per_address = irq->u.pgm.per_address; in __inject_prog()
1505 li->irq.pgm.per_code = irq->u.pgm.per_code; in __inject_prog()
1506 li->irq.pgm.per_atmid = irq->u.pgm.per_atmid; in __inject_prog()
1507 li->irq.pgm.per_access_id = irq->u.pgm.per_access_id; in __inject_prog()
1508 } else if (!(irq->u.pgm.code & PGM_PER)) { in __inject_prog()
1509 li->irq.pgm.code = (li->irq.pgm.code & PGM_PER) | in __inject_prog()
1510 irq->u.pgm.code; in __inject_prog()
1511 li->irq.pgm.flags = irq->u.pgm.flags; in __inject_prog()
1512 /* only modify non-PER information */ in __inject_prog()
1513 li->irq.pgm.trans_exc_code = irq->u.pgm.trans_exc_code; in __inject_prog()
1514 li->irq.pgm.mon_code = irq->u.pgm.mon_code; in __inject_prog()
1515 li->irq.pgm.data_exc_code = irq->u.pgm.data_exc_code; in __inject_prog()
1516 li->irq.pgm.mon_class_nr = irq->u.pgm.mon_class_nr; in __inject_prog()
1517 li->irq.pgm.exc_access_id = irq->u.pgm.exc_access_id; in __inject_prog()
1518 li->irq.pgm.op_access_id = irq->u.pgm.op_access_id; in __inject_prog()
1520 li->irq.pgm = irq->u.pgm; in __inject_prog()
1522 set_bit(IRQ_PEND_PROG, &li->pending_irqs); in __inject_prog()
1528 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __inject_pfault_init() local
1530 vcpu->stat.inject_pfault_init++; in __inject_pfault_init()
1532 irq->u.ext.ext_params2); in __inject_pfault_init()
1533 trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_PFAULT_INIT, in __inject_pfault_init()
1534 irq->u.ext.ext_params, in __inject_pfault_init()
1535 irq->u.ext.ext_params2); in __inject_pfault_init()
1537 li->irq.ext = irq->u.ext; in __inject_pfault_init()
1538 set_bit(IRQ_PEND_PFAULT_INIT, &li->pending_irqs); in __inject_pfault_init()
1545 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __inject_extcall() local
1546 struct kvm_s390_extcall_info *extcall = &li->irq.extcall; in __inject_extcall()
1547 uint16_t src_id = irq->u.extcall.code; in __inject_extcall()
1549 vcpu->stat.inject_external_call++; in __inject_extcall()
1550 VCPU_EVENT(vcpu, 4, "inject: external call source-cpu:%u", in __inject_extcall()
1552 trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_EXTERNAL_CALL, in __inject_extcall()
1556 if (kvm_get_vcpu_by_id(vcpu->kvm, src_id) == NULL) in __inject_extcall()
1557 return -EINVAL; in __inject_extcall()
1562 if (test_and_set_bit(IRQ_PEND_EXT_EXTERNAL, &li->pending_irqs)) in __inject_extcall()
1563 return -EBUSY; in __inject_extcall()
1564 *extcall = irq->u.extcall; in __inject_extcall()
1571 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __inject_set_prefix() local
1572 struct kvm_s390_prefix_info *prefix = &li->irq.prefix; in __inject_set_prefix()
1574 vcpu->stat.inject_set_prefix++; in __inject_set_prefix()
1576 irq->u.prefix.address); in __inject_set_prefix()
1577 trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_SIGP_SET_PREFIX, in __inject_set_prefix()
1578 irq->u.prefix.address, 0); in __inject_set_prefix()
1581 return -EBUSY; in __inject_set_prefix()
1583 *prefix = irq->u.prefix; in __inject_set_prefix()
1584 set_bit(IRQ_PEND_SET_PREFIX, &li->pending_irqs); in __inject_set_prefix()
1591 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __inject_sigp_stop() local
1592 struct kvm_s390_stop_info *stop = &li->irq.stop; in __inject_sigp_stop()
1595 vcpu->stat.inject_stop_signal++; in __inject_sigp_stop()
1596 trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_SIGP_STOP, 0, 0); in __inject_sigp_stop()
1598 if (irq->u.stop.flags & ~KVM_S390_STOP_SUPP_FLAGS) in __inject_sigp_stop()
1599 return -EINVAL; in __inject_sigp_stop()
1602 if (irq->u.stop.flags & KVM_S390_STOP_FLAG_STORE_STATUS) in __inject_sigp_stop()
1608 if (test_and_set_bit(IRQ_PEND_SIGP_STOP, &li->pending_irqs)) in __inject_sigp_stop()
1609 return -EBUSY; in __inject_sigp_stop()
1610 stop->flags = irq->u.stop.flags; in __inject_sigp_stop()
1617 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __inject_sigp_restart() local
1619 vcpu->stat.inject_restart++; in __inject_sigp_restart()
1621 trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_RESTART, 0, 0); in __inject_sigp_restart()
1623 set_bit(IRQ_PEND_RESTART, &li->pending_irqs); in __inject_sigp_restart()
1630 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __inject_sigp_emergency() local
1632 vcpu->stat.inject_emergency_signal++; in __inject_sigp_emergency()
1634 irq->u.emerg.code); in __inject_sigp_emergency()
1635 trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_EMERGENCY, in __inject_sigp_emergency()
1636 irq->u.emerg.code, 0); in __inject_sigp_emergency()
1639 if (kvm_get_vcpu_by_id(vcpu->kvm, irq->u.emerg.code) == NULL) in __inject_sigp_emergency()
1640 return -EINVAL; in __inject_sigp_emergency()
1642 set_bit(irq->u.emerg.code, li->sigp_emerg_pending); in __inject_sigp_emergency()
1643 set_bit(IRQ_PEND_EXT_EMERGENCY, &li->pending_irqs); in __inject_sigp_emergency()
1650 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __inject_mchk() local
1651 struct kvm_s390_mchk_info *mchk = &li->irq.mchk; in __inject_mchk()
1653 vcpu->stat.inject_mchk++; in __inject_mchk()
1655 irq->u.mchk.mcic); in __inject_mchk()
1656 trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_MCHK, 0, in __inject_mchk()
1657 irq->u.mchk.mcic); in __inject_mchk()
1667 mchk->cr14 |= irq->u.mchk.cr14; in __inject_mchk()
1668 mchk->mcic |= irq->u.mchk.mcic; in __inject_mchk()
1669 mchk->ext_damage_code |= irq->u.mchk.ext_damage_code; in __inject_mchk()
1670 mchk->failing_storage_address = irq->u.mchk.failing_storage_address; in __inject_mchk()
1671 memcpy(&mchk->fixed_logout, &irq->u.mchk.fixed_logout, in __inject_mchk()
1672 sizeof(mchk->fixed_logout)); in __inject_mchk()
1673 if (mchk->mcic & MCHK_EX_MASK) in __inject_mchk()
1674 set_bit(IRQ_PEND_MCHK_EX, &li->pending_irqs); in __inject_mchk()
1675 else if (mchk->mcic & MCHK_REP_MASK) in __inject_mchk()
1676 set_bit(IRQ_PEND_MCHK_REP, &li->pending_irqs); in __inject_mchk()
1682 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __inject_ckc() local
1684 vcpu->stat.inject_ckc++; in __inject_ckc()
1686 trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_CLOCK_COMP, in __inject_ckc()
1689 set_bit(IRQ_PEND_EXT_CLOCK_COMP, &li->pending_irqs); in __inject_ckc()
1696 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in __inject_cpu_timer() local
1698 vcpu->stat.inject_cputm++; in __inject_cpu_timer()
1700 trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_CPU_TIMER, in __inject_cpu_timer()
1703 set_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs); in __inject_cpu_timer()
1711 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; in get_io_int()
1712 struct list_head *isc_list = &fi->lists[FIRQ_LIST_IO_ISC_0 + isc]; in get_io_int()
1717 spin_lock(&fi->lock); in get_io_int()
1719 if (schid && (id != iter->io.subchannel_id || in get_io_int()
1720 nr != iter->io.subchannel_nr)) in get_io_int()
1723 list_del_init(&iter->list); in get_io_int()
1724 fi->counters[FIRQ_CNTR_IO] -= 1; in get_io_int()
1726 clear_bit(isc_to_irq_type(isc), &fi->pending_irqs); in get_io_int()
1727 spin_unlock(&fi->lock); in get_io_int()
1730 spin_unlock(&fi->lock); in get_io_int()
1749 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in get_top_gisa_isc()
1755 if (!gi->origin) in get_top_gisa_isc()
1758 active_mask = (isc_mask & gisa_get_ipm(gi->origin) << 24) << 32; in get_top_gisa_isc()
1760 isc = __fls(active_mask) ^ (BITS_PER_LONG - 1); in get_top_gisa_isc()
1761 if (gisa_tac_ipm_gisc(gi->origin, isc)) in get_top_gisa_isc()
1766 return -EINVAL; in get_top_gisa_isc()
1784 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in kvm_s390_get_io_int()
1800 if (int_word_to_isc(inti->io.io_int_word) <= isc) { in kvm_s390_get_io_int()
1802 gisa_set_ipm_gisc(gi->origin, isc); in kvm_s390_get_io_int()
1808 tmp_inti->type = KVM_S390_INT_IO(1, 0, 0, 0); in kvm_s390_get_io_int()
1809 tmp_inti->io.io_int_word = isc_to_int_word(isc); in kvm_s390_get_io_int()
1814 gisa_set_ipm_gisc(gi->origin, isc); in kvm_s390_get_io_int()
1822 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; in __inject_service()
1824 kvm->stat.inject_service_signal++; in __inject_service()
1825 spin_lock(&fi->lock); in __inject_service()
1826 fi->srv_signal.ext_params |= inti->ext.ext_params & SCCB_EVENT_PENDING; in __inject_service()
1829 if (fi->srv_signal.ext_params & SCCB_EVENT_PENDING) in __inject_service()
1830 set_bit(IRQ_PEND_EXT_SERVICE_EV, &fi->pending_irqs); in __inject_service()
1840 if (fi->srv_signal.ext_params & SCCB_MASK) in __inject_service()
1842 fi->srv_signal.ext_params |= inti->ext.ext_params & SCCB_MASK; in __inject_service()
1843 set_bit(IRQ_PEND_EXT_SERVICE, &fi->pending_irqs); in __inject_service()
1845 spin_unlock(&fi->lock); in __inject_service()
1853 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; in __inject_virtio()
1855 kvm->stat.inject_virtio++; in __inject_virtio()
1856 spin_lock(&fi->lock); in __inject_virtio()
1857 if (fi->counters[FIRQ_CNTR_VIRTIO] >= KVM_S390_MAX_VIRTIO_IRQS) { in __inject_virtio()
1858 spin_unlock(&fi->lock); in __inject_virtio()
1859 return -EBUSY; in __inject_virtio()
1861 fi->counters[FIRQ_CNTR_VIRTIO] += 1; in __inject_virtio()
1862 list_add_tail(&inti->list, &fi->lists[FIRQ_LIST_VIRTIO]); in __inject_virtio()
1863 set_bit(IRQ_PEND_VIRTIO, &fi->pending_irqs); in __inject_virtio()
1864 spin_unlock(&fi->lock); in __inject_virtio()
1871 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; in __inject_pfault_done()
1873 kvm->stat.inject_pfault_done++; in __inject_pfault_done()
1874 spin_lock(&fi->lock); in __inject_pfault_done()
1875 if (fi->counters[FIRQ_CNTR_PFAULT] >= in __inject_pfault_done()
1877 spin_unlock(&fi->lock); in __inject_pfault_done()
1878 return -EBUSY; in __inject_pfault_done()
1880 fi->counters[FIRQ_CNTR_PFAULT] += 1; in __inject_pfault_done()
1881 list_add_tail(&inti->list, &fi->lists[FIRQ_LIST_PFAULT]); in __inject_pfault_done()
1882 set_bit(IRQ_PEND_PFAULT_DONE, &fi->pending_irqs); in __inject_pfault_done()
1883 spin_unlock(&fi->lock); in __inject_pfault_done()
1891 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; in __inject_float_mchk()
1893 kvm->stat.inject_float_mchk++; in __inject_float_mchk()
1894 spin_lock(&fi->lock); in __inject_float_mchk()
1895 fi->mchk.cr14 |= inti->mchk.cr14 & (1UL << CR_PENDING_SUBCLASS); in __inject_float_mchk()
1896 fi->mchk.mcic |= inti->mchk.mcic; in __inject_float_mchk()
1897 set_bit(IRQ_PEND_MCHK_REP, &fi->pending_irqs); in __inject_float_mchk()
1898 spin_unlock(&fi->lock); in __inject_float_mchk()
1905 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in __inject_io()
1910 kvm->stat.inject_io++; in __inject_io()
1911 isc = int_word_to_isc(inti->io.io_int_word); in __inject_io()
1919 if (gi->origin && inti->type & KVM_S390_INT_IO_AI_MASK) { in __inject_io()
1921 gisa_set_ipm_gisc(gi->origin, isc); in __inject_io()
1926 fi = &kvm->arch.float_int; in __inject_io()
1927 spin_lock(&fi->lock); in __inject_io()
1928 if (fi->counters[FIRQ_CNTR_IO] >= KVM_S390_MAX_FLOAT_IRQS) { in __inject_io()
1929 spin_unlock(&fi->lock); in __inject_io()
1930 return -EBUSY; in __inject_io()
1932 fi->counters[FIRQ_CNTR_IO] += 1; in __inject_io()
1934 if (inti->type & KVM_S390_INT_IO_AI_MASK) in __inject_io()
1938 inti->io.subchannel_id >> 8, in __inject_io()
1939 inti->io.subchannel_id >> 1 & 0x3, in __inject_io()
1940 inti->io.subchannel_nr); in __inject_io()
1941 list = &fi->lists[FIRQ_LIST_IO_ISC_0 + isc]; in __inject_io()
1942 list_add_tail(&inti->list, list); in __inject_io()
1943 set_bit(isc_to_irq_type(isc), &fi->pending_irqs); in __inject_io()
1944 spin_unlock(&fi->lock); in __inject_io()
1956 online_vcpus = atomic_read(&kvm->online_vcpus); in __floating_irq_kick()
1961 sigcpu = find_first_bit(kvm->arch.idle_mask, online_vcpus); in __floating_irq_kick()
1964 sigcpu = kvm->arch.float_int.next_rr_cpu++; in __floating_irq_kick()
1965 kvm->arch.float_int.next_rr_cpu %= online_vcpus; in __floating_irq_kick()
1980 kvm->arch.gisa_int.origin) || in __floating_irq_kick()
1993 u64 type = READ_ONCE(inti->type); in __inject_vm()
2013 rc = -EINVAL; in __inject_vm()
2030 return -ENOMEM; in kvm_s390_inject_vm()
2032 inti->type = s390int->type; in kvm_s390_inject_vm()
2033 switch (inti->type) { in kvm_s390_inject_vm()
2036 s390int->parm, s390int->parm64); in kvm_s390_inject_vm()
2037 inti->ext.ext_params = s390int->parm; in kvm_s390_inject_vm()
2038 inti->ext.ext_params2 = s390int->parm64; in kvm_s390_inject_vm()
2041 VM_EVENT(kvm, 4, "inject: sclp parm:%x", s390int->parm); in kvm_s390_inject_vm()
2042 inti->ext.ext_params = s390int->parm; in kvm_s390_inject_vm()
2045 inti->ext.ext_params2 = s390int->parm64; in kvm_s390_inject_vm()
2049 s390int->parm64); in kvm_s390_inject_vm()
2050 inti->mchk.cr14 = s390int->parm; /* upper bits are not used */ in kvm_s390_inject_vm()
2051 inti->mchk.mcic = s390int->parm64; in kvm_s390_inject_vm()
2054 inti->io.subchannel_id = s390int->parm >> 16; in kvm_s390_inject_vm()
2055 inti->io.subchannel_nr = s390int->parm & 0x0000ffffu; in kvm_s390_inject_vm()
2056 inti->io.io_int_parm = s390int->parm64 >> 32; in kvm_s390_inject_vm()
2057 inti->io.io_int_word = s390int->parm64 & 0x00000000ffffffffull; in kvm_s390_inject_vm()
2061 return -EINVAL; in kvm_s390_inject_vm()
2063 trace_kvm_s390_inject_vm(s390int->type, s390int->parm, s390int->parm64, in kvm_s390_inject_vm()
2081 irq->type = s390int->type; in s390int_to_s390irq()
2082 switch (irq->type) { in s390int_to_s390irq()
2084 if (s390int->parm & 0xffff0000) in s390int_to_s390irq()
2085 return -EINVAL; in s390int_to_s390irq()
2086 irq->u.pgm.code = s390int->parm; in s390int_to_s390irq()
2089 irq->u.prefix.address = s390int->parm; in s390int_to_s390irq()
2092 irq->u.stop.flags = s390int->parm; in s390int_to_s390irq()
2095 if (s390int->parm & 0xffff0000) in s390int_to_s390irq()
2096 return -EINVAL; in s390int_to_s390irq()
2097 irq->u.extcall.code = s390int->parm; in s390int_to_s390irq()
2100 if (s390int->parm & 0xffff0000) in s390int_to_s390irq()
2101 return -EINVAL; in s390int_to_s390irq()
2102 irq->u.emerg.code = s390int->parm; in s390int_to_s390irq()
2105 irq->u.mchk.mcic = s390int->parm64; in s390int_to_s390irq()
2108 irq->u.ext.ext_params = s390int->parm; in s390int_to_s390irq()
2109 irq->u.ext.ext_params2 = s390int->parm64; in s390int_to_s390irq()
2116 return -EINVAL; in s390int_to_s390irq()
2123 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in kvm_s390_is_stop_irq_pending() local
2125 return test_bit(IRQ_PEND_SIGP_STOP, &li->pending_irqs); in kvm_s390_is_stop_irq_pending()
2130 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in kvm_s390_is_restart_irq_pending() local
2132 return test_bit(IRQ_PEND_RESTART, &li->pending_irqs); in kvm_s390_is_restart_irq_pending()
2137 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in kvm_s390_clear_stop_irq() local
2139 spin_lock(&li->lock); in kvm_s390_clear_stop_irq()
2140 li->irq.stop.flags = 0; in kvm_s390_clear_stop_irq()
2141 clear_bit(IRQ_PEND_SIGP_STOP, &li->pending_irqs); in kvm_s390_clear_stop_irq()
2142 spin_unlock(&li->lock); in kvm_s390_clear_stop_irq()
2149 switch (irq->type) { in do_inject_vcpu()
2184 rc = -EINVAL; in do_inject_vcpu()
2192 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in kvm_s390_inject_vcpu() local
2195 spin_lock(&li->lock); in kvm_s390_inject_vcpu()
2197 spin_unlock(&li->lock); in kvm_s390_inject_vcpu()
2208 list_del(&inti->list); in clear_irq_list()
2216 irq->type = inti->type; in inti_to_irq()
2217 switch (inti->type) { in inti_to_irq()
2221 irq->u.ext = inti->ext; in inti_to_irq()
2224 irq->u.io = inti->io; in inti_to_irq()
2231 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; in kvm_s390_clear_float_irqs()
2234 mutex_lock(&kvm->lock); in kvm_s390_clear_float_irqs()
2236 fi->masked_irqs = 0; in kvm_s390_clear_float_irqs()
2237 mutex_unlock(&kvm->lock); in kvm_s390_clear_float_irqs()
2238 spin_lock(&fi->lock); in kvm_s390_clear_float_irqs()
2239 fi->pending_irqs = 0; in kvm_s390_clear_float_irqs()
2240 memset(&fi->srv_signal, 0, sizeof(fi->srv_signal)); in kvm_s390_clear_float_irqs()
2241 memset(&fi->mchk, 0, sizeof(fi->mchk)); in kvm_s390_clear_float_irqs()
2243 clear_irq_list(&fi->lists[i]); in kvm_s390_clear_float_irqs()
2245 fi->counters[i] = 0; in kvm_s390_clear_float_irqs()
2246 spin_unlock(&fi->lock); in kvm_s390_clear_float_irqs()
2252 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in get_all_floating_irqs()
2263 return -EINVAL; in get_all_floating_irqs()
2266 * We are already using -ENOMEM to signal in get_all_floating_irqs()
2272 return -ENOBUFS; in get_all_floating_irqs()
2276 if (gi->origin && gisa_get_ipm(gi->origin)) { in get_all_floating_irqs()
2280 ret = -ENOMEM; in get_all_floating_irqs()
2283 if (gisa_tac_ipm_gisc(gi->origin, i)) { in get_all_floating_irqs()
2285 irq->type = KVM_S390_INT_IO(1, 0, 0, 0); in get_all_floating_irqs()
2286 irq->u.io.io_int_word = isc_to_int_word(i); in get_all_floating_irqs()
2291 fi = &kvm->arch.float_int; in get_all_floating_irqs()
2292 spin_lock(&fi->lock); in get_all_floating_irqs()
2294 list_for_each_entry(inti, &fi->lists[i], list) { in get_all_floating_irqs()
2297 ret = -ENOMEM; in get_all_floating_irqs()
2304 if (test_bit(IRQ_PEND_EXT_SERVICE, &fi->pending_irqs) || in get_all_floating_irqs()
2305 test_bit(IRQ_PEND_EXT_SERVICE_EV, &fi->pending_irqs)) { in get_all_floating_irqs()
2308 ret = -ENOMEM; in get_all_floating_irqs()
2312 irq->type = KVM_S390_INT_SERVICE; in get_all_floating_irqs()
2313 irq->u.ext = fi->srv_signal; in get_all_floating_irqs()
2316 if (test_bit(IRQ_PEND_MCHK_REP, &fi->pending_irqs)) { in get_all_floating_irqs()
2319 ret = -ENOMEM; in get_all_floating_irqs()
2323 irq->type = KVM_S390_MCHK; in get_all_floating_irqs()
2324 irq->u.mchk = fi->mchk; in get_all_floating_irqs()
2329 spin_unlock(&fi->lock); in get_all_floating_irqs()
2333 ret = -EFAULT; in get_all_floating_irqs()
2342 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; in flic_ais_mode_get_all()
2345 if (attr->attr < sizeof(ais)) in flic_ais_mode_get_all()
2346 return -EINVAL; in flic_ais_mode_get_all()
2349 return -EOPNOTSUPP; in flic_ais_mode_get_all()
2351 mutex_lock(&fi->ais_lock); in flic_ais_mode_get_all()
2352 ais.simm = fi->simm; in flic_ais_mode_get_all()
2353 ais.nimm = fi->nimm; in flic_ais_mode_get_all()
2354 mutex_unlock(&fi->ais_lock); in flic_ais_mode_get_all()
2356 if (copy_to_user((void __user *)attr->addr, &ais, sizeof(ais))) in flic_ais_mode_get_all()
2357 return -EFAULT; in flic_ais_mode_get_all()
2366 switch (attr->group) { in flic_get_attr()
2368 r = get_all_floating_irqs(dev->kvm, (u8 __user *) attr->addr, in flic_get_attr()
2369 attr->attr); in flic_get_attr()
2372 r = flic_ais_mode_get_all(dev->kvm, attr); in flic_get_attr()
2375 r = -EINVAL; in flic_get_attr()
2389 if (get_user(inti->type, (u64 __user *)addr)) in copy_irq_from_user()
2390 return -EFAULT; in copy_irq_from_user()
2392 switch (inti->type) { in copy_irq_from_user()
2397 target = (void *) &inti->ext; in copy_irq_from_user()
2398 source = &uptr->u.ext; in copy_irq_from_user()
2399 size = sizeof(inti->ext); in copy_irq_from_user()
2402 target = (void *) &inti->io; in copy_irq_from_user()
2403 source = &uptr->u.io; in copy_irq_from_user()
2404 size = sizeof(inti->io); in copy_irq_from_user()
2407 target = (void *) &inti->mchk; in copy_irq_from_user()
2408 source = &uptr->u.mchk; in copy_irq_from_user()
2409 size = sizeof(inti->mchk); in copy_irq_from_user()
2412 return -EINVAL; in copy_irq_from_user()
2416 return -EFAULT; in copy_irq_from_user()
2426 int len = attr->attr; in enqueue_floating_irq()
2429 return -EINVAL; in enqueue_floating_irq()
2431 return -EINVAL; in enqueue_floating_irq()
2436 return -ENOMEM; in enqueue_floating_irq()
2438 r = copy_irq_from_user(inti, attr->addr); in enqueue_floating_irq()
2443 r = __inject_vm(dev->kvm, inti); in enqueue_floating_irq()
2448 len -= sizeof(struct kvm_s390_irq); in enqueue_floating_irq()
2449 attr->addr += sizeof(struct kvm_s390_irq); in enqueue_floating_irq()
2460 return kvm->arch.adapters[id]; in get_io_adapter()
2470 (void __user *)attr->addr, sizeof(adapter_info))) in register_io_adapter()
2471 return -EFAULT; in register_io_adapter()
2474 return -EINVAL; in register_io_adapter()
2479 if (dev->kvm->arch.adapters[adapter_info.id] != NULL) in register_io_adapter()
2480 return -EINVAL; in register_io_adapter()
2484 return -ENOMEM; in register_io_adapter()
2486 adapter->id = adapter_info.id; in register_io_adapter()
2487 adapter->isc = adapter_info.isc; in register_io_adapter()
2488 adapter->maskable = adapter_info.maskable; in register_io_adapter()
2489 adapter->masked = false; in register_io_adapter()
2490 adapter->swap = adapter_info.swap; in register_io_adapter()
2491 adapter->suppressible = (adapter_info.flags) & in register_io_adapter()
2493 dev->kvm->arch.adapters[adapter->id] = adapter; in register_io_adapter()
2503 if (!adapter || !adapter->maskable) in kvm_s390_mask_adapter()
2504 return -EINVAL; in kvm_s390_mask_adapter()
2505 ret = adapter->masked; in kvm_s390_mask_adapter()
2506 adapter->masked = masked; in kvm_s390_mask_adapter()
2515 kfree(kvm->arch.adapters[i]); in kvm_s390_destroy_adapters()
2525 if (copy_from_user(&req, (void __user *)attr->addr, sizeof(req))) in modify_io_adapter()
2526 return -EFAULT; in modify_io_adapter()
2528 adapter = get_io_adapter(dev->kvm, req.id); in modify_io_adapter()
2530 return -EINVAL; in modify_io_adapter()
2533 ret = kvm_s390_mask_adapter(dev->kvm, req.id, req.mask); in modify_io_adapter()
2538 * The following operations are no longer needed and therefore no-ops. in modify_io_adapter()
2547 ret = -EINVAL; in modify_io_adapter()
2559 if (attr->flags) in clear_io_irq()
2560 return -EINVAL; in clear_io_irq()
2561 if (attr->attr != sizeof(schid)) in clear_io_irq()
2562 return -EINVAL; in clear_io_irq()
2563 if (copy_from_user(&schid, (void __user *) attr->addr, sizeof(schid))) in clear_io_irq()
2564 return -EFAULT; in clear_io_irq()
2566 return -EINVAL; in clear_io_irq()
2578 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; in modify_ais_mode()
2583 return -EOPNOTSUPP; in modify_ais_mode()
2585 if (copy_from_user(&req, (void __user *)attr->addr, sizeof(req))) in modify_ais_mode()
2586 return -EFAULT; in modify_ais_mode()
2589 return -EINVAL; in modify_ais_mode()
2592 (fi->simm & AIS_MODE_MASK(req.isc)) ? in modify_ais_mode()
2593 (fi->nimm & AIS_MODE_MASK(req.isc)) ? in modify_ais_mode()
2597 mutex_lock(&fi->ais_lock); in modify_ais_mode()
2600 fi->simm &= ~AIS_MODE_MASK(req.isc); in modify_ais_mode()
2601 fi->nimm &= ~AIS_MODE_MASK(req.isc); in modify_ais_mode()
2604 fi->simm |= AIS_MODE_MASK(req.isc); in modify_ais_mode()
2605 fi->nimm &= ~AIS_MODE_MASK(req.isc); in modify_ais_mode()
2608 ret = -EINVAL; in modify_ais_mode()
2610 mutex_unlock(&fi->ais_lock); in modify_ais_mode()
2618 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; in kvm_s390_inject_airq()
2622 .parm64 = isc_to_int_word(adapter->isc), in kvm_s390_inject_airq()
2626 if (!test_kvm_facility(kvm, 72) || !adapter->suppressible) in kvm_s390_inject_airq()
2629 mutex_lock(&fi->ais_lock); in kvm_s390_inject_airq()
2630 if (fi->nimm & AIS_MODE_MASK(adapter->isc)) { in kvm_s390_inject_airq()
2631 trace_kvm_s390_airq_suppressed(adapter->id, adapter->isc); in kvm_s390_inject_airq()
2636 if (!ret && (fi->simm & AIS_MODE_MASK(adapter->isc))) { in kvm_s390_inject_airq()
2637 fi->nimm |= AIS_MODE_MASK(adapter->isc); in kvm_s390_inject_airq()
2638 trace_kvm_s390_modify_ais_mode(adapter->isc, in kvm_s390_inject_airq()
2642 mutex_unlock(&fi->ais_lock); in kvm_s390_inject_airq()
2648 unsigned int id = attr->attr; in flic_inject_airq()
2652 return -EINVAL; in flic_inject_airq()
2659 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; in flic_ais_mode_set_all()
2663 return -EOPNOTSUPP; in flic_ais_mode_set_all()
2665 if (copy_from_user(&ais, (void __user *)attr->addr, sizeof(ais))) in flic_ais_mode_set_all()
2666 return -EFAULT; in flic_ais_mode_set_all()
2668 mutex_lock(&fi->ais_lock); in flic_ais_mode_set_all()
2669 fi->simm = ais.simm; in flic_ais_mode_set_all()
2670 fi->nimm = ais.nimm; in flic_ais_mode_set_all()
2671 mutex_unlock(&fi->ais_lock); in flic_ais_mode_set_all()
2682 switch (attr->group) { in flic_set_attr()
2687 kvm_s390_clear_float_irqs(dev->kvm); in flic_set_attr()
2690 dev->kvm->arch.gmap->pfault_enabled = 1; in flic_set_attr()
2693 dev->kvm->arch.gmap->pfault_enabled = 0; in flic_set_attr()
2699 synchronize_srcu(&dev->kvm->srcu); in flic_set_attr()
2700 kvm_for_each_vcpu(i, vcpu, dev->kvm) in flic_set_attr()
2710 r = clear_io_irq(dev->kvm, attr); in flic_set_attr()
2713 r = modify_ais_mode(dev->kvm, attr); in flic_set_attr()
2716 r = flic_inject_airq(dev->kvm, attr); in flic_set_attr()
2719 r = flic_ais_mode_set_all(dev->kvm, attr); in flic_set_attr()
2722 r = -EINVAL; in flic_set_attr()
2731 switch (attr->group) { in flic_has_attr()
2745 return -ENXIO; in flic_has_attr()
2751 return -EINVAL; in flic_create()
2752 if (dev->kvm->arch.flic) in flic_create()
2753 return -EINVAL; in flic_create()
2754 dev->kvm->arch.flic = dev; in flic_create()
2760 dev->kvm->arch.flic = NULL; in flic_destroy()
2766 .name = "kvm-flic",
2780 return swap ? (bit ^ (BITS_PER_LONG - 1)) : bit; in get_ind_bit()
2787 mmap_read_lock(kvm->mm); in get_map_page()
2788 get_user_pages_remote(kvm->mm, uaddr, 1, FOLL_WRITE, in get_map_page()
2790 mmap_read_unlock(kvm->mm); in get_map_page()
2803 ind_page = get_map_page(kvm, adapter_int->ind_addr); in adapter_indicators_set()
2805 return -1; in adapter_indicators_set()
2806 summary_page = get_map_page(kvm, adapter_int->summary_addr); in adapter_indicators_set()
2809 return -1; in adapter_indicators_set()
2812 idx = srcu_read_lock(&kvm->srcu); in adapter_indicators_set()
2814 bit = get_ind_bit(adapter_int->ind_addr, in adapter_indicators_set()
2815 adapter_int->ind_offset, adapter->swap); in adapter_indicators_set()
2817 mark_page_dirty(kvm, adapter_int->ind_addr >> PAGE_SHIFT); in adapter_indicators_set()
2820 bit = get_ind_bit(adapter_int->summary_addr, in adapter_indicators_set()
2821 adapter_int->summary_offset, adapter->swap); in adapter_indicators_set()
2823 mark_page_dirty(kvm, adapter_int->summary_addr >> PAGE_SHIFT); in adapter_indicators_set()
2825 srcu_read_unlock(&kvm->srcu, idx); in adapter_indicators_set()
2833 * < 0 - not injected due to error
2834 * = 0 - coalesced, summary indicator already active
2835 * > 0 - injected interrupt
2844 /* We're only interested in the 0->1 transition. */ in set_adapter_int()
2847 adapter = get_io_adapter(kvm, e->adapter.adapter_id); in set_adapter_int()
2849 return -1; in set_adapter_int()
2850 ret = adapter_indicators_set(kvm, adapter, &e->adapter); in set_adapter_int()
2851 if ((ret > 0) && !adapter->masked) { in set_adapter_int()
2872 mci.val = mcck_info->mcic; in kvm_s390_reinject_machine_check()
2881 mchk->cr14 = cr14; in kvm_s390_reinject_machine_check()
2882 mchk->mcic = mcck_info->mcic; in kvm_s390_reinject_machine_check()
2883 mchk->ext_damage_code = mcck_info->ext_damage_code; in kvm_s390_reinject_machine_check()
2884 mchk->failing_storage_address = mcck_info->failing_storage_address; in kvm_s390_reinject_machine_check()
2888 rc = __inject_vm(vcpu->kvm, &inti); in kvm_s390_reinject_machine_check()
2903 switch (ue->type) { in kvm_set_routing_entry()
2906 e->set = set_adapter_int; in kvm_set_routing_entry()
2907 uaddr = gmap_translate(kvm->arch.gmap, ue->u.adapter.summary_addr); in kvm_set_routing_entry()
2908 if (uaddr == -EFAULT) in kvm_set_routing_entry()
2909 return -EFAULT; in kvm_set_routing_entry()
2910 e->adapter.summary_addr = uaddr; in kvm_set_routing_entry()
2911 uaddr = gmap_translate(kvm->arch.gmap, ue->u.adapter.ind_addr); in kvm_set_routing_entry()
2912 if (uaddr == -EFAULT) in kvm_set_routing_entry()
2913 return -EFAULT; in kvm_set_routing_entry()
2914 e->adapter.ind_addr = uaddr; in kvm_set_routing_entry()
2915 e->adapter.summary_offset = ue->u.adapter.summary_offset; in kvm_set_routing_entry()
2916 e->adapter.ind_offset = ue->u.adapter.ind_offset; in kvm_set_routing_entry()
2917 e->adapter.adapter_id = ue->u.adapter.adapter_id; in kvm_set_routing_entry()
2920 return -EINVAL; in kvm_set_routing_entry()
2927 return -EINVAL; in kvm_set_msi()
2932 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in kvm_s390_set_irq_state() local
2939 return -ENOMEM; in kvm_s390_set_irq_state()
2942 r = -EFAULT; in kvm_s390_set_irq_state()
2950 spin_lock(&li->lock); in kvm_s390_set_irq_state()
2951 if (li->pending_irqs) { in kvm_s390_set_irq_state()
2952 r = -EBUSY; in kvm_s390_set_irq_state()
2963 spin_unlock(&li->lock); in kvm_s390_set_irq_state()
2970 static void store_local_irq(struct kvm_s390_local_interrupt *li, in store_local_irq() argument
2977 irq->type = KVM_S390_MCHK; in store_local_irq()
2978 irq->u.mchk = li->irq.mchk; in store_local_irq()
2981 irq->type = KVM_S390_PROGRAM_INT; in store_local_irq()
2982 irq->u.pgm = li->irq.pgm; in store_local_irq()
2985 irq->type = KVM_S390_INT_PFAULT_INIT; in store_local_irq()
2986 irq->u.ext = li->irq.ext; in store_local_irq()
2989 irq->type = KVM_S390_INT_EXTERNAL_CALL; in store_local_irq()
2990 irq->u.extcall = li->irq.extcall; in store_local_irq()
2993 irq->type = KVM_S390_INT_CLOCK_COMP; in store_local_irq()
2996 irq->type = KVM_S390_INT_CPU_TIMER; in store_local_irq()
2999 irq->type = KVM_S390_SIGP_STOP; in store_local_irq()
3000 irq->u.stop = li->irq.stop; in store_local_irq()
3003 irq->type = KVM_S390_RESTART; in store_local_irq()
3006 irq->type = KVM_S390_SIGP_SET_PREFIX; in store_local_irq()
3007 irq->u.prefix = li->irq.prefix; in store_local_irq()
3016 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; in kvm_s390_get_irq_state() local
3023 spin_lock(&li->lock); in kvm_s390_get_irq_state()
3024 pending_irqs = li->pending_irqs; in kvm_s390_get_irq_state()
3025 memcpy(&sigp_emerg_pending, &li->sigp_emerg_pending, in kvm_s390_get_irq_state()
3027 spin_unlock(&li->lock); in kvm_s390_get_irq_state()
3034 return -ENOBUFS; in kvm_s390_get_irq_state()
3035 store_local_irq(&vcpu->arch.local_int, &irq, irq_type); in kvm_s390_get_irq_state()
3037 return -EFAULT; in kvm_s390_get_irq_state()
3045 return -ENOBUFS; in kvm_s390_get_irq_state()
3049 return -EFAULT; in kvm_s390_get_irq_state()
3056 return -ENOBUFS; in kvm_s390_get_irq_state()
3061 return -EFAULT; in kvm_s390_get_irq_state()
3070 int vcpu_idx, online_vcpus = atomic_read(&kvm->online_vcpus); in __airqs_kick_single_vcpu()
3071 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in __airqs_kick_single_vcpu()
3075 for_each_set_bit(vcpu_idx, kvm->arch.idle_mask, online_vcpus) { in __airqs_kick_single_vcpu()
3079 vcpu_isc_mask = (u8)(vcpu->arch.sie_block->gcr[6] >> 24); in __airqs_kick_single_vcpu()
3082 if (test_and_set_bit(vcpu_idx, gi->kicked_mask)) in __airqs_kick_single_vcpu()
3095 container_of(gi->origin, struct sie_page2, gisa)->kvm; in gisa_vcpu_kicker()
3101 hrtimer_forward_now(timer, ns_to_ktime(gi->expires)); in gisa_vcpu_kicker()
3131 * for guests not in the yet cut-off alert list. When in the in process_gib_alert_list()
3132 * final loop, store the NULL_GISA_ADDR instead. This will re- in process_gib_alert_list()
3135 origin = xchg(&gib->alert_list_origin, in process_gib_alert_list()
3138 * Loop through the just cut-off alert list and start the in process_gib_alert_list()
3145 origin = gisa->next_alert; in process_gib_alert_list()
3146 gisa->next_alert = gisa_phys; in process_gib_alert_list()
3147 kvm = container_of(gisa, struct sie_page2, gisa)->kvm; in process_gib_alert_list()
3148 gi = &kvm->arch.gisa_int; in process_gib_alert_list()
3149 if (hrtimer_active(&gi->timer)) in process_gib_alert_list()
3150 hrtimer_cancel(&gi->timer); in process_gib_alert_list()
3151 hrtimer_start(&gi->timer, 0, HRTIMER_MODE_REL); in process_gib_alert_list()
3159 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in kvm_s390_gisa_clear()
3161 if (!gi->origin) in kvm_s390_gisa_clear()
3163 gisa_clear_ipm(gi->origin); in kvm_s390_gisa_clear()
3164 VM_EVENT(kvm, 3, "gisa 0x%pK cleared", gi->origin); in kvm_s390_gisa_clear()
3169 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in kvm_s390_gisa_init()
3173 gi->origin = &kvm->arch.sie_page2->gisa; in kvm_s390_gisa_init()
3174 gi->alert.mask = 0; in kvm_s390_gisa_init()
3175 spin_lock_init(&gi->alert.ref_lock); in kvm_s390_gisa_init()
3176 gi->expires = 50 * 1000; /* 50 usec */ in kvm_s390_gisa_init()
3177 hrtimer_init(&gi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in kvm_s390_gisa_init()
3178 gi->timer.function = gisa_vcpu_kicker; in kvm_s390_gisa_init()
3179 memset(gi->origin, 0, sizeof(struct kvm_s390_gisa)); in kvm_s390_gisa_init()
3180 gi->origin->next_alert = (u32)virt_to_phys(gi->origin); in kvm_s390_gisa_init()
3181 VM_EVENT(kvm, 3, "gisa 0x%pK initialized", gi->origin); in kvm_s390_gisa_init()
3186 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in kvm_s390_gisa_enable()
3191 if (gi->origin) in kvm_s390_gisa_enable()
3198 mutex_lock(&vcpu->mutex); in kvm_s390_gisa_enable()
3199 vcpu->arch.sie_block->gd = gisa_desc; in kvm_s390_gisa_enable()
3200 vcpu->arch.sie_block->eca |= ECA_AIV; in kvm_s390_gisa_enable()
3201 VCPU_EVENT(vcpu, 3, "AIV gisa format-%u enabled for cpu %03u", in kvm_s390_gisa_enable()
3202 vcpu->arch.sie_block->gd & 0x3, vcpu->vcpu_id); in kvm_s390_gisa_enable()
3203 mutex_unlock(&vcpu->mutex); in kvm_s390_gisa_enable()
3209 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in kvm_s390_gisa_destroy()
3210 struct kvm_s390_gisa *gisa = gi->origin; in kvm_s390_gisa_destroy()
3212 if (!gi->origin) in kvm_s390_gisa_destroy()
3214 WARN(gi->alert.mask != 0x00, in kvm_s390_gisa_destroy()
3216 gi->alert.mask); in kvm_s390_gisa_destroy()
3217 gi->alert.mask = 0x00; in kvm_s390_gisa_destroy()
3218 if (gisa_set_iam(gi->origin, gi->alert.mask)) in kvm_s390_gisa_destroy()
3220 hrtimer_cancel(&gi->timer); in kvm_s390_gisa_destroy()
3221 gi->origin = NULL; in kvm_s390_gisa_destroy()
3227 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in kvm_s390_gisa_disable()
3231 if (!gi->origin) in kvm_s390_gisa_disable()
3234 mutex_lock(&vcpu->mutex); in kvm_s390_gisa_disable()
3235 vcpu->arch.sie_block->eca &= ~ECA_AIV; in kvm_s390_gisa_disable()
3236 vcpu->arch.sie_block->gd = 0U; in kvm_s390_gisa_disable()
3237 mutex_unlock(&vcpu->mutex); in kvm_s390_gisa_disable()
3238 VCPU_EVENT(vcpu, 3, "AIV disabled for cpu %03u", vcpu->vcpu_id); in kvm_s390_gisa_disable()
3244 * kvm_s390_gisc_register - register a guest ISC
3257 * -ENODEV in case the vm uses no GISA
3258 * -ERANGE in case the guest ISC is invalid
3262 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in kvm_s390_gisc_register()
3264 if (!gi->origin) in kvm_s390_gisc_register()
3265 return -ENODEV; in kvm_s390_gisc_register()
3267 return -ERANGE; in kvm_s390_gisc_register()
3269 spin_lock(&gi->alert.ref_lock); in kvm_s390_gisc_register()
3270 gi->alert.ref_count[gisc]++; in kvm_s390_gisc_register()
3271 if (gi->alert.ref_count[gisc] == 1) { in kvm_s390_gisc_register()
3272 gi->alert.mask |= 0x80 >> gisc; in kvm_s390_gisc_register()
3273 gisa_set_iam(gi->origin, gi->alert.mask); in kvm_s390_gisc_register()
3275 spin_unlock(&gi->alert.ref_lock); in kvm_s390_gisc_register()
3277 return gib->nisc; in kvm_s390_gisc_register()
3282 * kvm_s390_gisc_unregister - unregister a guest ISC
3295 * -ENODEV in case the vm uses no GISA
3296 * -ERANGE in case the guest ISC is invalid
3297 * -EINVAL in case the guest ISC is not registered
3301 struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; in kvm_s390_gisc_unregister()
3304 if (!gi->origin) in kvm_s390_gisc_unregister()
3305 return -ENODEV; in kvm_s390_gisc_unregister()
3307 return -ERANGE; in kvm_s390_gisc_unregister()
3309 spin_lock(&gi->alert.ref_lock); in kvm_s390_gisc_unregister()
3310 if (gi->alert.ref_count[gisc] == 0) { in kvm_s390_gisc_unregister()
3311 rc = -EINVAL; in kvm_s390_gisc_unregister()
3314 gi->alert.ref_count[gisc]--; in kvm_s390_gisc_unregister()
3315 if (gi->alert.ref_count[gisc] == 0) { in kvm_s390_gisc_unregister()
3316 gi->alert.mask &= ~(0x80 >> gisc); in kvm_s390_gisc_unregister()
3317 gisa_set_iam(gi->origin, gi->alert.mask); in kvm_s390_gisc_unregister()
3320 spin_unlock(&gi->alert.ref_lock); in kvm_s390_gisc_unregister()
3332 gaite = (struct zpci_gaite *)aift->gait + in aen_host_forward()
3334 if (gaite->count == 0) in aen_host_forward()
3336 if (gaite->aisb != 0) in aen_host_forward()
3337 set_bit_inv(gaite->aisbo, phys_to_virt(gaite->aisb)); in aen_host_forward()
3342 gi = &kvm->arch.gisa_int; in aen_host_forward()
3344 if (!(gi->origin->g1.simm & AIS_MODE_MASK(gaite->gisc)) || in aen_host_forward()
3345 !(gi->origin->g1.nimm & AIS_MODE_MASK(gaite->gisc))) { in aen_host_forward()
3346 gisa_set_ipm_gisc(gi->origin, gaite->gisc); in aen_host_forward()
3347 if (hrtimer_active(&gi->timer)) in aen_host_forward()
3348 hrtimer_cancel(&gi->timer); in aen_host_forward()
3349 hrtimer_start(&gi->timer, 0, HRTIMER_MODE_REL); in aen_host_forward()
3350 kvm->stat.aen_forward++; in aen_host_forward()
3360 spin_lock_irqsave(&aift->gait_lock, flags); in aen_process_gait()
3362 if (!aift->gait) { in aen_process_gait()
3363 spin_unlock_irqrestore(&aift->gait_lock, flags); in aen_process_gait()
3369 si = airq_iv_scan(aift->sbv, si, airq_iv_end(aift->sbv)); in aen_process_gait()
3370 if (si == -1UL) { in aen_process_gait()
3372 /* Re-enable interrupts. */ in aen_process_gait()
3382 /* Scan again after re-enabling interrupts */ in aen_process_gait()
3389 spin_unlock_irqrestore(&aift->gait_lock, flags); in aen_process_gait()
3399 if ((info->forward || info->error) && in gib_alert_irq_handler()
3401 aen_process_gait(info->isc); in gib_alert_irq_handler()
3402 if (info->aism != 0) in gib_alert_irq_handler()
3418 mutex_lock(&aift->aift_lock); in kvm_s390_gib_destroy()
3420 mutex_unlock(&aift->aift_lock); in kvm_s390_gib_destroy()
3440 rc = -ENOMEM; in kvm_s390_gib_init()
3447 rc = -EIO; in kvm_s390_gib_init()
3453 gib->nisc = nisc; in kvm_s390_gib_init()
3459 rc = -EIO; in kvm_s390_gib_init()
3466 rc = -EIO; in kvm_s390_gib_init()
3471 KVM_EVENT(3, "gib 0x%pK (nisc=%d) initialized", gib, gib->nisc); in kvm_s390_gib_init()