18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci====================================
48c2ecf20Sopenharmony_ciFLIC (floating interrupt controller)
58c2ecf20Sopenharmony_ci====================================
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciFLIC handles floating (non per-cpu) interrupts, i.e. I/O, service and some
88c2ecf20Sopenharmony_cimachine check interruptions. All interrupts are stored in a per-vm list of
98c2ecf20Sopenharmony_cipending interrupts. FLIC performs operations on this list.
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciOnly one FLIC instance may be instantiated.
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciFLIC provides support to
148c2ecf20Sopenharmony_ci- add interrupts (KVM_DEV_FLIC_ENQUEUE)
158c2ecf20Sopenharmony_ci- inspect currently pending interrupts (KVM_FLIC_GET_ALL_IRQS)
168c2ecf20Sopenharmony_ci- purge all pending floating interrupts (KVM_DEV_FLIC_CLEAR_IRQS)
178c2ecf20Sopenharmony_ci- purge one pending floating I/O interrupt (KVM_DEV_FLIC_CLEAR_IO_IRQ)
188c2ecf20Sopenharmony_ci- enable/disable for the guest transparent async page faults
198c2ecf20Sopenharmony_ci- register and modify adapter interrupt sources (KVM_DEV_FLIC_ADAPTER_*)
208c2ecf20Sopenharmony_ci- modify AIS (adapter-interruption-suppression) mode state (KVM_DEV_FLIC_AISM)
218c2ecf20Sopenharmony_ci- inject adapter interrupts on a specified adapter (KVM_DEV_FLIC_AIRQ_INJECT)
228c2ecf20Sopenharmony_ci- get/set all AIS mode states (KVM_DEV_FLIC_AISM_ALL)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciGroups:
258c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_ENQUEUE
268c2ecf20Sopenharmony_ci    Passes a buffer and length into the kernel which are then injected into
278c2ecf20Sopenharmony_ci    the list of pending interrupts.
288c2ecf20Sopenharmony_ci    attr->addr contains the pointer to the buffer and attr->attr contains
298c2ecf20Sopenharmony_ci    the length of the buffer.
308c2ecf20Sopenharmony_ci    The format of the data structure kvm_s390_irq as it is copied from userspace
318c2ecf20Sopenharmony_ci    is defined in usr/include/linux/kvm.h.
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_GET_ALL_IRQS
348c2ecf20Sopenharmony_ci    Copies all floating interrupts into a buffer provided by userspace.
358c2ecf20Sopenharmony_ci    When the buffer is too small it returns -ENOMEM, which is the indication
368c2ecf20Sopenharmony_ci    for userspace to try again with a bigger buffer.
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci    -ENOBUFS is returned when the allocation of a kernelspace buffer has
398c2ecf20Sopenharmony_ci    failed.
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci    -EFAULT is returned when copying data to userspace failed.
428c2ecf20Sopenharmony_ci    All interrupts remain pending, i.e. are not deleted from the list of
438c2ecf20Sopenharmony_ci    currently pending interrupts.
448c2ecf20Sopenharmony_ci    attr->addr contains the userspace address of the buffer into which all
458c2ecf20Sopenharmony_ci    interrupt data will be copied.
468c2ecf20Sopenharmony_ci    attr->attr contains the size of the buffer in bytes.
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_CLEAR_IRQS
498c2ecf20Sopenharmony_ci    Simply deletes all elements from the list of currently pending floating
508c2ecf20Sopenharmony_ci    interrupts.  No interrupts are injected into the guest.
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_CLEAR_IO_IRQ
538c2ecf20Sopenharmony_ci    Deletes one (if any) I/O interrupt for a subchannel identified by the
548c2ecf20Sopenharmony_ci    subsystem identification word passed via the buffer specified by
558c2ecf20Sopenharmony_ci    attr->addr (address) and attr->attr (length).
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_APF_ENABLE
588c2ecf20Sopenharmony_ci    Enables async page faults for the guest. So in case of a major page fault
598c2ecf20Sopenharmony_ci    the host is allowed to handle this async and continues the guest.
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_APF_DISABLE_WAIT
628c2ecf20Sopenharmony_ci    Disables async page faults for the guest and waits until already pending
638c2ecf20Sopenharmony_ci    async page faults are done. This is necessary to trigger a completion interrupt
648c2ecf20Sopenharmony_ci    for every init interrupt before migrating the interrupt list.
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_ADAPTER_REGISTER
678c2ecf20Sopenharmony_ci    Register an I/O adapter interrupt source. Takes a kvm_s390_io_adapter
688c2ecf20Sopenharmony_ci    describing the adapter to register::
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci	struct kvm_s390_io_adapter {
718c2ecf20Sopenharmony_ci		__u32 id;
728c2ecf20Sopenharmony_ci		__u8 isc;
738c2ecf20Sopenharmony_ci		__u8 maskable;
748c2ecf20Sopenharmony_ci		__u8 swap;
758c2ecf20Sopenharmony_ci		__u8 flags;
768c2ecf20Sopenharmony_ci	};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci   id contains the unique id for the adapter, isc the I/O interruption subclass
798c2ecf20Sopenharmony_ci   to use, maskable whether this adapter may be masked (interrupts turned off),
808c2ecf20Sopenharmony_ci   swap whether the indicators need to be byte swapped, and flags contains
818c2ecf20Sopenharmony_ci   further characteristics of the adapter.
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci   Currently defined values for 'flags' are:
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci   - KVM_S390_ADAPTER_SUPPRESSIBLE: adapter is subject to AIS
868c2ecf20Sopenharmony_ci     (adapter-interrupt-suppression) facility. This flag only has an effect if
878c2ecf20Sopenharmony_ci     the AIS capability is enabled.
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci   Unknown flag values are ignored.
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_ADAPTER_MODIFY
938c2ecf20Sopenharmony_ci    Modifies attributes of an existing I/O adapter interrupt source. Takes
948c2ecf20Sopenharmony_ci    a kvm_s390_io_adapter_req specifying the adapter and the operation::
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	struct kvm_s390_io_adapter_req {
978c2ecf20Sopenharmony_ci		__u32 id;
988c2ecf20Sopenharmony_ci		__u8 type;
998c2ecf20Sopenharmony_ci		__u8 mask;
1008c2ecf20Sopenharmony_ci		__u16 pad0;
1018c2ecf20Sopenharmony_ci		__u64 addr;
1028c2ecf20Sopenharmony_ci	};
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci    id specifies the adapter and type the operation. The supported operations
1058c2ecf20Sopenharmony_ci    are:
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci    KVM_S390_IO_ADAPTER_MASK
1088c2ecf20Sopenharmony_ci      mask or unmask the adapter, as specified in mask
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci    KVM_S390_IO_ADAPTER_MAP
1118c2ecf20Sopenharmony_ci      This is now a no-op. The mapping is purely done by the irq route.
1128c2ecf20Sopenharmony_ci    KVM_S390_IO_ADAPTER_UNMAP
1138c2ecf20Sopenharmony_ci      This is now a no-op. The mapping is purely done by the irq route.
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_AISM
1168c2ecf20Sopenharmony_ci    modify the adapter-interruption-suppression mode for a given isc if the
1178c2ecf20Sopenharmony_ci    AIS capability is enabled. Takes a kvm_s390_ais_req describing::
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci	struct kvm_s390_ais_req {
1208c2ecf20Sopenharmony_ci		__u8 isc;
1218c2ecf20Sopenharmony_ci		__u16 mode;
1228c2ecf20Sopenharmony_ci	};
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci    isc contains the target I/O interruption subclass, mode the target
1258c2ecf20Sopenharmony_ci    adapter-interruption-suppression mode. The following modes are
1268c2ecf20Sopenharmony_ci    currently supported:
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci    - KVM_S390_AIS_MODE_ALL: ALL-Interruptions Mode, i.e. airq injection
1298c2ecf20Sopenharmony_ci      is always allowed;
1308c2ecf20Sopenharmony_ci    - KVM_S390_AIS_MODE_SINGLE: SINGLE-Interruption Mode, i.e. airq
1318c2ecf20Sopenharmony_ci      injection is only allowed once and the following adapter interrupts
1328c2ecf20Sopenharmony_ci      will be suppressed until the mode is set again to ALL-Interruptions
1338c2ecf20Sopenharmony_ci      or SINGLE-Interruption mode.
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_AIRQ_INJECT
1368c2ecf20Sopenharmony_ci    Inject adapter interrupts on a specified adapter.
1378c2ecf20Sopenharmony_ci    attr->attr contains the unique id for the adapter, which allows for
1388c2ecf20Sopenharmony_ci    adapter-specific checks and actions.
1398c2ecf20Sopenharmony_ci    For adapters subject to AIS, handle the airq injection suppression for
1408c2ecf20Sopenharmony_ci    an isc according to the adapter-interruption-suppression mode on condition
1418c2ecf20Sopenharmony_ci    that the AIS capability is enabled.
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci  KVM_DEV_FLIC_AISM_ALL
1448c2ecf20Sopenharmony_ci    Gets or sets the adapter-interruption-suppression mode for all ISCs. Takes
1458c2ecf20Sopenharmony_ci    a kvm_s390_ais_all describing::
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	struct kvm_s390_ais_all {
1488c2ecf20Sopenharmony_ci	       __u8 simm; /* Single-Interruption-Mode mask */
1498c2ecf20Sopenharmony_ci	       __u8 nimm; /* No-Interruption-Mode mask *
1508c2ecf20Sopenharmony_ci	};
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci    simm contains Single-Interruption-Mode mask for all ISCs, nimm contains
1538c2ecf20Sopenharmony_ci    No-Interruption-Mode mask for all ISCs. Each bit in simm and nimm corresponds
1548c2ecf20Sopenharmony_ci    to an ISC (MSB0 bit 0 to ISC 0 and so on). The combination of simm bit and
1558c2ecf20Sopenharmony_ci    nimm bit presents AIS mode for a ISC.
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci    KVM_DEV_FLIC_AISM_ALL is indicated by KVM_CAP_S390_AIS_MIGRATION.
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ciNote: The KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR device ioctls executed on
1608c2ecf20Sopenharmony_ciFLIC with an unknown group or attribute gives the error code EINVAL (instead of
1618c2ecf20Sopenharmony_ciENXIO, as specified in the API documentation). It is not possible to conclude
1628c2ecf20Sopenharmony_cithat a FLIC operation is unavailable based on the error code resulting from a
1638c2ecf20Sopenharmony_ciusage attempt.
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci.. note:: The KVM_DEV_FLIC_CLEAR_IO_IRQ ioctl will return EINVAL in case a
1668c2ecf20Sopenharmony_ci	  zero schid is specified.
167