diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2018-03-19 02:02:52 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2018-03-19 02:02:52 -0400 |
commit | bcbd41da3b0a8a3e0f8457bb545a32f5ca3c81f5 (patch) | |
tree | ca3f72b98c73eb74235c05f204bbbfdd31240910 | |
parent | 81796a3c6a4ad3ba0408c807ec14f50e6270ec23 (diff) | |
parent | 9851bc77e62499957567e7c39a5beba7d6de6296 (diff) |
Merge tag 'vfio-ccw-20180305' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/vfio-ccw into features
Pull vfio-ccw patches from Cornelia Huck:
A small documentation update, and reject transport mode requests
(which we don't support).
-rw-r--r-- | Documentation/s390/vfio-ccw.txt | 79 | ||||
-rw-r--r-- | drivers/s390/cio/vfio_ccw_fsm.c | 5 |
2 files changed, 43 insertions, 41 deletions
diff --git a/Documentation/s390/vfio-ccw.txt b/Documentation/s390/vfio-ccw.txt index 90b3dfead81b..2be11ad864ff 100644 --- a/Documentation/s390/vfio-ccw.txt +++ b/Documentation/s390/vfio-ccw.txt | |||
@@ -28,7 +28,7 @@ every detail. More information/reference could be found here: | |||
28 | https://en.wikipedia.org/wiki/Channel_I/O | 28 | https://en.wikipedia.org/wiki/Channel_I/O |
29 | - s390 architecture: | 29 | - s390 architecture: |
30 | s390 Principles of Operation manual (IBM Form. No. SA22-7832) | 30 | s390 Principles of Operation manual (IBM Form. No. SA22-7832) |
31 | - The existing Qemu code which implements a simple emulated channel | 31 | - The existing QEMU code which implements a simple emulated channel |
32 | subsystem could also be a good reference. It makes it easier to follow | 32 | subsystem could also be a good reference. It makes it easier to follow |
33 | the flow. | 33 | the flow. |
34 | qemu/hw/s390x/css.c | 34 | qemu/hw/s390x/css.c |
@@ -39,22 +39,22 @@ For vfio mediated device framework: | |||
39 | Motivation of vfio-ccw | 39 | Motivation of vfio-ccw |
40 | ---------------------- | 40 | ---------------------- |
41 | 41 | ||
42 | Currently, a guest virtualized via qemu/kvm on s390 only sees | 42 | Typically, a guest virtualized via QEMU/KVM on s390 only sees |
43 | paravirtualized virtio devices via the "Virtio Over Channel I/O | 43 | paravirtualized virtio devices via the "Virtio Over Channel I/O |
44 | (virtio-ccw)" transport. This makes virtio devices discoverable via | 44 | (virtio-ccw)" transport. This makes virtio devices discoverable via |
45 | standard operating system algorithms for handling channel devices. | 45 | standard operating system algorithms for handling channel devices. |
46 | 46 | ||
47 | However this is not enough. On s390 for the majority of devices, which | 47 | However this is not enough. On s390 for the majority of devices, which |
48 | use the standard Channel I/O based mechanism, we also need to provide | 48 | use the standard Channel I/O based mechanism, we also need to provide |
49 | the functionality of passing through them to a Qemu virtual machine. | 49 | the functionality of passing through them to a QEMU virtual machine. |
50 | This includes devices that don't have a virtio counterpart (e.g. tape | 50 | This includes devices that don't have a virtio counterpart (e.g. tape |
51 | drives) or that have specific characteristics which guests want to | 51 | drives) or that have specific characteristics which guests want to |
52 | exploit. | 52 | exploit. |
53 | 53 | ||
54 | For passing a device to a guest, we want to use the same interface as | 54 | For passing a device to a guest, we want to use the same interface as |
55 | everybody else, namely vfio. Thus, we would like to introduce vfio | 55 | everybody else, namely vfio. We implement this vfio support for channel |
56 | support for channel devices. And we would like to name this new vfio | 56 | devices via the vfio mediated device framework and the subchannel device |
57 | device "vfio-ccw". | 57 | driver "vfio_ccw". |
58 | 58 | ||
59 | Access patterns of CCW devices | 59 | Access patterns of CCW devices |
60 | ------------------------------ | 60 | ------------------------------ |
@@ -99,7 +99,7 @@ As mentioned above, we realize vfio-ccw with a mdev implementation. | |||
99 | Channel I/O does not have IOMMU hardware support, so the physical | 99 | Channel I/O does not have IOMMU hardware support, so the physical |
100 | vfio-ccw device does not have an IOMMU level translation or isolation. | 100 | vfio-ccw device does not have an IOMMU level translation or isolation. |
101 | 101 | ||
102 | Sub-channel I/O instructions are all privileged instructions, When | 102 | Subchannel I/O instructions are all privileged instructions. When |
103 | handling the I/O instruction interception, vfio-ccw has the software | 103 | handling the I/O instruction interception, vfio-ccw has the software |
104 | policing and translation how the channel program is programmed before | 104 | policing and translation how the channel program is programmed before |
105 | it gets sent to hardware. | 105 | it gets sent to hardware. |
@@ -121,7 +121,7 @@ devices: | |||
121 | - The vfio_mdev driver for the mediated vfio ccw device. | 121 | - The vfio_mdev driver for the mediated vfio ccw device. |
122 | This is provided by the mdev framework. It is a vfio device driver for | 122 | This is provided by the mdev framework. It is a vfio device driver for |
123 | the mdev that created by vfio_ccw. | 123 | the mdev that created by vfio_ccw. |
124 | It realize a group of vfio device driver callbacks, adds itself to a | 124 | It realizes a group of vfio device driver callbacks, adds itself to a |
125 | vfio group, and registers itself to the mdev framework as a mdev | 125 | vfio group, and registers itself to the mdev framework as a mdev |
126 | driver. | 126 | driver. |
127 | It uses a vfio iommu backend that uses the existing map and unmap | 127 | It uses a vfio iommu backend that uses the existing map and unmap |
@@ -178,7 +178,7 @@ vfio-ccw I/O region | |||
178 | 178 | ||
179 | An I/O region is used to accept channel program request from user | 179 | An I/O region is used to accept channel program request from user |
180 | space and store I/O interrupt result for user space to retrieve. The | 180 | space and store I/O interrupt result for user space to retrieve. The |
181 | defination of the region is: | 181 | definition of the region is: |
182 | 182 | ||
183 | struct ccw_io_region { | 183 | struct ccw_io_region { |
184 | #define ORB_AREA_SIZE 12 | 184 | #define ORB_AREA_SIZE 12 |
@@ -198,30 +198,23 @@ irb_area stores the I/O result. | |||
198 | 198 | ||
199 | ret_code stores a return code for each access of the region. | 199 | ret_code stores a return code for each access of the region. |
200 | 200 | ||
201 | vfio-ccw patches overview | 201 | vfio-ccw operation details |
202 | ------------------------- | 202 | -------------------------- |
203 | 203 | ||
204 | For now, our patches are rebased on the latest mdev implementation. | 204 | vfio-ccw follows what vfio-pci did on the s390 platform and uses |
205 | vfio-ccw follows what vfio-pci did on the s390 paltform and uses | 205 | vfio-iommu-type1 as the vfio iommu backend. |
206 | vfio-iommu-type1 as the vfio iommu backend. It's a good start to launch | ||
207 | the code review for vfio-ccw. Note that the implementation is far from | ||
208 | complete yet; but we'd like to get feedback for the general | ||
209 | architecture. | ||
210 | 206 | ||
211 | * CCW translation APIs | 207 | * CCW translation APIs |
212 | - Description: | 208 | A group of APIs (start with 'cp_') to do CCW translation. The CCWs |
213 | These introduce a group of APIs (start with 'cp_') to do CCW | 209 | passed in by a user space program are organized with their guest |
214 | translation. The CCWs passed in by a user space program are | 210 | physical memory addresses. These APIs will copy the CCWs into kernel |
215 | organized with their guest physical memory addresses. These APIs | 211 | space, and assemble a runnable kernel channel program by updating the |
216 | will copy the CCWs into the kernel space, and assemble a runnable | 212 | guest physical addresses with their corresponding host physical addresses. |
217 | kernel channel program by updating the guest physical addresses with | 213 | Note that we have to use IDALs even for direct-access CCWs, as the |
218 | their corresponding host physical addresses. | 214 | referenced memory can be located anywhere, including above 2G. |
219 | - Patches: | ||
220 | vfio: ccw: introduce channel program interfaces | ||
221 | 215 | ||
222 | * vfio_ccw device driver | 216 | * vfio_ccw device driver |
223 | - Description: | 217 | This driver utilizes the CCW translation APIs and introduces |
224 | The following patches utilizes the CCW translation APIs and introduce | ||
225 | vfio_ccw, which is the driver for the I/O subchannel devices you want | 218 | vfio_ccw, which is the driver for the I/O subchannel devices you want |
226 | to pass through. | 219 | to pass through. |
227 | vfio_ccw implements the following vfio ioctls: | 220 | vfio_ccw implements the following vfio ioctls: |
@@ -236,20 +229,14 @@ architecture. | |||
236 | This also provides the SET_IRQ ioctl to setup an event notifier to | 229 | This also provides the SET_IRQ ioctl to setup an event notifier to |
237 | notify the user space program the I/O completion in an asynchronous | 230 | notify the user space program the I/O completion in an asynchronous |
238 | way. | 231 | way. |
239 | - Patches: | 232 | |
240 | vfio: ccw: basic implementation for vfio_ccw driver | 233 | The use of vfio-ccw is not limited to QEMU, while QEMU is definitely a |
241 | vfio: ccw: introduce ccw_io_region | ||
242 | vfio: ccw: realize VFIO_DEVICE_GET_REGION_INFO ioctl | ||
243 | vfio: ccw: realize VFIO_DEVICE_RESET ioctl | ||
244 | vfio: ccw: realize VFIO_DEVICE_G(S)ET_IRQ_INFO ioctls | ||
245 | |||
246 | The user of vfio-ccw is not limited to Qemu, while Qemu is definitely a | ||
247 | good example to get understand how these patches work. Here is a little | 234 | good example to get understand how these patches work. Here is a little |
248 | bit more detail how an I/O request triggered by the Qemu guest will be | 235 | bit more detail how an I/O request triggered by the QEMU guest will be |
249 | handled (without error handling). | 236 | handled (without error handling). |
250 | 237 | ||
251 | Explanation: | 238 | Explanation: |
252 | Q1-Q7: Qemu side process. | 239 | Q1-Q7: QEMU side process. |
253 | K1-K5: Kernel side process. | 240 | K1-K5: Kernel side process. |
254 | 241 | ||
255 | Q1. Get I/O region info during initialization. | 242 | Q1. Get I/O region info during initialization. |
@@ -263,7 +250,7 @@ Q4. Write the guest channel program and ORB to the I/O region. | |||
263 | K2. Translate the guest channel program to a host kernel space | 250 | K2. Translate the guest channel program to a host kernel space |
264 | channel program, which becomes runnable for a real device. | 251 | channel program, which becomes runnable for a real device. |
265 | K3. With the necessary information contained in the orb passed in | 252 | K3. With the necessary information contained in the orb passed in |
266 | by Qemu, issue the ccwchain to the device. | 253 | by QEMU, issue the ccwchain to the device. |
267 | K4. Return the ssch CC code. | 254 | K4. Return the ssch CC code. |
268 | Q5. Return the CC code to the guest. | 255 | Q5. Return the CC code to the guest. |
269 | 256 | ||
@@ -271,7 +258,7 @@ Q5. Return the CC code to the guest. | |||
271 | 258 | ||
272 | K5. Interrupt handler gets the I/O result and write the result to | 259 | K5. Interrupt handler gets the I/O result and write the result to |
273 | the I/O region. | 260 | the I/O region. |
274 | K6. Signal Qemu to retrieve the result. | 261 | K6. Signal QEMU to retrieve the result. |
275 | Q6. Get the signal and event handler reads out the result from the I/O | 262 | Q6. Get the signal and event handler reads out the result from the I/O |
276 | region. | 263 | region. |
277 | Q7. Update the irb for the guest. | 264 | Q7. Update the irb for the guest. |
@@ -289,10 +276,20 @@ More information for DASD and ECKD could be found here: | |||
289 | https://en.wikipedia.org/wiki/Direct-access_storage_device | 276 | https://en.wikipedia.org/wiki/Direct-access_storage_device |
290 | https://en.wikipedia.org/wiki/Count_key_data | 277 | https://en.wikipedia.org/wiki/Count_key_data |
291 | 278 | ||
292 | Together with the corresponding work in Qemu, we can bring the passed | 279 | Together with the corresponding work in QEMU, we can bring the passed |
293 | through DASD/ECKD device online in a guest now and use it as a block | 280 | through DASD/ECKD device online in a guest now and use it as a block |
294 | device. | 281 | device. |
295 | 282 | ||
283 | While the current code allows the guest to start channel programs via | ||
284 | START SUBCHANNEL, support for HALT SUBCHANNEL or CLEAR SUBCHANNEL is | ||
285 | not yet implemented. | ||
286 | |||
287 | vfio-ccw supports classic (command mode) channel I/O only. Transport | ||
288 | mode (HPF) is not supported. | ||
289 | |||
290 | QDIO subchannels are currently not supported. Classic devices other than | ||
291 | DASD/ECKD might work, but have not been tested. | ||
292 | |||
296 | Reference | 293 | Reference |
297 | --------- | 294 | --------- |
298 | 1. ESA/s390 Principles of Operation manual (IBM Form. No. SA22-7832) | 295 | 1. ESA/s390 Principles of Operation manual (IBM Form. No. SA22-7832) |
diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c index c30420c517b1..ff6963ad6e39 100644 --- a/drivers/s390/cio/vfio_ccw_fsm.c +++ b/drivers/s390/cio/vfio_ccw_fsm.c | |||
@@ -124,6 +124,11 @@ static void fsm_io_request(struct vfio_ccw_private *private, | |||
124 | if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) { | 124 | if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) { |
125 | orb = (union orb *)io_region->orb_area; | 125 | orb = (union orb *)io_region->orb_area; |
126 | 126 | ||
127 | /* Don't try to build a cp if transport mode is specified. */ | ||
128 | if (orb->tm.b) { | ||
129 | io_region->ret_code = -EOPNOTSUPP; | ||
130 | goto err_out; | ||
131 | } | ||
127 | io_region->ret_code = cp_init(&private->cp, mdev_dev(mdev), | 132 | io_region->ret_code = cp_init(&private->cp, mdev_dev(mdev), |
128 | orb); | 133 | orb); |
129 | if (io_region->ret_code) | 134 | if (io_region->ret_code) |