* Re: [PATCH] x86/mm: Fix marking of unused sub-pmd ranges
2022-05-09 9:06 ` [PATCH] x86/mm: Fix marking of unused sub-pmd ranges Adrian-Ken Rueegsegger
@ 2022-05-12 9:04 ` David Hildenbrand
2022-05-12 16:54 ` Thomas Gleixner
2022-05-13 7:36 ` Oscar Salvador
2022-05-13 10:44 ` [tip: x86/urgent] " tip-bot2 for Adrian-Ken Rueegsegger
2 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2022-05-12 9:04 UTC (permalink / raw)
To: Adrian-Ken Rueegsegger, dave.hansen, osalvador
Cc: luto, peterz, tglx, mingo, bp, hpa, x86, linux-kernel
On 09.05.22 11:06, Adrian-Ken Rueegsegger wrote:
> 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: 8d400913c231 ("x86/vmemmap: handle unpopulated sub-pmd ranges")
> Signed-off-by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
> ---
> arch/x86/mm/init_64.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 96d34ebb20a9..e2942335d143 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -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();
>
> /*
> @@ -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
As the x86 code was based on my s390x code, I assume that this was
accidentally introduced in the x86 variant.
We'd be marking the wrong range PAGE_UNUSED.
Your fix looks correct to me:
Reviewed-by: David Hildenbrand <david@redhat.com>
Do we want to cc stable?
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] x86/mm: Fix marking of unused sub-pmd ranges
2022-05-12 9:04 ` David Hildenbrand
@ 2022-05-12 16:54 ` Thomas Gleixner
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Gleixner @ 2022-05-12 16:54 UTC (permalink / raw)
To: David Hildenbrand, Adrian-Ken Rueegsegger, dave.hansen, osalvador
Cc: luto, peterz, mingo, bp, hpa, x86, linux-kernel
On Thu, May 12 2022 at 11:04, David Hildenbrand wrote:
> On 09.05.22 11:06, Adrian-Ken Rueegsegger wrote:
>> 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();
>>
>> /*
>> @@ -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
>
> As the x86 code was based on my s390x code, I assume that this was
> accidentally introduced in the x86 variant.
>
> We'd be marking the wrong range PAGE_UNUSED.
>
> Your fix looks correct to me:
>
> Reviewed-by: David Hildenbrand <david@redhat.com>
>
> Do we want to cc stable?
Yes, we'll add it when picking it up.
I really have to ask why this duplicated code exists in the first
place. There is zero architecture specific code neither in the s390 nor
in the x86 version.
The x86 version is just copy & pasta & fatfinger, if I'm not missing
something here.
Thanks,
tglx
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86/mm: Fix marking of unused sub-pmd ranges
2022-05-09 9:06 ` [PATCH] x86/mm: Fix marking of unused sub-pmd ranges Adrian-Ken Rueegsegger
2022-05-12 9:04 ` David Hildenbrand
@ 2022-05-13 7:36 ` Oscar Salvador
2022-05-13 10:44 ` [tip: x86/urgent] " tip-bot2 for Adrian-Ken Rueegsegger
2 siblings, 0 replies; 6+ messages in thread
From: Oscar Salvador @ 2022-05-13 7:36 UTC (permalink / raw)
To: Adrian-Ken Rueegsegger
Cc: dave.hansen, david, luto, peterz, tglx, mingo, bp, hpa, x86,
linux-kernel
On 2022-05-09 11:06, Adrian-Ken Rueegsegger wrote:
> 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: 8d400913c231 ("x86/vmemmap: handle unpopulated sub-pmd ranges")
> Signed-off-by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
Yes, this was clearly an oversight from my side.
Thanks for fixing it!
Reviewed-by: Oscar Salvador <osalvador@suse.de>
> ---
> arch/x86/mm/init_64.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 96d34ebb20a9..e2942335d143 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -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();
>
> /*
> @@ -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
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread* [tip: x86/urgent] x86/mm: Fix marking of unused sub-pmd ranges
2022-05-09 9:06 ` [PATCH] x86/mm: Fix marking of unused sub-pmd ranges Adrian-Ken Rueegsegger
2022-05-12 9:04 ` David Hildenbrand
2022-05-13 7:36 ` Oscar Salvador
@ 2022-05-13 10:44 ` tip-bot2 for Adrian-Ken Rueegsegger
2 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Adrian-Ken Rueegsegger @ 2022-05-13 10:44 UTC (permalink / raw)
To: linux-tip-commits
Cc: Adrian-Ken Rueegsegger, Thomas Gleixner, Oscar Salvador,
David Hildenbrand, stable, x86, linux-kernel
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 280abe14b6e0a38de9cc86fe6a019523aadd8f70
Gitweb: https://git.kernel.org/tip/280abe14b6e0a38de9cc86fe6a019523aadd8f70
Author: Adrian-Ken Rueegsegger <ken@codelabs.ch>
AuthorDate: Mon, 09 May 2022 11:06:37 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 13 May 2022 12:41:21 +02:00
x86/mm: Fix marking of unused sub-pmd ranges
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: 8d400913c231 ("x86/vmemmap: handle unpopulated sub-pmd ranges")
Signed-off-by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220509090637.24152-2-ken@codelabs.ch
---
arch/x86/mm/init_64.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 96d34eb..e294233 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -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();
/*
@@ -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
^ permalink raw reply related [flat|nested] 6+ messages in thread