Skip to contentSkip to conversation

x86/pod: fix decrease_reservation() clearing of M2P entries

PATCH In review Roger Pau Monne 2 participants 4 messages Dec 10, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/pod: fix decrease_reservation() clearing of M2P entries

Add the missing index increase in the M2P clearing loop, otherwise the loop keeps pointlessly setting the same MFN entry repeatedly. This seems to be an oversight from the change that introduced support to process high order pages in one go.

Fixes 3c352011c0d3 ("x86/PoD: shorten certain operations on higher order ranges")
---
 xen/arch/x86/mm/p2m-pod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/mm/p2m-pod.c +1 -1
index 05633fe2ac88..22dde913cc3c 100644
@@ -655,7 +655,7 @@ decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order)
             }
             p2m_tlb_flush_sync(p2m);
             for ( j = 0; j < n; ++j )
-                set_gpfn_from_mfn(mfn_x(mfn), INVALID_M2P_ENTRY);
+                set_gpfn_from_mfn(mfn_x(mfn) + j, INVALID_M2P_ENTRY);
             p2m_pod_cache_add(p2m, page, cur_order);
 
             ioreq_request_mapcache_invalidate(d);
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Roger Pau Monne

Add the missing index increase in the M2P clearing loop, otherwise the loop keeps pointlessly setting the same MFN entry repeatedly. This seems to be an oversight from the change that introduced support to process high order pages in one go.

Ouch.

Quoted 2 lines
Fixes 3c352011c0d3 ("x86/PoD: shorten certain operations on higher order ranges")

I'd like to note that things were broken in the same way before that commit, too, simply because the order wasn't taken into account all. (This is not a request to change the Fixes: tag, though. It's just an observation.)

Jan

#2 lore raw
Quoted 8 lines · Jan Beulich
Quoted 4 lines · Roger Pau Monne

Add the missing index increase in the M2P clearing loop, otherwise the loop keeps pointlessly setting the same MFN entry repeatedly. This seems to be an oversight from the change that introduced support to process high order pages in one go.

Ouch.

Quoted 8 lines
Quoted 2 lines
Fixes 3c352011c0d3 ("x86/PoD: shorten certain operations on higher order ranges")

I'd like to note that things were broken in the same way before that commit, too, simply because the order wasn't taken into account all. (This is not a request to change the Fixes: tag, though. It's just an observation.)

Are you sure? Previous to that commit the order is not taken into account, and each 4K page is processed independently: the i index is strictly increased with +1 for each loop.

Thanks, Roger.

#3 lore raw
Quoted 14 lines · Roger Pau Monné
Quoted 13 lines · Jan Beulich
Quoted 4 lines · Roger Pau Monne

Add the missing index increase in the M2P clearing loop, otherwise the loop keeps pointlessly setting the same MFN entry repeatedly. This seems to be an oversight from the change that introduced support to process high order pages in one go.

Ouch.

Quoted 2 lines
Fixes 3c352011c0d3 ("x86/PoD: shorten certain operations on higher order ranges")
Quoted 7 lines
Quoted 3 lines

I'd like to note that things were broken in the same way before that commit, too, simply because the order wasn't taken into account all. (This is not a request to change the Fixes: tag, though. It's just an observation.)

Are you sure? Previous to that commit the order is not taken into account, and each 4K page is processed independently: the i index is strictly increased with +1 for each loop.

Indeed. No idea what I was thinking I was seeing.

Jan