* [PATCH] arm64: mm: Fix pfn_is_map_memory() misreporting mapped memory
@ 2026-09-08 16:20 Vladimir Murzin
2026-09-09 13:31 ` Will Deacon
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Murzin @ 2026-09-08 16:20 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: catalin.marinas, will, liulhong617
Commit 7ace06a01efa ("arm64: mm: fix accidental linear mapping of
no-map reserved memory") removed sub-page no-map regions from the
linear mapping. However, pfn_is_map_memory() can still report that
such a region is mapped.
For instance, with 64K pages, say we have
normal: ...–0xa2007fff
no-map: 0xa2008000–0xa200ffff
normal: 0xa2010000–...
The range 0xa2000000–0xa200ffff is not linearly mapped, but
pfn_is_map_memory(__phys_to_pfn(0xa2008000)) aligns the address to
page granularity and passes 0xa2000000 to memblock_is_map_memory().
That address belongs to the preceding normal memblock region, so the
no-map region is ignored and the function returns true.
Fix that by checking if entire page is subset of memory block.
Fixes: 7ace06a01efa ("arm64: mm: fix accidental linear mapping of no-map reserved memory")
Assisted-by: LLM
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---
arch/arm64/mm/init.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index fbf215ecc7d0..5da80e1e1727 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -172,7 +172,8 @@ int pfn_is_map_memory(unsigned long pfn)
if (PHYS_PFN(addr) != pfn)
return 0;
- return memblock_is_map_memory(addr);
+ return memblock_is_region_memory(addr, PAGE_SIZE) &&
+ memblock_is_map_memory(addr);
}
EXPORT_SYMBOL(pfn_is_map_memory);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: Fix pfn_is_map_memory() misreporting mapped memory
2026-09-08 16:20 [PATCH] arm64: mm: Fix pfn_is_map_memory() misreporting mapped memory Vladimir Murzin
@ 2026-09-09 13:31 ` Will Deacon
2026-09-10 13:57 ` Vladimir Murzin
0 siblings, 1 reply; 4+ messages in thread
From: Will Deacon @ 2026-09-09 13:31 UTC (permalink / raw)
To: Vladimir Murzin; +Cc: linux-arm-kernel, catalin.marinas, liulhong617, ardb
On Tue, Sep 08, 2026 at 05:20:33PM +0100, Vladimir Murzin wrote:
> Commit 7ace06a01efa ("arm64: mm: fix accidental linear mapping of
> no-map reserved memory") removed sub-page no-map regions from the
> linear mapping. However, pfn_is_map_memory() can still report that
> such a region is mapped.
>
> For instance, with 64K pages, say we have
>
> normal: ...–0xa2007fff
> no-map: 0xa2008000–0xa200ffff
> normal: 0xa2010000–...
>
> The range 0xa2000000–0xa200ffff is not linearly mapped, but
> pfn_is_map_memory(__phys_to_pfn(0xa2008000)) aligns the address to
> page granularity and passes 0xa2000000 to memblock_is_map_memory().
> That address belongs to the preceding normal memblock region, so the
> no-map region is ignored and the function returns true.
>
> Fix that by checking if entire page is subset of memory block.
>
> Fixes: 7ace06a01efa ("arm64: mm: fix accidental linear mapping of no-map reserved memory")
> Assisted-by: LLM
> Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
> ---
> arch/arm64/mm/init.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index fbf215ecc7d0..5da80e1e1727 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -172,7 +172,8 @@ int pfn_is_map_memory(unsigned long pfn)
> if (PHYS_PFN(addr) != pfn)
> return 0;
>
> - return memblock_is_map_memory(addr);
> + return memblock_is_region_memory(addr, PAGE_SIZE) &&
> + memblock_is_map_memory(addr);
> }
Yuck, this is really grotty :(
Can we at least predicate the extra memblock_is_region_memory() check on
having a page-size > 4k?
Will
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: Fix pfn_is_map_memory() misreporting mapped memory
2026-09-09 13:31 ` Will Deacon
@ 2026-09-10 13:57 ` Vladimir Murzin
2026-09-11 12:35 ` Will Deacon
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Murzin @ 2026-09-10 13:57 UTC (permalink / raw)
To: Will Deacon; +Cc: linux-arm-kernel, catalin.marinas, liulhong617, ardb
On 9/9/26 14:31, Will Deacon wrote:
> On Tue, Sep 08, 2026 at 05:20:33PM +0100, Vladimir Murzin wrote:
>> Commit 7ace06a01efa ("arm64: mm: fix accidental linear mapping of
>> no-map reserved memory") removed sub-page no-map regions from the
>> linear mapping. However, pfn_is_map_memory() can still report that
>> such a region is mapped.
>>
>> For instance, with 64K pages, say we have
>>
>> normal: ...–0xa2007fff
>> no-map: 0xa2008000–0xa200ffff
>> normal: 0xa2010000–...
>>
>> The range 0xa2000000–0xa200ffff is not linearly mapped, but
>> pfn_is_map_memory(__phys_to_pfn(0xa2008000)) aligns the address to
>> page granularity and passes 0xa2000000 to memblock_is_map_memory().
>> That address belongs to the preceding normal memblock region, so the
>> no-map region is ignored and the function returns true.
>>
>> Fix that by checking if entire page is subset of memory block.
>>
>> Fixes: 7ace06a01efa ("arm64: mm: fix accidental linear mapping of no-map reserved memory")
>> Assisted-by: LLM
>> Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
>> ---
>> arch/arm64/mm/init.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
>> index fbf215ecc7d0..5da80e1e1727 100644
>> --- a/arch/arm64/mm/init.c
>> +++ b/arch/arm64/mm/init.c
>> @@ -172,7 +172,8 @@ int pfn_is_map_memory(unsigned long pfn)
>> if (PHYS_PFN(addr) != pfn)
>> return 0;
>>
>> - return memblock_is_map_memory(addr);
>> + return memblock_is_region_memory(addr, PAGE_SIZE) &&
>> + memblock_is_map_memory(addr);
>> }
> Yuck, this is really grotty :(
>
> Can we at least predicate the extra memblock_is_region_memory() check on
> having a page-size > 4k?
>
The same can happen with 4K page size and subpage no-map and I have not seen
anything prohibiting subpage no-map ...
Cheers
Vladimir
> Will
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: Fix pfn_is_map_memory() misreporting mapped memory
2026-09-10 13:57 ` Vladimir Murzin
@ 2026-09-11 12:35 ` Will Deacon
0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2026-09-11 12:35 UTC (permalink / raw)
To: Vladimir Murzin; +Cc: linux-arm-kernel, catalin.marinas, liulhong617, ardb
On Thu, Sep 10, 2026 at 02:57:25PM +0100, Vladimir Murzin wrote:
> On 9/9/26 14:31, Will Deacon wrote:
> > On Tue, Sep 08, 2026 at 05:20:33PM +0100, Vladimir Murzin wrote:
> >> Commit 7ace06a01efa ("arm64: mm: fix accidental linear mapping of
> >> no-map reserved memory") removed sub-page no-map regions from the
> >> linear mapping. However, pfn_is_map_memory() can still report that
> >> such a region is mapped.
> >>
> >> For instance, with 64K pages, say we have
> >>
> >> normal: ...–0xa2007fff
> >> no-map: 0xa2008000–0xa200ffff
> >> normal: 0xa2010000–...
> >>
> >> The range 0xa2000000–0xa200ffff is not linearly mapped, but
> >> pfn_is_map_memory(__phys_to_pfn(0xa2008000)) aligns the address to
> >> page granularity and passes 0xa2000000 to memblock_is_map_memory().
> >> That address belongs to the preceding normal memblock region, so the
> >> no-map region is ignored and the function returns true.
> >>
> >> Fix that by checking if entire page is subset of memory block.
> >>
> >> Fixes: 7ace06a01efa ("arm64: mm: fix accidental linear mapping of no-map reserved memory")
> >> Assisted-by: LLM
> >> Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
> >> ---
> >> arch/arm64/mm/init.c | 3 ++-
> >> 1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> >> index fbf215ecc7d0..5da80e1e1727 100644
> >> --- a/arch/arm64/mm/init.c
> >> +++ b/arch/arm64/mm/init.c
> >> @@ -172,7 +172,8 @@ int pfn_is_map_memory(unsigned long pfn)
> >> if (PHYS_PFN(addr) != pfn)
> >> return 0;
> >>
> >> - return memblock_is_map_memory(addr);
> >> + return memblock_is_region_memory(addr, PAGE_SIZE) &&
> >> + memblock_is_map_memory(addr);
> >> }
> > Yuck, this is really grotty :(
> >
> > Can we at least predicate the extra memblock_is_region_memory() check on
> > having a page-size > 4k?
> >
>
> The same can happen with 4K page size and subpage no-map and I have not seen
> anything prohibiting subpage no-map ...
Ah yes, I made a similar observation during the review of the offending
commit. Oh well. Let's see what others think before we merge this.
Will
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-11 12:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 16:20 [PATCH] arm64: mm: Fix pfn_is_map_memory() misreporting mapped memory Vladimir Murzin
2026-09-09 13:31 ` Will Deacon
2026-09-10 13:57 ` Vladimir Murzin
2026-09-11 12:35 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox