Skip to contentSkip to conversation

idpf: IDPF + SWIOTLB Bug

RFC PATCH In review Steve Rutherford 3 participants 12 messages Feb 27 – Mar 25

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

v2 cover idpf: IDPF + SWIOTLB Bug

Found an issue with the IDPF driver when SWIOTLB is enabled. The issue results in empty headers for packets that hit the split queue workaround path. It's caused by a spurious sync in that path. The header is synced from the SWIOTLB even when the header was shoved into the payload.

I cooked up a sample patch, but I'm not an expert in this driver, so I have no idea if it's the right solution. It did allow my QEMU VM to boot with a superficially functional passed-through IDPF NIC and SWIOTLB=force.

The patch was written against COS's 6.12, so I assume that it will not apply cleanly elsewhere, but I figured a wrong sample patch was better than a long paragraph describing the same thing. My read of more recent kernels is that this problem is still present, but could be mistaken.

v2 - Updated title and tags based on feedback.

Steve Rutherford (1):
idpf: Fix header clobber in IDPF with SWIOTLB enabled

 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#1 lore raw

RFC PATCH v2 1/1 idpf: Fix header clobber in IDPF with SWIOTLB enabled

When SWIOTLB and header split are enabled, IDPF sees empty packets in the rx queue.

This is caused by libeth_rx_sync_for_cpu clobbering the synthesized header in the workaround (i.e. overflow) path. After the header is synthesized by idpf_rx_hsplit_wa, the sync call pulls from the empty SWIOTLB buffer, effectively zeroing out the buffer.

This skips the extra sync in the workaround path in most cases. The one exception is that it calls sync to trigger a recycle the header buffer when it fails to find a header in the payload.

Fixes 90912f9f4f2d1 ("idpf: convert header split mode to libeth + napi_build_skb()")
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +7 -2
index 3ddf7b1e85ef..946203a6bd86 100644
@@ -3007,9 +3007,14 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)
 			u64_stats_update_begin(&rxq->stats_sync);
 			u64_stats_inc(&rxq->q_stats.hsplit_buf_ovf);
 			u64_stats_update_end(&rxq->stats_sync);
-		}
 
