xref: /OK3568_Linux_fs/kernel/Documentation/virt/kvm/devices/s390_flic.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun====================================
4*4882a593SmuzhiyunFLIC (floating interrupt controller)
5*4882a593Smuzhiyun====================================
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunFLIC handles floating (non per-cpu) interrupts, i.e. I/O, service and some
8*4882a593Smuzhiyunmachine check interruptions. All interrupts are stored in a per-vm list of
9*4882a593Smuzhiyunpending interrupts. FLIC performs operations on this list.
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunOnly one FLIC instance may be instantiated.
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunFLIC provides support to
14*4882a593Smuzhiyun- add interrupts (KVM_DEV_FLIC_ENQUEUE)
15*4882a593Smuzhiyun- inspect currently pending interrupts (KVM_FLIC_GET_ALL_IRQS)
16*4882a593Smuzhiyun- purge all pending floating interrupts (KVM_DEV_FLIC_CLEAR_IRQS)
17*4882a593Smuzhiyun- purge one pending floating I/O interrupt (KVM_DEV_FLIC_CLEAR_IO_IRQ)
18*4882a593Smuzhiyun- enable/disable for the guest transparent async page faults
19*4882a593Smuzhiyun- register and modify adapter interrupt sources (KVM_DEV_FLIC_ADAPTER_*)
20*4882a593Smuzhiyun- modify AIS (adapter-interruption-suppression) mode state (KVM_DEV_FLIC_AISM)
21*4882a593Smuzhiyun- inject adapter interrupts on a specified adapter (KVM_DEV_FLIC_AIRQ_INJECT)
22*4882a593Smuzhiyun- get/set all AIS mode states (KVM_DEV_FLIC_AISM_ALL)
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunGroups:
25*4882a593Smuzhiyun  KVM_DEV_FLIC_ENQUEUE
26*4882a593Smuzhiyun    Passes a buffer and length into the kernel which are then injected into
27*4882a593Smuzhiyun    the list of pending interrupts.
28*4882a593Smuzhiyun    attr->addr contains the pointer to the buffer and attr->attr contains
29*4882a593Smuzhiyun    the length of the buffer.
30*4882a593Smuzhiyun    The format of the data structure kvm_s390_irq as it is copied from userspace
31*4882a593Smuzhiyun    is defined in usr/include/linux/kvm.h.
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun  KVM_DEV_FLIC_GET_ALL_IRQS
34*4882a593Smuzhiyun    Copies all floating interrupts into a buffer provided by userspace.
35*4882a593Smuzhiyun    When the buffer is too small it returns -ENOMEM, which is the indication
36*4882a593Smuzhiyun    for userspace to try again with a bigger buffer.
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun    -ENOBUFS is returned when the allocation of a kernelspace buffer has
39*4882a593Smuzhiyun    failed.
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun    -EFAULT is returned when copying data to userspace failed.
42*4882a593Smuzhiyun    All interrupts remain pending, i.e. are not deleted from the list of
43*4882a593Smuzhiyun    currently pending interrupts.
44*4882a593Smuzhiyun    attr->addr contains the userspace address of the buffer into which all
45*4882a593Smuzhiyun    interrupt data will be copied.
46*4882a593Smuzhiyun    attr->attr contains the size of the buffer in bytes.
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun  KVM_DEV_FLIC_CLEAR_IRQS
49*4882a593Smuzhiyun    Simply deletes all elements from the list of currently pending floating
50*4882a593Smuzhiyun    interrupts.  No interrupts are injected into the guest.
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun  KVM_DEV_FLIC_CLEAR_IO_IRQ
53*4882a593Smuzhiyun    Deletes one (if any) I/O interrupt for a subchannel identified by the
54*4882a593Smuzhiyun    subsystem identification word passed via the buffer specified by
55*4882a593Smuzhiyun    attr->addr (address) and attr->attr (length).
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun  KVM_DEV_FLIC_APF_ENABLE
58*4882a593Smuzhiyun    Enables async page faults for the guest. So in case of a major page fault
59*4882a593Smuzhiyun    the host is allowed to handle this async and continues the guest.
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun  KVM_DEV_FLIC_APF_DISABLE_WAIT
62*4882a593Smuzhiyun    Disables async page faults for the guest and waits until already pending
63*4882a593Smuzhiyun    async page faults are done. This is necessary to trigger a completion interrupt
64*4882a593Smuzhiyun    for every init interrupt before migrating the interrupt list.
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun  KVM_DEV_FLIC_ADAPTER_REGISTER
67*4882a593Smuzhiyun    Register an I/O adapter interrupt source. Takes a kvm_s390_io_adapter
68*4882a593Smuzhiyun    describing the adapter to register::
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun	struct kvm_s390_io_adapter {
71*4882a593Smuzhiyun		__u32 id;
72*4882a593Smuzhiyun		__u8 isc;
73*4882a593Smuzhiyun		__u8 maskable;
74*4882a593Smuzhiyun		__u8 swap;
75*4882a593Smuzhiyun		__u8 flags;
76*4882a593Smuzhiyun	};
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun   id contains the unique id for the adapter, isc the I/O interruption subclass
79*4882a593Smuzhiyun   to use, maskable whether this adapter may be masked (interrupts turned off),
80*4882a593Smuzhiyun   swap whether the indicators need to be byte swapped, and flags contains
81*4882a593Smuzhiyun   further characteristics of the adapter.
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun   Currently defined values for 'flags' are:
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun   - KVM_S390_ADAPTER_SUPPRESSIBLE: adapter is subject to AIS
86*4882a593Smuzhiyun     (adapter-interrupt-suppression) facility. This flag only has an effect if
87*4882a593Smuzhiyun     the AIS capability is enabled.
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun   Unknown flag values are ignored.
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun  KVM_DEV_FLIC_ADAPTER_MODIFY
93*4882a593Smuzhiyun    Modifies attributes of an existing I/O adapter interrupt source. Takes
94*4882a593Smuzhiyun    a kvm_s390_io_adapter_req specifying the adapter and the operation::
95*4882a593Smuzhiyun
96*4882a593Smuzhiyun	struct kvm_s390_io_adapter_req {
97*4882a593Smuzhiyun		__u32 id;
98*4882a593Smuzhiyun		__u8 type;
99*4882a593Smuzhiyun		__u8 mask;
100*4882a593Smuzhiyun		__u16 pad0;
101*4882a593Smuzhiyun		__u64 addr;
102*4882a593Smuzhiyun	};
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun    id specifies the adapter and type the operation. The supported operations
105*4882a593Smuzhiyun    are:
106*4882a593Smuzhiyun
107*4882a593Smuzhiyun    KVM_S390_IO_ADAPTER_MASK
108*4882a593Smuzhiyun      mask or unmask the adapter, as specified in mask
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun    KVM_S390_IO_ADAPTER_MAP
111*4882a593Smuzhiyun      This is now a no-op. The mapping is purely done by the irq route.
112*4882a593Smuzhiyun    KVM_S390_IO_ADAPTER_UNMAP
113*4882a593Smuzhiyun      This is now a no-op. The mapping is purely done by the irq route.
114*4882a593Smuzhiyun
115*4882a593Smuzhiyun  KVM_DEV_FLIC_AISM
116*4882a593Smuzhiyun    modify the adapter-interruption-suppression mode for a given isc if the
117*4882a593Smuzhiyun    AIS capability is enabled. Takes a kvm_s390_ais_req describing::
118*4882a593Smuzhiyun
119*4882a593Smuzhiyun	struct kvm_s390_ais_req {
120*4882a593Smuzhiyun		__u8 isc;
121*4882a593Smuzhiyun		__u16 mode;
122*4882a593Smuzhiyun	};
123*4882a593Smuzhiyun
124*4882a593Smuzhiyun    isc contains the target I/O interruption subclass, mode the target
125*4882a593Smuzhiyun    adapter-interruption-suppression mode. The following modes are
126*4882a593Smuzhiyun    currently supported:
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun    - KVM_S390_AIS_MODE_ALL: ALL-Interruptions Mode, i.e. airq injection
129*4882a593Smuzhiyun      is always allowed;
130*4882a593Smuzhiyun    - KVM_S390_AIS_MODE_SINGLE: SINGLE-Interruption Mode, i.e. airq
131*4882a593Smuzhiyun      injection is only allowed once and the following adapter interrupts
132*4882a593Smuzhiyun      will be suppressed until the mode is set again to ALL-Interruptions
133*4882a593Smuzhiyun      or SINGLE-Interruption mode.
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun  KVM_DEV_FLIC_AIRQ_INJECT
136*4882a593Smuzhiyun    Inject adapter interrupts on a specified adapter.
137*4882a593Smuzhiyun    attr->attr contains the unique id for the adapter, which allows for
138*4882a593Smuzhiyun    adapter-specific checks and actions.
139*4882a593Smuzhiyun    For adapters subject to AIS, handle the airq injection suppression for
140*4882a593Smuzhiyun    an isc according to the adapter-interruption-suppression mode on condition
141*4882a593Smuzhiyun    that the AIS capability is enabled.
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun  KVM_DEV_FLIC_AISM_ALL
144*4882a593Smuzhiyun    Gets or sets the adapter-interruption-suppression mode for all ISCs. Takes
145*4882a593Smuzhiyun    a kvm_s390_ais_all describing::
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun	struct kvm_s390_ais_all {
148*4882a593Smuzhiyun	       __u8 simm; /* Single-Interruption-Mode mask */
149*4882a593Smuzhiyun	       __u8 nimm; /* No-Interruption-Mode mask *
150*4882a593Smuzhiyun	};
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun    simm contains Single-Interruption-Mode mask for all ISCs, nimm contains
153*4882a593Smuzhiyun    No-Interruption-Mode mask for all ISCs. Each bit in simm and nimm corresponds
154*4882a593Smuzhiyun    to an ISC (MSB0 bit 0 to ISC 0 and so on). The combination of simm bit and
155*4882a593Smuzhiyun    nimm bit presents AIS mode for a ISC.
156*4882a593Smuzhiyun
157*4882a593Smuzhiyun    KVM_DEV_FLIC_AISM_ALL is indicated by KVM_CAP_S390_AIS_MIGRATION.
158*4882a593Smuzhiyun
159*4882a593SmuzhiyunNote: The KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR device ioctls executed on
160*4882a593SmuzhiyunFLIC with an unknown group or attribute gives the error code EINVAL (instead of
161*4882a593SmuzhiyunENXIO, as specified in the API documentation). It is not possible to conclude
162*4882a593Smuzhiyunthat a FLIC operation is unavailable based on the error code resulting from a
163*4882a593Smuzhiyunusage attempt.
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun.. note:: The KVM_DEV_FLIC_CLEAR_IO_IRQ ioctl will return EINVAL in case a
166*4882a593Smuzhiyun	  zero schid is specified.
167