Skip to contentSkip to conversation

ARM: mmu: skip cacheable page flushes for empty ranges

PATCH Applied Ahmad Fatoum 2 participants 2 messages Jun 20 – Jun 22 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ARM: mmu: skip cacheable page flushes for empty ranges

If we end here with a size of zero, region_end will become -1 and is a sure way to lead into confusing issues.

__arch_remap_range() skips 0-sized regions, so do likewise here, so all of arch_remap_range() is 0-size-region safe.

Reported-by Ben Pye # Matrix
Fixes b71103970c9b ("ARM: mmu: skip TLB invalidation if remapping zero bytes")

---
v1 -> v2:
- early exit instead of panic
- Add Fixes: tag

---
 arch/arm/cpu/flush_cacheable_pages.h | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/cpu/flush_cacheable_pages.h +3 -0
index a03e10810dc7..a5c54864d446 100644
@@ -28,6 +28,9 @@ static void flush_cacheable_pages(void *start, size_t size)
 	size_t block_size;
 	mmu_addr_t *ttb;
 
+	if (!size)
+		return;
+
 	region_start = PAGE_ALIGN_DOWN((ulong)start);
 	region_end = PAGE_ALIGN(region_start + size) - 1;
 
Signature · 1 line
2.47.3
Applied
#1 lore raw
Quoted 8 lines · Ahmad Fatoum

If we end here with a size of zero, region_end will become -1 and is a sure way to lead into confusing issues.

__arch_remap_range() skips 0-sized regions, so do likewise here, so all of arch_remap_range() is 0-size-region safe.

[...]

Applied, thanks!

[1/1] ARM: mmu: skip cacheable page flushes for empty ranges
https://git.pengutronix.de/cgit/barebox/commit/?id=95ff4d5058ac (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>