-		if (libeth_rx_sync_for_cpu(hdr, hdr_len)) {
+			/* Recycle the hdr buffer if unused.*/
+			if (!hdr_len)
+				libeth_rx_sync_for_cpu(hdr, 0);
+		} else if (!libeth_rx_sync_for_cpu(hdr, hdr_len))
+			hdr_len = 0;
+
+		if (hdr_len) {
 			skb = idpf_rx_build_skb(hdr, hdr_len);
 			if (!skb)
 				break;
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
Reviewed-by on v2 1/1
#2 lore raw

RE: [Intel-wired-lan] [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

Quoted 45 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Steve Rutherford
Sent: Friday, February 27, 2026 9:35 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Lobakin, Aleksander <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Eric Dumazet <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; David Decotigny <[email protected]>; Singhai, Anjali <[email protected]>; Samudrala, Sridhar <[email protected]>; Brian Vazquez <[email protected]>; Li Li <[email protected]>; Tantilov, Emil S <[email protected]>; Steve Rutherford <[email protected]>
Subject: [Intel-wired-lan] [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

When SWIOTLB and header split are enabled, IDPF sees empty packets in the rx queue.

This is caused by libeth_rx_sync_for_cpu clobbering the synthesized header in the workaround (i.e. overflow) path. After the header is synthesized by idpf_rx_hsplit_wa, the sync call pulls from the empty SWIOTLB buffer, effectively zeroing out the buffer.

This skips the extra sync in the workaround path in most cases. The one exception is that it calls sync to trigger a recycle the header buffer when it fails to find a header in the payload.

Fixes 90912f9f4f2d1 ("idpf: convert header split mode to libeth +

napi_build_skb()")

---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0 -0
index 3ddf7b1e85ef..946203a6bd86 100644

drivers/net/ethernet/intel/idpf/idpf_txrx.c static int idpf_rx_splitq_clean(struct · line 3012

Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +1 -2
@@ -3007,9 +3007,14 @@ static int idpf_rx_splitq_clean(struct
 idpf_rx_queue *rxq, int budget)
 			u64_stats_update_begin(&rxq->stats_sync);
 			u64_stats_inc(&rxq->q_stats.hsplit_buf_ovf);
 			u64_stats_update_end(&rxq->stats_sync);
-		}
 
-		if (libeth_rx_sync_for_cpu(hdr, hdr_len)) {
+			/* Recycle the hdr buffer if unused.*/

Just a nit - please add space before */

Quoted 11 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +6 -0
+			if (!hdr_len)
+				libeth_rx_sync_for_cpu(hdr, 0);
+		} else if (!libeth_rx_sync_for_cpu(hdr, hdr_len))
+			hdr_len = 0;
+
+		if (hdr_len) {
 			skb = idpf_rx_build_skb(hdr, hdr_len);
 			if (!skb)

break;
--
2.53.0.473.g4a7958ca14-goog

#3 lore raw

Re: [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

In reply to Steve Rutherford

From: Steve Rutherford <[email protected]>
Date: Fri, 27 Feb 2026 20:34:57 +0000

Quoted 26 lines

When SWIOTLB and header split are enabled, IDPF sees empty packets in the rx queue.

This is caused by libeth_rx_sync_for_cpu clobbering the synthesized header in the workaround (i.e. overflow) path. After the header is synthesized by idpf_rx_hsplit_wa, the sync call pulls from the empty SWIOTLB buffer, effectively zeroing out the buffer.

This skips the extra sync in the workaround path in most cases. The one exception is that it calls sync to trigger a recycle the header buffer when it fails to find a header in the payload.

Fixes 90912f9f4f2d1 ("idpf: convert header split mode to libeth + napi_build_skb()")
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0 -0
index 3ddf7b1e85ef..946203a6bd86 100644
@@ -3007,9 +3007,14 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)
 			u64_stats_update_begin(&rxq->stats_sync);
 			u64_stats_inc(&rxq->q_stats.hsplit_buf_ovf);
 			u64_stats_update_end(&rxq->stats_sync);

drivers/net/ethernet/intel/idpf/idpf_txrx.c static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget) · line 3017

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +7 -2
-		}
 
-		if (libeth_rx_sync_for_cpu(hdr, hdr_len)) {
+			/* Recycle the hdr buffer if unused.*/
+			if (!hdr_len)
+				libeth_rx_sync_for_cpu(hdr, 0);
+		} else if (!libeth_rx_sync_for_cpu(hdr, hdr_len))
+			hdr_len = 0;
+
+		if (hdr_len) {

This is for a very old tree I believe? We now have libeth_xdp_process_buff() there for quite some time already.

drivers/net/ethernet/intel/idpf/idpf_txrx.c static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget) · line 3020

Quoted 3 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0 -0
 			skb = idpf_rx_build_skb(hdr, hdr_len);
 			if (!skb)
 				break;

Thanks,
Olek

#4 lore raw

Re: [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

Quoted 32 lines · Alexander Lobakin

From: Steve Rutherford <[email protected]>
Date: Fri, 27 Feb 2026 20:34:57 +0000

Quoted 28 lines

When SWIOTLB and header split are enabled, IDPF sees empty packets in the rx queue.

This is caused by libeth_rx_sync_for_cpu clobbering the synthesized header in the workaround (i.e. overflow) path. After the header is synthesized by idpf_rx_hsplit_wa, the sync call pulls from the empty SWIOTLB buffer, effectively zeroing out the buffer.

This skips the extra sync in the workaround path in most cases. The one exception is that it calls sync to trigger a recycle the header buffer when it fails to find a header in the payload.

Fixes 90912f9f4f2d1 ("idpf: convert header split mode to libeth + napi_build_skb()")
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0 -1
index 3ddf7b1e85ef..946203a6bd86 100644
@@ -3007,9 +3007,14 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)
                      u64_stats_update_begin(&rxq->stats_sync);
                      u64_stats_inc(&rxq->q_stats.hsplit_buf_ovf);
                      u64_stats_update_end(&rxq->stats_sync);
-             }
 
Quoted 11 lines

drivers/net/ethernet/intel/idpf/idpf_txrx.c static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget) · line 3017

Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +7 -1
-             if (libeth_rx_sync_for_cpu(hdr, hdr_len)) {
+                     /* Recycle the hdr buffer if unused.*/
+                     if (!hdr_len)
+                             libeth_rx_sync_for_cpu(hdr, 0);
+             } else if (!libeth_rx_sync_for_cpu(hdr, hdr_len))
+                     hdr_len = 0;
+
+             if (hdr_len) {

This is for a very old tree I believe? We now have libeth_xdp_process_buff() there for quite some time already.

It is, yeah. I thought I posted a cover letter with more of a description, but, frankly, I may have messed up the process of posting.

From the cover letter -
Found an issue with the IDPF driver when SWIOTLB is enabled. The issue results in empty headers for packets that hit the split queue workaround path. It's caused by a spurious sync in that path. The header is synced from the SWIOTLB even when the header was shoved into the payload.

I cooked up a sample patch, but I'm not an expert in this driver, so I have no idea if it's the right solution. It did allow my QEMU VM to boot with a superficially functional passed-through IDPF NIC and SWIOTLB=force.

The patch was written against COS's 6.12, so I assume that it will not apply cleanly elsewhere, but I figured a wrong sample patch was better than a long paragraph describing the same thing. My read of more recent kernels is that this problem is still present, but could be mistaken.

Thanks,
Steve

#5 lore raw

Re: [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

From: Steve Rutherford <[email protected]>
Date: Tue, 3 Mar 2026 11:44:19 -0800

Quoted 55 lines
Quoted 32 lines · Alexander Lobakin

From: Steve Rutherford <[email protected]>
Date: Fri, 27 Feb 2026 20:34:57 +0000

Quoted 28 lines

When SWIOTLB and header split are enabled, IDPF sees empty packets in the rx queue.

This is caused by libeth_rx_sync_for_cpu clobbering the synthesized header in the workaround (i.e. overflow) path. After the header is synthesized by idpf_rx_hsplit_wa, the sync call pulls from the empty SWIOTLB buffer, effectively zeroing out the buffer.

This skips the extra sync in the workaround path in most cases. The one exception is that it calls sync to trigger a recycle the header buffer when it fails to find a header in the payload.

Fixes 90912f9f4f2d1 ("idpf: convert header split mode to libeth + napi_build_skb()")
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0 -1
index 3ddf7b1e85ef..946203a6bd86 100644
@@ -3007,9 +3007,14 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)
                      u64_stats_update_begin(&rxq->stats_sync);
                      u64_stats_inc(&rxq->q_stats.hsplit_buf_ovf);
                      u64_stats_update_end(&rxq->stats_sync);
-             }
 
Quoted 11 lines

drivers/net/ethernet/intel/idpf/idpf_txrx.c static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget) · line 3017

Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +7 -1
-             if (libeth_rx_sync_for_cpu(hdr, hdr_len)) {
+                     /* Recycle the hdr buffer if unused.*/
+                     if (!hdr_len)
+                             libeth_rx_sync_for_cpu(hdr, 0);
+             } else if (!libeth_rx_sync_for_cpu(hdr, hdr_len))
+                     hdr_len = 0;
+
+             if (hdr_len) {

This is for a very old tree I believe? We now have libeth_xdp_process_buff() there for quite some time already.

It is, yeah. I thought I posted a cover letter with more of a description, but, frankly, I may have messed up the process of posting.

From the cover letter -
Found an issue with the IDPF driver when SWIOTLB is enabled. The issue results in empty headers for packets that hit the split queue workaround path. It's caused by a spurious sync in that path. The header is synced from the SWIOTLB even when the header was shoved into the payload.

Quoted 8 lines

I cooked up a sample patch, but I'm not an expert in this driver, so I have no idea if it's the right solution. It did allow my QEMU VM to boot with a superficially functional passed-through IDPF NIC and SWIOTLB=force.

The patch was written against COS's 6.12, so I assume that it will not apply cleanly elsewhere, but I figured a wrong sample patch was better than a long paragraph describing the same thing. My read of more recent kernels is that this problem is still present, but could be mistaken.

Ooops, sorry, I haven't read the cover letter =\

Did I get it correctly that in case of SWIOTLB, we can't sync the same buffer two times? But if the hsplit W/A was applied, then this double sync corrupts the data?

I'll prepare a patch for the latest net (with you as Co-developed-by or any other tag you prefer) once I find a way how to play this nicely with libeth_xdp_process_buff(). It performs an unconditional sync and bails out if it returned false.

Quoted 3 lines

Thanks,
Steve

Thanks,
Olek

#6 lore raw

Re: [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

I believe syncing twice isn't inherently wrong - it's more that you can't synthesize the header via the workaround and then sync, since it will pull the uninitialized header buffer from the SWIOTLB. Outside of SWIOTLB, dma syncs are more or less no-ops, while (with SWIOTLB) they are copies from/to the bounce buffers.

Quoted 85 lines · Alexander Lobakin

From: Steve Rutherford <[email protected]>
Date: Tue, 3 Mar 2026 11:44:19 -0800

Quoted 55 lines
Quoted 32 lines · Alexander Lobakin

From: Steve Rutherford <[email protected]>
Date: Fri, 27 Feb 2026 20:34:57 +0000

Quoted 28 lines

When SWIOTLB and header split are enabled, IDPF sees empty packets in the rx queue.

This is caused by libeth_rx_sync_for_cpu clobbering the synthesized header in the workaround (i.e. overflow) path. After the header is synthesized by idpf_rx_hsplit_wa, the sync call pulls from the empty SWIOTLB buffer, effectively zeroing out the buffer.

This skips the extra sync in the workaround path in most cases. The one exception is that it calls sync to trigger a recycle the header buffer when it fails to find a header in the payload.

Fixes 90912f9f4f2d1 ("idpf: convert header split mode to libeth + napi_build_skb()")
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0 -1
index 3ddf7b1e85ef..946203a6bd86 100644
@@ -3007,9 +3007,14 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)
                      u64_stats_update_begin(&rxq->stats_sync);
                      u64_stats_inc(&rxq->q_stats.hsplit_buf_ovf);
                      u64_stats_update_end(&rxq->stats_sync);
-             }
 
