Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vfio-ccw: Enable transparent CCW IPL from DASD

Remove the explicit prefetch check when using vfio-ccw devices.
This check does not trigger in practice as all Linux channel programs
are intended to use prefetch.

It is expected that all ORBs issued by Linux will request prefetch.
Although non-prefetching ORBs are not rejected, they will prefetch
nonetheless. A warning is issued up to once per 5 seconds when a
forced prefetch occurs.

A non-prefetch ORB does not necessarily result in an error, however
frequent encounters with non-prefetch ORBs indicate that channel
programs are being executed in a way that is inconsistent with what
the guest is requesting. While there is currently no known case of an
error caused by forced prefetch, it is possible in theory that forced
prefetch could result in an error if applied to a channel program that
is dependent on non-prefetch.

Signed-off-by: Jared Rossi <jrossi@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Message-Id: <20200506212440.31323-2-jrossi@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>

authored by

Jared Rossi and committed by
Cornelia Huck
725b94d7 e1750a3d

+18 -7
+6
Documentation/s390/vfio-ccw.rst
··· 335 335 The current code allows the guest to start channel programs via 336 336 START SUBCHANNEL, and to issue HALT SUBCHANNEL and CLEAR SUBCHANNEL. 337 337 338 + Currently all channel programs are prefetched, regardless of the 339 + p-bit setting in the ORB. As a result, self modifying channel 340 + programs are not supported. For this reason, IPL has to be handled as 341 + a special case by a userspace/guest program; this has been implemented 342 + in QEMU's s390-ccw bios as of QEMU 4.1. 343 + 338 344 vfio-ccw supports classic (command mode) channel I/O only. Transport 339 345 mode (HPF) is not supported. 340 346
+12 -7
drivers/s390/cio/vfio_ccw_cp.c
··· 8 8 * Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> 9 9 */ 10 10 11 + #include <linux/ratelimit.h> 11 12 #include <linux/mm.h> 12 13 #include <linux/slab.h> 13 14 #include <linux/iommu.h> ··· 626 625 * the target channel program from @orb->cmd.iova to the new ccwchain(s). 627 626 * 628 627 * Limitations: 629 - * 1. Supports only prefetch enabled mode. 630 - * 2. Supports idal(c64) ccw chaining. 631 - * 3. Supports 4k idaw. 628 + * 1. Supports idal(c64) ccw chaining. 629 + * 2. Supports 4k idaw. 632 630 * 633 631 * Returns: 634 632 * %0 on success and a negative error value on failure. 635 633 */ 636 634 int cp_init(struct channel_program *cp, struct device *mdev, union orb *orb) 637 635 { 636 + /* custom ratelimit used to avoid flood during guest IPL */ 637 + static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 1); 638 638 int ret; 639 639 640 640 /* 641 - * XXX: 642 - * Only support prefetch enable mode now. 641 + * We only support prefetching the channel program. We assume all channel 642 + * programs executed by supported guests likewise support prefetching. 643 + * Executing a channel program that does not specify prefetching will 644 + * typically not cause an error, but a warning is issued to help identify 645 + * the problem if something does break. 643 646 */ 644 - if (!orb->cmd.pfch) 645 - return -EOPNOTSUPP; 647 + if (!orb->cmd.pfch && __ratelimit(&ratelimit_state)) 648 + dev_warn(mdev, "Prefetching channel program even though prefetch not specified in ORB"); 646 649 647 650 INIT_LIST_HEAD(&cp->ccwchain_list); 648 651 memcpy(&cp->orb, orb, sizeof(*orb));