Skip to contentSkip to conversation

vfio-ccw fixes

GIT PULL Cornelia Huck 2 participants 4 messages Oct 16, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

The following changes since commit fe3af62553896d2a6b13c931137406681d76c3e4:

s390: update defconfig (2017-10-16 08:19:28 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/vfio-ccw.git tags/vfio-ccw-20171016

for you to fetch changes up to 4cebc5d6a6ff41c0266d235aa4854b062d34ad09:

vfio: ccw: validate the count field of a ccw before pinning (2017-10-16 11:14:48 +0200)

----------------------------------------------------------------
Some improvements in data handling for vfio-ccw.

----------------------------------------------------------------

Dong Jia Shi (2):
vfio: ccw: bypass bad idaw address when fetching IDAL ccws
vfio: ccw: validate the count field of a ccw before pinning

 drivers/s390/cio/vfio_ccw_cp.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
Signature · 1 line
2.13.6
#1 lore raw

[PULL 1/2] vfio: ccw: bypass bad idaw address when fetching IDAL ccws

From: Dong Jia Shi <[email protected]>

We currently return the same error code (-EFAULT) to indicate two different error cases:
1. a bug in vfio-ccw implementation has been found.
2. a buggy channel program has been detected.

This brings difficulty for userland program (specifically Qemu) to handle.

Let's use -EFAULT to only indicate the first case. For the second case, we simply hand over the ccws to lower level for further handling.

Notice:
Once a bad idaw address is detected, the current behavior is to suppress the ssch. With this fix, the channel program will be accepted, and part of the channel program (the part ahead of the bad idaw) could possibly be executed by the device before I/O conclusion.

Message-Id: <[email protected]>

---
 drivers/s390/cio/vfio_ccw_cp.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/s390/cio/vfio_ccw_cp.c +0 -4
index 5ccfdc80d0ec..722f8b8c7273 100644
@@ -569,10 +569,6 @@ static int ccwchain_fetch_idal(struct ccwchain *chain,
 
 	for (i = 0; i < idaw_nr; i++) {
 		idaw_iova = *(idaws + i);
-		if (IS_ERR_VALUE(idaw_iova)) {
-			ret = -EFAULT;
-			goto out_free_idaws;
-		}
 
 		ret = pfn_array_alloc_pin(pat->pat_pa + i, cp->mdev,
 					  idaw_iova, 1);
Signature · 1 line
2.13.6
#2 lore raw

[PULL 2/2] vfio: ccw: validate the count field of a ccw before pinning

In reply to Cornelia Huck

From: Dong Jia Shi <[email protected]>

If the count field of a ccw is zero, there is no need to try to pin page(s) for it. Let's check the count value before starting pinning operations.

Message-Id: <[email protected]>

---
 drivers/s390/cio/vfio_ccw_cp.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/s390/cio/vfio_ccw_cp.c +17 -1
index 722f8b8c7273..d8f98ad9b029 100644
@@ -105,7 +105,10 @@ static int pfn_array_alloc_pin(struct pfn_array *pa, struct device *mdev,
 {
 	int ret = 0;
 
-	if (!len || pa->pa_nr)
+	if (!len)
+		return 0;
+
+	if (pa->pa_nr)
 		return -EINVAL;
 
 	pa->pa_iova = iova;
@@ -501,6 +504,16 @@ static int ccwchain_fetch_direct(struct ccwchain *chain,
 
 	ccw = chain->ch_ccw + idx;
 
+	if (!ccw->count) {
+		/*
+		 * We just want the translation result of any direct ccw
+		 * to be an IDA ccw, so let's add the IDA flag for it.
+		 * Although the flag will be ignored by firmware.
+		 */
+		ccw->flags |= CCW_FLAG_IDA;
+		return 0;
+	}
+
 	/*
 	 * Pin data page(s) in memory.
 	 * The number of pages actually is the count of the idaws which will be
@@ -541,6 +554,9 @@ static int ccwchain_fetch_idal(struct ccwchain *chain,
 
 	ccw = chain->ch_ccw + idx;
 
+	if (!ccw->count)
+		return 0;
+
 	/* Calculate size of idaws. */
 	ret = copy_from_iova(cp->mdev, &idaw_iova, ccw->cda, sizeof(idaw_iova));
 	if (ret)
Signature · 1 line
2.13.6
#3 lore raw
In reply to Cornelia Huck
Quoted 15 lines · On Mon, 16 Oct 2017 11:50:34 +0200 Cornelia Huck <[email protected]> wrote:

The following changes since commit fe3af62553896d2a6b13c931137406681d76c3e4:

s390: update defconfig (2017-10-16 08:19:28 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/vfio-ccw.git tags/vfio-ccw-20171016

for you to fetch changes up to 4cebc5d6a6ff41c0266d235aa4854b062d34ad09:

vfio: ccw: validate the count field of a ccw before pinning (2017-10-16 11:14:48 +0200)

----------------------------------------------------------------
Some improvements in data handling for vfio-ccw.

Quoted 9 lines

----------------------------------------------------------------

Dong Jia Shi (2):
vfio: ccw: bypass bad idaw address when fetching IDAL ccws
vfio: ccw: validate the count field of a ccw before pinning

 drivers/s390/cio/vfio_ccw_cp.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

The vfio update is merged and pushed to s390/linux:features. Thanks.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.