Skip to contentSkip to conversation

mm/hmm: Fix calcuation of start address for unaddressable memory

PATCH New Balbir Singh 1 participant 1 message Jul 17, 2017

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

PATCH 1/1 mm/hmm: Fix calcuation of start address for unaddressable memory

The code used iomem_resource.end which is an odd number and hence the calculation then moves on to addr - size + 1. When the minimum is (1ULL << MAX_PHYSMEM_BITS), the calculation of start is broken. This patch changes the calculation so that addr is on the start of a PA_SECTION_SIZE boundary

---
 mm/hmm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/hmm.c +2 -1
index 34e1325..cc6d25c 100644
@@ -1022,7 +1022,8 @@ struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops,
 		goto error_devm_add_action;
 
 	size = ALIGN(size, PA_SECTION_SIZE);
-	addr = min((unsigned long)iomem_resource.end, 1UL << MAX_PHYSMEM_BITS);
+	addr = min((unsigned long)iomem_resource.end,
+					(1UL << MAX_PHYSMEM_BITS) - 1);
 	addr = addr - size + 1UL;
 
 	/*
Signature · 7 lines
2.9.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>