FAILED: patch "[PATCH] s390/vfio_ccw: Ensure first IDAW remains constant" failed to apply to 6.6-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 565bef268d75bf7df665bce6923a88cd0eb74592
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026082009-hankering-carded-0ce5@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 565bef268d75bf7df665bce6923a88cd0eb74592 Mon Sep 17 00:00:00 2001
From: Eric Farman <[email protected]>
Date: Tue, 28 Jul 2026 05:30:16 +0200
Subject: [PATCH] s390/vfio_ccw: Ensure first IDAW remains constant
The first IDAW in a list does not need to be on a 2K/4K boundary like all others, and so is read separately to accurately calculate the size of the buffer needed to read the full IDAL.
Verify that the address found in the first IDAW is unchanged between reads, to ensure a consistent set of IDAWs being worked with.
drivers/s390/cio/vfio_ccw_cp.c +16 -0
@@ -523,6 +523,7 @@ static dma64_t *get_guest_idal(struct ccw1 *ccw, struct channel_program *cp, int &container_of(cp, struct vfio_ccw_private, cp)->vdev;dma64_t *idaws;dma32_t *idaws_f1; +u64 first_idaw;int idal_len = idaw_nr *sizeof (*idaws);int idaw_size =idal_is_2k (cp) ?PAGE_SIZE /2 :PAGE_SIZE ;int idaw_mask = ~(idaw_size -1 );
@@ -539,6 +540,18 @@ static dma64_t *get_guest_idal(struct ccw1 *ccw, struct channel_program *cp, intkfree (idaws);return ERR_PTR (ret); } + + idaws_f1 = (dma32_t *)idaws; +if (cp->orb.cmd.c64) + first_idaw =dma64_to_u64 (idaws[0 ]); +else + first_idaw =dma32_to_u32 (idaws_f1[0 ]); + +/* Unexpected mismatch from earlier read */ +if (first_idaw != cp->guest_iova) { +kfree (idaws); +return ERR_PTR (-EINVAL ); + } }else {/* Fabricate an IDAL based off CCW data address */ if (cp->orb.cmd.c64) {
@@ -604,6 +617,9 @@ static int ccw_count_idaws(struct ccw1 *ccw, iova =dma32_to_u32 (ccw->cda); } +/* Save the read address for later */ + cp->guest_iova = iova; +/* Format-1 IDAWs operate on 2K each */ if (!cp->orb.cmd.c64)return idal_2k_nr_words ((void *)iova, bytes);
drivers/s390/cio/vfio_ccw_cp.h +2 -0
@@ -35,6 +35,7 @@* @initialized: whether this instance is actually initialized * @guest_cp: copy of guest channel program * @ccwchain_count: number of channel program segments (linked by TIC) +* @guest_iova: first data address of a guest channel program * * @ccwchain_list is the head of a ccwchain list, that contents the * translated result of the guest channel program that pointed out by
@@ -46,6 +47,7 @@ struct channel_program {bool initialized;struct ccw1 *guest_cp;unsigned int ccwchain_count; +u64 guest_iova; };int cp_init (struct channel_program *cp,union orb *orb);
Eric Farman
maintainerPATCH 1/1 s390/vfio_ccw: Ensure first IDAW remains constant
The first IDAW in a list does not need to be on a 2K/4K boundary like all others, and so is read separately to accurately calculate the size of the buffer needed to read the full IDAL.
Verify that the address found in the first IDAW is unchanged between reads, to ensure a consistent set of IDAWs being worked with.
--- drivers/s390/cio/vfio_ccw_cp.c | 18 +++++++++++++++++- drivers/s390/cio/vfio_ccw_cp.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/s390/cio/vfio_ccw_cp.c +17 -1
@@ -478,7 +478,7 @@ static int ccwchain_loop_tic(struct ccwchain *chain, struct channel_program *cp)return 0 ; } -static int ccwchain_build_ccws (dma32_t cda,struct channel_program *cp) +static int ccwchain_build_ccws (u32 cda,struct channel_program *cp) {struct ccwchain *chain, *temp;int ret;
@@ -521,6 +521,7 @@ static unsigned long *get_guest_idal(struct ccw1 *ccw, &container_of(cp, struct vfio_ccw_private, cp)->vdev;unsigned long *idaws;unsigned int *idaws_f1; +u64 first_idaw;int idal_len = idaw_nr *sizeof (*idaws);int idaw_size =idal_is_2k (cp) ?PAGE_SIZE /2 :PAGE_SIZE ;int idaw_mask = ~(idaw_size -1 );
@@ -537,6 +538,18 @@ static unsigned long *get_guest_idal(struct ccw1 *ccw,kfree (idaws);return ERR_PTR (ret); } + + idaws_f1 = (unsigned int *)idaws; +if (cp->orb.cmd.c64) + first_idaw = idaws[0 ]; +else + first_idaw = (unsigned long )(idaws_f1[0 ]); + +/* Unexpected mismatch from earlier read */ +if (first_idaw != cp->guest_iova) { +kfree (idaws); +return ERR_PTR (-EINVAL ); + } }else {/* Fabricate an IDAL based off CCW data address */ if (cp->orb.cmd.c64) {
@@ -598,6 +611,9 @@ static int ccw_count_idaws(struct ccw1 *ccw, iova = ccw->cda; } +/* Save the read address for later */ + cp->guest_iova = iova; +/* Format-1 IDAWs operate on 2K each */ if (!cp->orb.cmd.c64)return idal_2k_nr_words ((void *)iova, bytes);
drivers/s390/cio/vfio_ccw_cp.h +2 -0
@@ -35,6 +35,7 @@* @initialized: whether this instance is actually initialized * @guest_cp: copy of guest channel program * @ccwchain_count: number of channel program segments (linked by TIC) +* @guest_iova: first data address of a guest channel program * * @ccwchain_list is the head of a ccwchain list, that contents the * translated result of the guest channel program that pointed out by
@@ -46,6 +47,7 @@ struct channel_program {bool initialized;struct ccw1 *guest_cp;unsigned int ccwchain_count; +u64 guest_iova; };int cp_init (struct channel_program *cp,union orb *orb);
Signature · 1 line
2.55.0