* [PATCH] arm64: mm: fix max_mapnr is assigned the wrong value
@ 2019-03-30 13:13 Muchun Song
2019-04-01 10:44 ` Catalin Marinas
0 siblings, 1 reply; 4+ messages in thread
From: Muchun Song @ 2019-03-30 13:13 UTC (permalink / raw)
To: catalin.marinas, will.deacon
Cc: f.fainelli, ard.biesheuvel, robin.murphy, david, linux-kernel,
stefan, rppt, hannes, akpm, logang, linux-arm-kernel, ghackmann
When we not use flat memory, the mem_map will be NULL and
pfn_to_page(max_pfn) is a pointer which is located in kernel space. So
max_mapnr is assigned a very large number(e.g., 0xffffxxxx_xxxxxxxx) - fix
it.
Signed-off-by: Muchun Song <smuchun@gmail.com>
---
arch/arm64/mm/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index bc02818fa48b..e86c21a44c88 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -535,7 +535,7 @@ void __init mem_init(void)
else
swiotlb_force = SWIOTLB_NO_FORCE;
- set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
+ set_max_mapnr(max_pfn - PHYS_PFN_OFFSET);
#ifndef CONFIG_SPARSEMEM_VMEMMAP
free_unused_memmap();
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: fix max_mapnr is assigned the wrong value
2019-03-30 13:13 [PATCH] arm64: mm: fix max_mapnr is assigned the wrong value Muchun Song
@ 2019-04-01 10:44 ` Catalin Marinas
2019-04-01 14:21 ` Muchun Song
0 siblings, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2019-04-01 10:44 UTC (permalink / raw)
To: Muchun Song
Cc: f.fainelli, ard.biesheuvel, robin.murphy, david, will.deacon,
linux-kernel, stefan, rppt, hannes, akpm, logang,
linux-arm-kernel, ghackmann
On Sat, Mar 30, 2019 at 09:13:46PM +0800, Muchun Song wrote:
> When we not use flat memory, the mem_map will be NULL and
> pfn_to_page(max_pfn) is a pointer which is located in kernel space. So
> max_mapnr is assigned a very large number(e.g., 0xffffxxxx_xxxxxxxx) - fix
> it.
>
> Signed-off-by: Muchun Song <smuchun@gmail.com>
> ---
> arch/arm64/mm/init.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index bc02818fa48b..e86c21a44c88 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -535,7 +535,7 @@ void __init mem_init(void)
> else
> swiotlb_force = SWIOTLB_NO_FORCE;
>
> - set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
> + set_max_mapnr(max_pfn - PHYS_PFN_OFFSET);
>
> #ifndef CONFIG_SPARSEMEM_VMEMMAP
> free_unused_memmap();
The patch looks fine but did you actually hit any problem? max_mapnr
seems to only be used in the generic pfn_valid() which we do not use on
arm64 (just wondering if it needs a cc stable; it doesn't look like as
it's not a regression).
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: fix max_mapnr is assigned the wrong value
2019-04-01 10:44 ` Catalin Marinas
@ 2019-04-01 14:21 ` Muchun Song
2019-04-01 14:32 ` Catalin Marinas
0 siblings, 1 reply; 4+ messages in thread
From: Muchun Song @ 2019-04-01 14:21 UTC (permalink / raw)
To: Catalin Marinas
Cc: Florian Fainelli, Ard Biesheuvel, robin.murphy, david,
will.deacon, linux-kernel, stefan, rppt, hannes, akpm, logang,
linux-arm-kernel, ghackmann
Hi Catalin,
Thanks for your reply. In fact, I didn't hit any problem. I just read the code
and found the problem. I see max_mapnr is to only be used in the
generic pfn_valid().
As you said, we do not use it on arm64. So in a sense, the patch is
meaningless.
But I think since it is a problem, why not fix it (Even if max_mapnr
is not be used)?
What is your opinion?
Catalin Marinas <catalin.marinas@arm.com> 于2019年4月1日周一 下午6:44写道:
>
> On Sat, Mar 30, 2019 at 09:13:46PM +0800, Muchun Song wrote:
> > When we not use flat memory, the mem_map will be NULL and
> > pfn_to_page(max_pfn) is a pointer which is located in kernel space. So
> > max_mapnr is assigned a very large number(e.g., 0xffffxxxx_xxxxxxxx) - fix
> > it.
> >
> > Signed-off-by: Muchun Song <smuchun@gmail.com>
> > ---
> > arch/arm64/mm/init.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> > index bc02818fa48b..e86c21a44c88 100644
> > --- a/arch/arm64/mm/init.c
> > +++ b/arch/arm64/mm/init.c
> > @@ -535,7 +535,7 @@ void __init mem_init(void)
> > else
> > swiotlb_force = SWIOTLB_NO_FORCE;
> >
> > - set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
> > + set_max_mapnr(max_pfn - PHYS_PFN_OFFSET);
> >
> > #ifndef CONFIG_SPARSEMEM_VMEMMAP
> > free_unused_memmap();
>
> The patch looks fine but did you actually hit any problem? max_mapnr
> seems to only be used in the generic pfn_valid() which we do not use on
> arm64 (just wondering if it needs a cc stable; it doesn't look like as
> it's not a regression).
>
> --
> Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: fix max_mapnr is assigned the wrong value
2019-04-01 14:21 ` Muchun Song
@ 2019-04-01 14:32 ` Catalin Marinas
0 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2019-04-01 14:32 UTC (permalink / raw)
To: Muchun Song
Cc: Florian Fainelli, Ard Biesheuvel, robin.murphy, david,
will.deacon, linux-kernel, stefan, rppt, hannes, akpm, logang,
linux-arm-kernel, ghackmann
On Mon, Apr 01, 2019 at 10:21:58PM +0800, Muchun Song wrote:
> Thanks for your reply. In fact, I didn't hit any problem. I just read the code
> and found the problem. I see max_mapnr is to only be used in the
> generic pfn_valid().
> As you said, we do not use it on arm64. So in a sense, the patch is
> meaningless.
>
> But I think since it is a problem, why not fix it (Even if max_mapnr
> is not be used)?
> What is your opinion?
I'm ok with fixing, only that it's not urgent. Will can pick it up for
the 5.2 merging window.
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-01 14:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-30 13:13 [PATCH] arm64: mm: fix max_mapnr is assigned the wrong value Muchun Song
2019-04-01 10:44 ` Catalin Marinas
2019-04-01 14:21 ` Muchun Song
2019-04-01 14:32 ` Catalin Marinas
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).