Quoted 11 lines

drivers/net/ethernet/intel/idpf/idpf_txrx.c static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget) · line 3017

Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +7 -1
-             if (libeth_rx_sync_for_cpu(hdr, hdr_len)) {
+                     /* Recycle the hdr buffer if unused.*/
+                     if (!hdr_len)
+                             libeth_rx_sync_for_cpu(hdr, 0);
+             } else if (!libeth_rx_sync_for_cpu(hdr, hdr_len))
+                     hdr_len = 0;
+
+             if (hdr_len) {

This is for a very old tree I believe? We now have libeth_xdp_process_buff() there for quite some time already.

It is, yeah. I thought I posted a cover letter with more of a description, but, frankly, I may have messed up the process of posting.

From the cover letter -
Found an issue with the IDPF driver when SWIOTLB is enabled. The issue results in empty headers for packets that hit the split queue workaround path. It's caused by a spurious sync in that path. The header is synced from the SWIOTLB even when the header was shoved into the payload.

Quoted 8 lines

I cooked up a sample patch, but I'm not an expert in this driver, so I have no idea if it's the right solution. It did allow my QEMU VM to boot with a superficially functional passed-through IDPF NIC and SWIOTLB=force.

The patch was written against COS's 6.12, so I assume that it will not apply cleanly elsewhere, but I figured a wrong sample patch was better than a long paragraph describing the same thing. My read of more recent kernels is that this problem is still present, but could be mistaken.

Ooops, sorry, I haven't read the cover letter =\

Did I get it correctly that in case of SWIOTLB, we can't sync the same buffer two times? But if the hsplit W/A was applied, then this double sync corrupts the data?

I'll prepare a patch for the latest net (with you as Co-developed-by or any other tag you prefer) once I find a way how to play this nicely with libeth_xdp_process_buff(). It performs an unconditional sync and bails out if it returned false.

Quoted 3 lines

Thanks,
Steve

Thanks,
Olek

#7 lore raw

Re: [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

From: Steve Rutherford <[email protected]>
Date: Wed, 4 Mar 2026 14:01:46 -0800

Quoted 5 lines

I believe syncing twice isn't inherently wrong - it's more that you can't synthesize the header via the workaround and then sync, since it will pull the uninitialized header buffer from the SWIOTLB. Outside of SWIOTLB, dma syncs are more or less no-ops, while (with SWIOTLB) they are copies from/to the bounce buffers.

Ah I see.

What if I add sync_for_device after copying the header? This should synchronize the bounce buffer with the copied data I guess? A bit of overhead, but this W/A triggers mostly on stuff like ARP/ICMP, "hotpath" L4 protos are fortunately not affected.

Quoted 21 lines
Quoted 18 lines · Alexander Lobakin

From: Steve Rutherford <[email protected]>
Date: Tue, 3 Mar 2026 11:44:19 -0800

Quoted 14 lines
Quoted 12 lines · Alexander Lobakin

From: Steve Rutherford <[email protected]>
Date: Fri, 27 Feb 2026 20:34:57 +0000

Quoted 8 lines

When SWIOTLB and header split are enabled, IDPF sees empty packets in the rx queue.

This is caused by libeth_rx_sync_for_cpu clobbering the synthesized header in the workaround (i.e. overflow) path. After the header is synthesized by idpf_rx_hsplit_wa, the sync call pulls from the empty SWIOTLB buffer, effectively zeroing out the buffer.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This skips the extra sync in the workaround path in most cases. The one exception is that it calls sync to trigger a recycle the header buffer when it fails to find a header in the payload.

Fixes 90912f9f4f2d1 ("idpf: convert header split mode to libeth + napi_build_skb()")

Thanks,
Olek

#8 lore raw

Re: [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

Quoted 10 lines · Alexander Lobakin

From: Steve Rutherford <[email protected]>
Date: Wed, 4 Mar 2026 14:01:46 -0800

Quoted 5 lines

I believe syncing twice isn't inherently wrong - it's more that you can't synthesize the header via the workaround and then sync, since it will pull the uninitialized header buffer from the SWIOTLB. Outside of SWIOTLB, dma syncs are more or less no-ops, while (with SWIOTLB) they are copies from/to the bounce buffers.

Quoted 6 lines

Ah I see.

What if I add sync_for_device after copying the header? This should synchronize the bounce buffer with the copied data I guess? A bit of overhead, but this W/A triggers mostly on stuff like ARP/ICMP, "hotpath" L4 protos are fortunately not affected.

That should work fine as well. I'm not certain I have strong preferences on the right answer here, other than "does it work and, ideally, is it less confusing?" The patch I posted is a bit unintuitive. I think what you are describing might make the workaround self-contained.

thanks,
Steve
[And sorry for my gmail-driven top posting crimes D: ]

#9 lore raw

Re: [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

Hey,

From: Steve Rutherford via Intel-wired-lan <[email protected]>
Date: Fri, 6 Mar 2026 11:35:27 -0800

Quoted 19 lines
Quoted 10 lines · On Fri, Mar 6, 2026 at 6:52=E2=80=AFAM Alexander Lobakin…

From: Steve Rutherford <[email protected]>
Date: Wed, 4 Mar 2026 14:01:46 -0800

Quoted 5 lines

I believe syncing twice isn't inherently wrong - it's more that you can't synthesize the header via the workaround and then sync, since it will pull the uninitialized header buffer from the SWIOTLB. Outside of SWIOTLB, dma syncs are more or less no-ops, while (with SWIOTLB) they are copies from/to the bounce buffers.

Quoted 6 lines

Ah I see.

What if I add sync_for_device after copying the header? This should synchronize the bounce buffer with the copied data I guess? A bit of overhead, but this W/A triggers mostly on stuff like ARP/ICMP, "hotpath" L4 protos are fortunately not affected.

Quoted 5 lines

That should work fine as well. I'm not certain I have strong preferences on the right answer here, other than "does it work and, ideally, is it less confusing?" The patch I posted is a bit unintuitive. I think what you are describing might make the workaround self-contained.

Could you please test this patch with SWIOTLB? If it doesn't fix the issue, you can try changing page_pool_get_dma_dir(hdr_pp) to DMA_TO_DEVICE and/or DMA_BIDIRECTIONAL. Currently, I don't have any machines with SWIOTLB unfortunately =\
Let me know if any of these works. I'll submit it properly when we have a solution.

(the patch applies cleanly to the latest net-next and should apply
to a couple older kernel releases as well)

Quoted 4 lines

thanks,
Steve
[And sorry for my gmail-driven top posting crimes D: ]

Thanks,
Olek
---

drivers/net/ethernet/intel/idpf/idpf_txrx.c +12 -7
index 45ee5b80479a..42111d56d66f 100644
@@ -3475,7 +3475,8 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
 			     struct libeth_fqe *buf, u32 data_len)
 {
 	u32 copy = data_len <= L1_CACHE_BYTES ? data_len : ETH_HLEN;
-	struct page *hdr_page, *buf_page;
+	const struct page_pool *hdr_pp;
+	dma_addr_t hdr_addr;
 	const void *src;
 	void *dst;
 
@@ -3483,16 +3484,20 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
 	    !libeth_rx_sync_for_cpu(buf, copy))
 		return 0;
 
-	hdr_page = __netmem_to_page(hdr->netmem);
-	buf_page = __netmem_to_page(buf->netmem);
-	dst = page_address(hdr_page) + hdr->offset +
-		pp_page_to_nmdesc(hdr_page)->pp->p.offset;
-	src = page_address(buf_page) + buf->offset +
-		pp_page_to_nmdesc(buf_page)->pp->p.offset;
+	hdr_pp = __netmem_get_pp(hdr->netmem);
+	dst = __netmem_address(hdr->netmem) + hdr->offset + hdr_pp->p.offset;
+	src = __netmem_address(buf->netmem) + buf->offset +
+	      __netmem_get_pp(buf->netmem)->p.offset;
 
 	memcpy(dst, src, LARGEST_ALIGN(copy));
 	buf->offset += copy;
 
+	/* Make sure SWIOTLB is synced */
+	hdr_addr = page_pool_get_dma_addr_netmem(hdr->netmem);
+	dma_sync_single_range_for_device(hdr_pp->p.dev, hdr_addr,
+					 hdr->offset + hdr_pp->p.offset,
+					 copy, page_pool_get_dma_dir(hdr_pp));
+
 	return copy;
 }
 
#10 lore raw

Re: [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

From: Alexander Lobakin <[email protected]>
Date: Thu, 12 Mar 2026 17:30:24 +0100

Quoted 30 lines

Hey,

From: Steve Rutherford via Intel-wired-lan <[email protected]>
Date: Fri, 6 Mar 2026 11:35:27 -0800

Quoted 19 lines
Quoted 10 lines · On Fri, Mar 6, 2026 at 6:52=E2=80=AFAM Alexander Lobakin…

From: Steve Rutherford <[email protected]>
Date: Wed, 4 Mar 2026 14:01:46 -0800

Quoted 5 lines

I believe syncing twice isn't inherently wrong - it's more that you can't synthesize the header via the workaround and then sync, since it will pull the uninitialized header buffer from the SWIOTLB. Outside of SWIOTLB, dma syncs are more or less no-ops, while (with SWIOTLB) they are copies from/to the bounce buffers.

Quoted 6 lines

Ah I see.

What if I add sync_for_device after copying the header? This should synchronize the bounce buffer with the copied data I guess? A bit of overhead, but this W/A triggers mostly on stuff like ARP/ICMP, "hotpath" L4 protos are fortunately not affected.

Quoted 5 lines

That should work fine as well. I'm not certain I have strong preferences on the right answer here, other than "does it work and, ideally, is it less confusing?" The patch I posted is a bit unintuitive. I think what you are describing might make the workaround self-contained.

Quoted 6 lines

Could you please test this patch with SWIOTLB? If it doesn't fix the issue, you can try changing page_pool_get_dma_dir(hdr_pp) to DMA_TO_DEVICE and/or DMA_BIDIRECTIONAL. Currently, I don't have any machines with SWIOTLB unfortunately =\
Let me know if any of these works. I'll submit it properly when we have a solution.

Any updates? I need your Tested-by in order to send this.

Quoted 42 lines

(the patch applies cleanly to the latest net-next and should apply
to a couple older kernel releases as well)

Quoted 4 lines

thanks,
Steve
[And sorry for my gmail-driven top posting crimes D: ]

Thanks,
Olek
---

drivers/net/ethernet/intel/idpf/idpf_txrx.c +6 -7
index 45ee5b80479a..42111d56d66f 100644
@@ -3475,7 +3475,8 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
 			     struct libeth_fqe *buf, u32 data_len)
 {
 	u32 copy = data_len <= L1_CACHE_BYTES ? data_len : ETH_HLEN;
-	struct page *hdr_page, *buf_page;
+	const struct page_pool *hdr_pp;
+	dma_addr_t hdr_addr;
 	const void *src;
 	void *dst;
 
@@ -3483,16 +3484,20 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
 	    !libeth_rx_sync_for_cpu(buf, copy))
 		return 0;
 
-	hdr_page = __netmem_to_page(hdr->netmem);
-	buf_page = __netmem_to_page(buf->netmem);
-	dst = page_address(hdr_page) + hdr->offset +
-		pp_page_to_nmdesc(hdr_page)->pp->p.offset;
-	src = page_address(buf_page) + buf->offset +
-		pp_page_to_nmdesc(buf_page)->pp->p.offset;
+	hdr_pp = __netmem_get_pp(hdr->netmem);
+	dst = __netmem_address(hdr->netmem) + hdr->offset + hdr_pp->p.offset;
+	src = __netmem_address(buf->netmem) + buf->offset +
+	      __netmem_get_pp(buf->netmem)->p.offset;
 
 	memcpy(dst, src, LARGEST_ALIGN(copy));

drivers/net/ethernet/intel/idpf/idpf_txrx.c static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr, · line 3502

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +6 -0
 	buf->offset += copy;
 
+	/* Make sure SWIOTLB is synced */
+	hdr_addr = page_pool_get_dma_addr_netmem(hdr->netmem);
+	dma_sync_single_range_for_device(hdr_pp->p.dev, hdr_addr,
+					 hdr->offset + hdr_pp->p.offset,
+					 copy, page_pool_get_dma_dir(hdr_pp));
+
 	return copy;
 }

Thanks,
Olek

#11 lore raw

Re: [RFC PATCHv2 1/1] idpf: Fix header clobber in IDPF with SWIOTLB enabled

Quoted 34 lines · Alexander Lobakin

From: Alexander Lobakin <[email protected]>
Date: Thu, 12 Mar 2026 17:30:24 +0100

Quoted 30 lines

Hey,

From: Steve Rutherford via Intel-wired-lan <[email protected]>
Date: Fri, 6 Mar 2026 11:35:27 -0800

Quoted 24 lines
Quoted 10 lines · On Fri, Mar 6, 2026 at 6:52=E2=80=AFAM Alexander Lobakin…

From: Steve Rutherford <[email protected]>
Date: Wed, 4 Mar 2026 14:01:46 -0800

Quoted 5 lines

I believe syncing twice isn't inherently wrong - it's more that you can't synthesize the header via the workaround and then sync, since it will pull the uninitialized header buffer from the SWIOTLB. Outside of SWIOTLB, dma syncs are more or less no-ops, while (with SWIOTLB) they are copies from/to the bounce buffers.

Quoted 6 lines

Ah I see.

What if I add sync_for_device after copying the header? This should synchronize the bounce buffer with the copied data I guess? A bit of overhead, but this W/A triggers mostly on stuff like ARP/ICMP, "hotpath" L4 protos are fortunately not affected.

That should work fine as well. I'm not certain I have strong preferences on the right answer here, other than "does it work and, ideally, is it less confusing?" The patch I posted is a bit unintuitive. I think what you are describing might make the workaround self-contained.

Quoted 8 lines
Quoted 6 lines

Could you please test this patch with SWIOTLB? If it doesn't fix the issue, you can try changing page_pool_get_dma_dir(hdr_pp) to DMA_TO_DEVICE and/or DMA_BIDIRECTIONAL. Currently, I don't have any machines with SWIOTLB unfortunately =\
Let me know if any of these works. I'll submit it properly when we have a solution.

Any updates? I need your Tested-by in order to send this.

Sorry for the delay, tried to reproduce this against a 6.18 kernel and ran into environment-specific issues with 6.18. I'll take another stab sometime this week.

thanks,
Steve

Quoted 56 lines
Quoted 43 lines

(the patch applies cleanly to the latest net-next and should apply
to a couple older kernel releases as well)

Quoted 4 lines

thanks,
Steve
[And sorry for my gmail-driven top posting crimes D: ]

Thanks,
Olek
---

drivers/net/ethernet/intel/idpf/idpf_txrx.c +6 -7
index 45ee5b80479a..42111d56d66f 100644
@@ -3475,7 +3475,8 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
                           struct libeth_fqe *buf, u32 data_len)
 {
      u32 copy = data_len <= L1_CACHE_BYTES ? data_len : ETH_HLEN;
-     struct page *hdr_page, *buf_page;
+     const struct page_pool *hdr_pp;
+     dma_addr_t hdr_addr;
      const void *src;
      void *dst;
 
@@ -3483,16 +3484,20 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
          !libeth_rx_sync_for_cpu(buf, copy))
              return 0;
 
