linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nicolai Stange <nicstange@gmail.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, Nicolai Stange <nicstange@gmail.com>
Subject: [RFC 1/3] sparse-vmemmap: let vmemmap_populate_basepages() cover the whole range
Date: Wed, 15 Feb 2017 21:58:24 +0100	[thread overview]
Message-ID: <20170215205826.13356-2-nicstange@gmail.com> (raw)
In-Reply-To: <20170215205826.13356-1-nicstange@gmail.com>

vmemmap_populate_basepages() takes two memory addresses, start and end,
and attempts to populate the page range covering it.

Due to the way this is done, namely by means of a

  for (addr = start; addr < end; addr += PAGE_SIZE) {
     ...
  }

loop, this misses the last necessary page in case of

  start % PAGE_SIZE > end % PAGE_SIZE.

On x86, Kasan's initizalization in arch/x86/mm/kasan_init_64.c (ab)uses
the arch-provided vmemmap_populate() for shadow memory population.
The start and end addresses passed aren't necessarily page aligned.

With commit 7b79d10a2d64 ("mm: convert kmalloc_section_memmap() to
populate_section_memmap()"), the x86 specific vmemmap_populate() sometimes
uses the aforementioned vmemmap_populate_basepages(). This results in
non-populated shadow memory:

  BUG: unable to handle kernel paging request at ffffed0017b4d000
  IP: memset_erms+0x9/0x10
  [...]
  Call Trace:
   ? kasan_free_pages+0x50/0x60
   free_hot_cold_page+0x382/0x9e0
   [...]
   __free_pages+0xe8/0x100
   [...]
   __free_pages_bootmem+0x1c9/0x202
   ? page_alloc_init_late+0x3a/0x3a
   ? kmemleak_free_part+0x42/0x150
   free_bootmem_late+0x5f/0x7d
   efi_free_boot_services+0x10d/0x233
   [...]

Fix this by making vmemmap_populate_basepages() round the start argument
down to a multiple of PAGE_SIZE such that the above condition can never
hold.

Signed-off-by: Nicolai Stange <nicstange@gmail.com>
---
 mm/sparse-vmemmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
index 8679d4a81b98..d45bd2714a2b 100644
--- a/mm/sparse-vmemmap.c
+++ b/mm/sparse-vmemmap.c
@@ -223,7 +223,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
 int __meminit vmemmap_populate_basepages(unsigned long start,
 					 unsigned long end, int node)
 {
-	unsigned long addr = start;
+	unsigned long addr = start & ~(PAGE_SIZE - 1);
 	pgd_t *pgd;
 	pud_t *pud;
 	pmd_t *pmd;
-- 
2.11.1

--
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-02-15 20:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15 20:58 [RFC 0/3] Regressions due to 7b79d10a2d64 ("mm: convert kmalloc_section_memmap() to populate_section_memmap()") and Kasan initialization on Nicolai Stange
2017-02-15 20:58 ` Nicolai Stange [this message]
2017-02-15 20:58 ` [RFC 2/3] sparse-vmemmap: make vmemmap_populate_basepages() skip HP mapped ranges Nicolai Stange
2017-02-15 20:58 ` [RFC 3/3] sparse-vmemmap: let vmemmap_verify() ignore NUMA_NO_NODE requests Nicolai Stange
2017-02-15 21:10 ` [RFC 0/3] Regressions due to 7b79d10a2d64 ("mm: convert kmalloc_section_memmap() to populate_section_memmap()") and Kasan initialization on Andrew Morton
2017-02-15 21:26   ` Dan Williams
2017-02-15 21:54     ` Andrew Morton
2017-02-25 19:03 ` Dan Williams
2017-02-27  9:34   ` Dmitry Vyukov
2017-03-03 16:08   ` Andrey Ryabinin
2017-03-10  0:58     ` Dan Williams
2017-03-10  8:46       ` Andrey Ryabinin

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=20170215205826.13356-2-nicstange@gmail.com \
    --to=nicstange@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.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).