Skip to content

Commit

Permalink
x86/mm: Fix marking of unused sub-pmd ranges
Browse files Browse the repository at this point in the history
The unused part precedes the new range spanned by the start, end parameters
of vmemmap_use_new_sub_pmd(). This means it actually goes from
ALIGN_DOWN(start, PMD_SIZE) up to start.

Use the correct address when applying the mark using memset.

Fixes: 8d40091 ("x86/vmemmap: handle unpopulated sub-pmd ranges")
Signed-off-by: Adrian-Ken Rueegsegger <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Oscar Salvador <[email protected]>
Reviewed-by: David Hildenbrand <[email protected]>
Cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Kensan authored and KAGA-KOKO committed May 13, 2022
1 parent c5eb0a6 commit 280abe1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/x86/mm/init_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ static void __meminit vmemmap_use_sub_pmd(unsigned long start, unsigned long end

static void __meminit vmemmap_use_new_sub_pmd(unsigned long start, unsigned long end)
{
const unsigned long page = ALIGN_DOWN(start, PMD_SIZE);

vmemmap_flush_unused_pmd();

/*
Expand All @@ -914,8 +916,7 @@ static void __meminit vmemmap_use_new_sub_pmd(unsigned long start, unsigned long
* Mark with PAGE_UNUSED the unused parts of the new memmap range
*/
if (!IS_ALIGNED(start, PMD_SIZE))
memset((void *)start, PAGE_UNUSED,
start - ALIGN_DOWN(start, PMD_SIZE));
memset((void *)page, PAGE_UNUSED, start - page);

/*
* We want to avoid memset(PAGE_UNUSED) when populating the vmemmap of
Expand Down

0 comments on commit 280abe1

Please sign in to comment.