-     hdr_page = __netmem_to_page(hdr->netmem);
-     buf_page = __netmem_to_page(buf->netmem);
-     dst = page_address(hdr_page) + hdr->offset +
-             pp_page_to_nmdesc(hdr_page)->pp->p.offset;
-     src = page_address(buf_page) + buf->offset +
-             pp_page_to_nmdesc(buf_page)->pp->p.offset;
+     hdr_pp = __netmem_get_pp(hdr->netmem);
+     dst = __netmem_address(hdr->netmem) + hdr->offset + hdr_pp->p.offset;
+     src = __netmem_address(buf->netmem) + buf->offset +
+           __netmem_get_pp(buf->netmem)->p.offset;
 
      memcpy(dst, src, LARGEST_ALIGN(copy));

drivers/net/ethernet/intel/idpf/idpf_txrx.c static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr, · line 3502

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +6 -0
      buf->offset += copy;
 
+     /* Make sure SWIOTLB is synced */
+     hdr_addr = page_pool_get_dma_addr_netmem(hdr->netmem);
+     dma_sync_single_range_for_device(hdr_pp->p.dev, hdr_addr,
+                                      hdr->offset + hdr_pp->p.offset,
+                                      copy, page_pool_get_dma_dir(hdr_pp));
+
      return copy;
 }

Thanks,
Olek