linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <bsingharora@gmail.com>
To: jglisse@redhat.com
Cc: linux-mm@kvack.org, Balbir Singh <bsingharora@gmail.com>
Subject: [PATCH] mm/hmm: Fix calcuation of start address for unaddressable memory
Date: Mon, 17 Jul 2017 12:22:23 +1000	[thread overview]
Message-ID: <20170717022223.23603-1-bsingharora@gmail.com> (raw)

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>

                 reply	other threads:[~2017-07-17  3:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170717022223.23603-1-bsingharora@gmail.com \
    --to=bsingharora@gmail.com \
    --cc=jglisse@redhat.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).