linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hmm: Fix calcuation of start address for unaddressable memory
@ 2017-07-17  2:22 Balbir Singh
  0 siblings, 0 replies; only message in thread
From: Balbir Singh @ 2017-07-17  2:22 UTC (permalink / raw)
  To: jglisse; +Cc: linux-mm, Balbir Singh

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

Signed-off-by: Balbir Singh <bsingharora@gmail.com>
---
 mm/hmm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index 34e1325..cc6d25c 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -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;
 
 	/*
-- 
2.9.4

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-07-17  3:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-17  2:22 [PATCH] mm/hmm: Fix calcuation of start address for unaddressable memory Balbir Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).