Skip to contentSkip to conversation

vfio-ccw: Fix the conversion of Format-0 CCWs to Format-1

PATCH In review Eric Farman 2 participants 3 messages Jul 2, 2019 – Jul 5, 2019

Subsystems (4)
lore
Share & tools
lore

Eric Farman

author maintainer
#0 lore raw

PATCH 1/1 vfio-ccw: Fix the conversion of Format-0 CCWs to Format-1

When processing Format-0 CCWs, we use the "len" variable as the number of CCWs to convert to Format-1. But that variable contains zero here, and is not a meaningful CCW count until ccwchain_calc_length() returns. Since that routine requires and expects Format-1 CCWs to identify the chaining behavior, the format conversion must be done first.

Convert the 2KB we copied even if it's more than we need.

Fixes 7f8e89a8f2fd ("vfio-ccw: Factor out the ccw0-to-ccw1 transition")
---
 drivers/s390/cio/vfio_ccw_cp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/vfio_ccw_cp.c +1 -1
index 9cddc1288059..a870bde10445 100644
@@ -431,7 +431,7 @@ static int ccwchain_handle_ccw(u32 cda, struct channel_program *cp)
 
 	/* Convert any Format-0 CCWs to Format-1 */
 	if (!cp->orb.cmd.fmt)
-		convert_ccw0_to_ccw1(cp->guest_cp, len);
+		convert_ccw0_to_ccw1(cp->guest_cp, CCWCHAIN_LEN_MAX);
 
 	/* Count the CCWs in the current chain */
 	len = ccwchain_calc_length(cda, cp);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Tue, 2 Jul 2019 20:09:28 +0200 Eric Farman <[email protected]> wrote:

When processing Format-0 CCWs, we use the "len" variable as the number of CCWs to convert to Format-1. But that variable contains zero here, and is not a meaningful CCW count until ccwchain_calc_length() returns. Since that routine requires and expects Format-1 CCWs to identify the chaining behavior, the format conversion must be done first.

The usage of the 'len' variable in the function is a bit confusing anyway.

Quoted 15 lines

Convert the 2KB we copied even if it's more than we need.

Fixes 7f8e89a8f2fd ("vfio-ccw: Factor out the ccw0-to-ccw1 transition")
---
 drivers/s390/cio/vfio_ccw_cp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/vfio_ccw_cp.c +0 -0
index 9cddc1288059..a870bde10445 100644

drivers/s390/cio/vfio_ccw_cp.c static int ccwchain_handle_ccw(u32 cda, struct channel_program *cp) · line 437

Quoted 8 lines
drivers/s390/cio/vfio_ccw_cp.c +1 -1
@@ -431,7 +431,7 @@ static int ccwchain_handle_ccw(u32 cda, struct channel_program *cp)
 
 	/* Convert any Format-0 CCWs to Format-1 */
 	if (!cp->orb.cmd.fmt)
-		convert_ccw0_to_ccw1(cp->guest_cp, len);
+		convert_ccw0_to_ccw1(cp->guest_cp, CCWCHAIN_LEN_MAX);
 
 	/* Count the CCWs in the current chain */
 	len = ccwchain_calc_length(cda, cp);
#2 lore raw
Quoted 34 lines · On Wed, 3 Jul 2019 11:07:04 +0200 Cornelia Huck <[email protected]> wrote:
Quoted 6 lines · On Tue, 2 Jul 2019 20:09:28 +0200 Eric Farman <[email protected]> wrote:

When processing Format-0 CCWs, we use the "len" variable as the number of CCWs to convert to Format-1. But that variable contains zero here, and is not a meaningful CCW count until ccwchain_calc_length() returns. Since that routine requires and expects Format-1 CCWs to identify the chaining behavior, the format conversion must be done first.

The usage of the 'len' variable in the function is a bit confusing anyway.

Quoted 21 lines

Convert the 2KB we copied even if it's more than we need.

Fixes 7f8e89a8f2fd ("vfio-ccw: Factor out the ccw0-to-ccw1 transition")
---
 drivers/s390/cio/vfio_ccw_cp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/vfio_ccw_cp.c +1 -1
index 9cddc1288059..a870bde10445 100644
@@ -431,7 +431,7 @@ static int ccwchain_handle_ccw(u32 cda, struct channel_program *cp)
 
 	/* Convert any Format-0 CCWs to Format-1 */
 	if (!cp->orb.cmd.fmt)
-		convert_ccw0_to_ccw1(cp->guest_cp, len);
+		convert_ccw0_to_ccw1(cp->guest_cp, CCWCHAIN_LEN_MAX);
 
Quoted 4 lines

drivers/s390/cio/vfio_ccw_cp.c static int ccwchain_handle_ccw(u32 cda, struct channel_program *cp) · line 437

Quoted 2 lines
drivers/s390/cio/vfio_ccw_cp.c +0 -0
 	/* Count the CCWs in the current chain */
 	len = ccwchain_calc_length(cda, cp);  

And queued.

I'll send a pull req for this now; we can always do a second round for the other patches.