arm64: mm: fix max_mapnr is assigned the wrong value
PATCH 1/1 arm64: mm: fix max_mapnr is assigned the wrong value
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.
--- arch/arm64/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/mm/init.c +1 -1
@@ -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 ();
Signature · 1 line
2.17.1
Catalin Marinas
maintainerQuoted 15 lines · Muchun Song
When we not use flat memory, the
mem_mapwill be NULL andpfn_to_page(max_pfn)is a pointer which is located in kernel space. Somax_mapnris assigned a very largenumber(e.g., 0xffffxxxx_xxxxxxxx)- fix it.Signed-off-by Muchun Song <[email protected]>--- arch/arm64/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/mm/init.c +0
-0
arch/arm64/mm/init.c void __init mem_init(void) · line 541
Quoted 8 lines
arch/arm64/mm/init.c +1
-1@@ -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).
Signature · 1 line
Catalin
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?
Quoted 33 lines · Catalin Marinas <[email protected]> 于2019年4月1日周一 下午6:44写道:
Quoted 15 lines · Muchun Song
When we not use flat memory, the
mem_mapwill be NULL andpfn_to_page(max_pfn)is a pointer which is located in kernel space. Somax_mapnris assigned a very largenumber(e.g., 0xffffxxxx_xxxxxxxx)- fix it.Signed-off-by Muchun Song <[email protected]>--- arch/arm64/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/mm/init.c +0
-0arch/arm64/mm/init.c void __init mem_init(void) · line 541
Quoted 8 lines
arch/arm64/mm/init.c +1
-1@@ -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_mapnrseems to only be used in the genericpfn_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
Quoted 9 lines · Muchun Song
Thanks for your reply. In fact, I didn't hit any problem. I just read the code and found the problem. I see
max_mapnris to only be used in the genericpfn_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_mapnris 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.