diff options
| author | Jens Freimann <jfrei@linux.vnet.ibm.com> | 2014-11-11 14:57:06 -0500 |
|---|---|---|
| committer | Christian Borntraeger <borntraeger@de.ibm.com> | 2015-03-31 15:07:30 -0400 |
| commit | 47b43c52ee4b0425449d1b2b1eedca7f6b7a578a (patch) | |
| tree | 70342ba800b1cd61ed55059d12e873c706d822ba | |
| parent | b4aec92567f3146167cbc262c686ff73730aa4ca (diff) | |
KVM: s390: add ioctl to inject local interrupts
We have introduced struct kvm_s390_irq a while ago which allows to
inject all kinds of interrupts as defined in the Principles of
Operation.
Add ioctl to inject interrupts with the extended struct kvm_s390_irq
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
| -rw-r--r-- | Documentation/virtual/kvm/api.txt | 56 | ||||
| -rw-r--r-- | arch/s390/kvm/kvm-s390.c | 10 | ||||
| -rw-r--r-- | include/uapi/linux/kvm.h | 3 | ||||
| -rw-r--r-- | virt/kvm/kvm_main.c | 2 |
4 files changed, 70 insertions, 1 deletions
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index 0d7fc66289a0..a7c651d0dc63 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt | |||
| @@ -2820,6 +2820,62 @@ single frame starting at start_gfn for count frames. | |||
| 2820 | Note: If any architecturally invalid key value is found in the given data then | 2820 | Note: If any architecturally invalid key value is found in the given data then |
| 2821 | the ioctl will return -EINVAL. | 2821 | the ioctl will return -EINVAL. |
| 2822 | 2822 | ||
| 2823 | 4.92 KVM_S390_IRQ | ||
| 2824 | |||
| 2825 | Capability: KVM_CAP_S390_INJECT_IRQ | ||
| 2826 | Architectures: s390 | ||
| 2827 | Type: vcpu ioctl | ||
| 2828 | Parameters: struct kvm_s390_irq (in) | ||
| 2829 | Returns: 0 on success, -1 on error | ||
| 2830 | Errors: | ||
| 2831 | EINVAL: interrupt type is invalid | ||
| 2832 | type is KVM_S390_SIGP_STOP and flag parameter is invalid value | ||
| 2833 | type is KVM_S390_INT_EXTERNAL_CALL and code is bigger | ||
| 2834 | than the maximum of VCPUs | ||
| 2835 | EBUSY: type is KVM_S390_SIGP_SET_PREFIX and vcpu is not stopped | ||
| 2836 | type is KVM_S390_SIGP_STOP and a stop irq is already pending | ||
| 2837 | type is KVM_S390_INT_EXTERNAL_CALL and an external call interrupt | ||
| 2838 | is already pending | ||
| 2839 | |||
| 2840 | Allows to inject an interrupt to the guest. | ||
| 2841 | |||
| 2842 | Using struct kvm_s390_irq as a parameter allows | ||
| 2843 | to inject additional payload which is not | ||
| 2844 | possible via KVM_S390_INTERRUPT. | ||
| 2845 | |||
| 2846 | Interrupt parameters are passed via kvm_s390_irq: | ||
| 2847 | |||
| 2848 | struct kvm_s390_irq { | ||
| 2849 | __u64 type; | ||
| 2850 | union { | ||
| 2851 | struct kvm_s390_io_info io; | ||
| 2852 | struct kvm_s390_ext_info ext; | ||
| 2853 | struct kvm_s390_pgm_info pgm; | ||
| 2854 | struct kvm_s390_emerg_info emerg; | ||
| 2855 | struct kvm_s390_extcall_info extcall; | ||
| 2856 | struct kvm_s390_prefix_info prefix; | ||
| 2857 | struct kvm_s390_stop_info stop; | ||
| 2858 | struct kvm_s390_mchk_info mchk; | ||
| 2859 | char reserved[64]; | ||
| 2860 | } u; | ||
| 2861 | }; | ||
| 2862 | |||
| 2863 | type can be one of the following: | ||
| 2864 | |||
| 2865 | KVM_S390_SIGP_STOP - sigp stop; parameter in .stop | ||
| 2866 | KVM_S390_PROGRAM_INT - program check; parameters in .pgm | ||
| 2867 | KVM_S390_SIGP_SET_PREFIX - sigp set prefix; parameters in .prefix | ||
| 2868 | KVM_S390_RESTART - restart; no parameters | ||
| 2869 | KVM_S390_INT_CLOCK_COMP - clock comparator interrupt; no parameters | ||
| 2870 | KVM_S390_INT_CPU_TIMER - CPU timer interrupt; no parameters | ||
| 2871 | KVM_S390_INT_EMERGENCY - sigp emergency; parameters in .emerg | ||
| 2872 | KVM_S390_INT_EXTERNAL_CALL - sigp external call; parameters in .extcall | ||
| 2873 | KVM_S390_MCHK - machine check interrupt; parameters in .mchk | ||
| 2874 | |||
| 2875 | |||
| 2876 | Note that the vcpu ioctl is asynchronous to vcpu execution. | ||
| 2877 | |||
| 2878 | |||
| 2823 | 5. The kvm_run structure | 2879 | 5. The kvm_run structure |
| 2824 | ------------------------ | 2880 | ------------------------ |
| 2825 | 2881 | ||
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index dbc9ca34d9da..8bc25d405edf 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
| @@ -177,6 +177,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) | |||
| 177 | case KVM_CAP_S390_IRQCHIP: | 177 | case KVM_CAP_S390_IRQCHIP: |
| 178 | case KVM_CAP_VM_ATTRIBUTES: | 178 | case KVM_CAP_VM_ATTRIBUTES: |
| 179 | case KVM_CAP_MP_STATE: | 179 | case KVM_CAP_MP_STATE: |
| 180 | case KVM_CAP_S390_INJECT_IRQ: | ||
| 180 | case KVM_CAP_S390_USER_SIGP: | 181 | case KVM_CAP_S390_USER_SIGP: |
| 181 | case KVM_CAP_S390_USER_STSI: | 182 | case KVM_CAP_S390_USER_STSI: |
| 182 | case KVM_CAP_S390_SKEYS: | 183 | case KVM_CAP_S390_SKEYS: |
| @@ -2391,6 +2392,15 @@ long kvm_arch_vcpu_ioctl(struct file *filp, | |||
| 2391 | long r; | 2392 | long r; |
| 2392 | 2393 | ||
| 2393 | switch (ioctl) { | 2394 | switch (ioctl) { |
| 2395 | case KVM_S390_IRQ: { | ||
| 2396 | struct kvm_s390_irq s390irq; | ||
| 2397 | |||
| 2398 | r = -EFAULT; | ||
| 2399 | if (copy_from_user(&s390irq, argp, sizeof(s390irq))) | ||
| 2400 | break; | ||
| 2401 | r = kvm_s390_inject_vcpu(vcpu, &s390irq); | ||
| 2402 | break; | ||
| 2403 | } | ||
| 2394 | case KVM_S390_INTERRUPT: { | 2404 | case KVM_S390_INTERRUPT: { |
| 2395 | struct kvm_s390_interrupt s390int; | 2405 | struct kvm_s390_interrupt s390int; |
| 2396 | struct kvm_s390_irq s390irq; | 2406 | struct kvm_s390_irq s390irq; |
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 1162ef7a3fa1..c0632e87a00f 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h | |||
| @@ -802,6 +802,7 @@ struct kvm_ppc_smmu_info { | |||
| 802 | #define KVM_CAP_S390_MEM_OP 108 | 802 | #define KVM_CAP_S390_MEM_OP 108 |
| 803 | #define KVM_CAP_S390_USER_STSI 109 | 803 | #define KVM_CAP_S390_USER_STSI 109 |
| 804 | #define KVM_CAP_S390_SKEYS 110 | 804 | #define KVM_CAP_S390_SKEYS 110 |
| 805 | #define KVM_CAP_S390_INJECT_IRQ 113 | ||
| 805 | 806 | ||
| 806 | #ifdef KVM_CAP_IRQ_ROUTING | 807 | #ifdef KVM_CAP_IRQ_ROUTING |
| 807 | 808 | ||
| @@ -1182,6 +1183,8 @@ struct kvm_s390_ucas_mapping { | |||
| 1182 | /* Available with KVM_CAP_S390_SKEYS */ | 1183 | /* Available with KVM_CAP_S390_SKEYS */ |
| 1183 | #define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys) | 1184 | #define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys) |
| 1184 | #define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys) | 1185 | #define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys) |
| 1186 | /* Available with KVM_CAP_S390_INJECT_IRQ */ | ||
| 1187 | #define KVM_S390_IRQ _IOW(KVMIO, 0xb4, struct kvm_s390_irq) | ||
| 1185 | 1188 | ||
| 1186 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) | 1189 | #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) |
| 1187 | #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) | 1190 | #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a1093700f3a4..34310a8d24b9 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
| @@ -2118,7 +2118,7 @@ static long kvm_vcpu_ioctl(struct file *filp, | |||
| 2118 | * Special cases: vcpu ioctls that are asynchronous to vcpu execution, | 2118 | * Special cases: vcpu ioctls that are asynchronous to vcpu execution, |
| 2119 | * so vcpu_load() would break it. | 2119 | * so vcpu_load() would break it. |
| 2120 | */ | 2120 | */ |
| 2121 | if (ioctl == KVM_S390_INTERRUPT || ioctl == KVM_INTERRUPT) | 2121 | if (ioctl == KVM_S390_INTERRUPT || ioctl == KVM_S390_IRQ || ioctl == KVM_INTERRUPT) |
| 2122 | return kvm_arch_vcpu_ioctl(filp, ioctl, arg); | 2122 | return kvm_arch_vcpu_ioctl(filp, ioctl, arg); |
| 2123 | #endif | 2123 | #endif |
| 2124 | 2124 | ||
