Re: [PATCH v3 3/7] x86/mm: Thread pgprot_t through init_memory_mapping()
On Fri 21-02-20 11:24:59, Logan Gunthorpe wrote: > In prepartion to support a pgprot_t argument for arch_add_memory(). > > It's required to move the prototype of init_memory_mapping() seeing > the original location came before the definition of pgprot_t. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: "H. Peter Anvin" > Cc: x...@kernel.org > Cc: Dave Hansen > Cc: Andy Lutomirski > Cc: Peter Zijlstra > Signed-off-by: Logan Gunthorpe Acked-by: Michal Hocko > --- > arch/x86/include/asm/page_types.h | 3 --- > arch/x86/include/asm/pgtable.h| 3 +++ > arch/x86/kernel/amd_gart_64.c | 3 ++- > arch/x86/mm/init.c| 9 + > arch/x86/mm/init_32.c | 3 ++- > arch/x86/mm/init_64.c | 32 +-- > arch/x86/mm/mm_internal.h | 3 ++- > arch/x86/platform/uv/bios_uv.c| 3 ++- > 8 files changed, 34 insertions(+), 25 deletions(-) > > diff --git a/arch/x86/include/asm/page_types.h > b/arch/x86/include/asm/page_types.h > index c85e15010f48..bf7aa2e290ef 100644 > --- a/arch/x86/include/asm/page_types.h > +++ b/arch/x86/include/asm/page_types.h > @@ -73,9 +73,6 @@ static inline phys_addr_t get_max_mapped(void) > > bool pfn_range_is_mapped(unsigned long start_pfn, unsigned long end_pfn); > > -extern unsigned long init_memory_mapping(unsigned long start, > - unsigned long end); > - > extern void initmem_init(void); > > #endif /* !__ASSEMBLY__ */ > diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h > index 7e118660bbd9..48d6a5960f28 100644 > --- a/arch/x86/include/asm/pgtable.h > +++ b/arch/x86/include/asm/pgtable.h > @@ -1046,6 +1046,9 @@ static inline void __meminit > init_trampoline_default(void) > > void __init poking_init(void); > > +unsigned long init_memory_mapping(unsigned long start, > + unsigned long end, pgprot_t prot); > + > # ifdef CONFIG_RANDOMIZE_MEMORY > void __meminit init_trampoline(void); > # else > diff --git a/arch/x86/kernel/amd_gart_64.c b/arch/x86/kernel/amd_gart_64.c > index 4e5f50236048..16133819415c 100644 > --- a/arch/x86/kernel/amd_gart_64.c > +++ b/arch/x86/kernel/amd_gart_64.c > @@ -744,7 +744,8 @@ int __init gart_iommu_init(void) > > start_pfn = PFN_DOWN(aper_base); > if (!pfn_range_is_mapped(start_pfn, end_pfn)) > - init_memory_mapping(start_pfn< + init_memory_mapping(start_pfn< + PAGE_KERNEL); > > pr_info("PCI-DMA: using GART IOMMU.\n"); > iommu_size = check_iommu_size(info.aper_base, aper_size); > diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c > index e7bb483557c9..1bba16c5742b 100644 > --- a/arch/x86/mm/init.c > +++ b/arch/x86/mm/init.c > @@ -467,7 +467,7 @@ bool pfn_range_is_mapped(unsigned long start_pfn, > unsigned long end_pfn) > * the physical memory. To access them they are temporarily mapped. > */ > unsigned long __ref init_memory_mapping(unsigned long start, > -unsigned long end) > + unsigned long end, pgprot_t prot) > { > struct map_range mr[NR_RANGE_MR]; > unsigned long ret = 0; > @@ -481,7 +481,8 @@ unsigned long __ref init_memory_mapping(unsigned long > start, > > for (i = 0; i < nr_range; i++) > ret = kernel_physical_mapping_init(mr[i].start, mr[i].end, > -mr[i].page_size_mask); > +mr[i].page_size_mask, > +prot); > > add_pfn_range_mapped(start >> PAGE_SHIFT, ret >> PAGE_SHIFT); > > @@ -521,7 +522,7 @@ static unsigned long __init init_range_memory_mapping( >*/ > can_use_brk_pgt = max(start, (u64)pgt_buf_end<= > min(end, (u64)pgt_buf_top< - init_memory_mapping(start, end); > + init_memory_mapping(start, end, PAGE_KERNEL); > mapped_ram_size += end - start; > can_use_brk_pgt = true; > } > @@ -661,7 +662,7 @@ void __init init_mem_mapping(void) > #endif > > /* the ISA range is always mapped regardless of memory holes */ > - init_memory_mapping(0, ISA_END_ADDRESS); > + init_memory_mapping(0, ISA_END_ADDRESS, PAGE_KERNEL); > > /* Init the trampoline, possibly with KASLR memory offset */ > init_trampoline(); > diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c > index 3ec3dac7c268..e25a4218e6ff 100644 > --- a/arch/x86/mm/init_32.c > +++ b/arch/x86/mm/init_32.c > @@ -253,7 +253,8 @@ static inline int is_kernel_text(unsigned long addr) > unsigned long __init > kernel_physical_mapping_init(unsigned long start, >unsigned long end, > - unsigned long page_size_mask) > +
Re: [PATCH v3 3/7] x86/mm: Thread pgprot_t through init_memory_mapping()
On Fri, Feb 21, 2020 at 10:25 AM Logan Gunthorpe wrote: > > In prepartion to support a pgprot_t argument for arch_add_memory(). > > It's required to move the prototype of init_memory_mapping() seeing > the original location came before the definition of pgprot_t. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: "H. Peter Anvin" > Cc: x...@kernel.org > Cc: Dave Hansen > Cc: Andy Lutomirski > Cc: Peter Zijlstra > Signed-off-by: Logan Gunthorpe Looks good, checked for argument confusion, passes the nvdimm unit tests. Reviewed-by: Dan Williams
[PATCH v3 3/7] x86/mm: Thread pgprot_t through init_memory_mapping()
In prepartion to support a pgprot_t argument for arch_add_memory(). It's required to move the prototype of init_memory_mapping() seeing the original location came before the definition of pgprot_t. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: x...@kernel.org Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra Signed-off-by: Logan Gunthorpe --- arch/x86/include/asm/page_types.h | 3 --- arch/x86/include/asm/pgtable.h| 3 +++ arch/x86/kernel/amd_gart_64.c | 3 ++- arch/x86/mm/init.c| 9 + arch/x86/mm/init_32.c | 3 ++- arch/x86/mm/init_64.c | 32 +-- arch/x86/mm/mm_internal.h | 3 ++- arch/x86/platform/uv/bios_uv.c| 3 ++- 8 files changed, 34 insertions(+), 25 deletions(-) diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h index c85e15010f48..bf7aa2e290ef 100644 --- a/arch/x86/include/asm/page_types.h +++ b/arch/x86/include/asm/page_types.h @@ -73,9 +73,6 @@ static inline phys_addr_t get_max_mapped(void) bool pfn_range_is_mapped(unsigned long start_pfn, unsigned long end_pfn); -extern unsigned long init_memory_mapping(unsigned long start, -unsigned long end); - extern void initmem_init(void); #endif /* !__ASSEMBLY__ */ diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 7e118660bbd9..48d6a5960f28 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1046,6 +1046,9 @@ static inline void __meminit init_trampoline_default(void) void __init poking_init(void); +unsigned long init_memory_mapping(unsigned long start, + unsigned long end, pgprot_t prot); + # ifdef CONFIG_RANDOMIZE_MEMORY void __meminit init_trampoline(void); # else diff --git a/arch/x86/kernel/amd_gart_64.c b/arch/x86/kernel/amd_gart_64.c index 4e5f50236048..16133819415c 100644 --- a/arch/x86/kernel/amd_gart_64.c +++ b/arch/x86/kernel/amd_gart_64.c @@ -744,7 +744,8 @@ int __init gart_iommu_init(void) start_pfn = PFN_DOWN(aper_base); if (!pfn_range_is_mapped(start_pfn, end_pfn)) - init_memory_mapping(start_pfn<> PAGE_SHIFT, ret >> PAGE_SHIFT); @@ -521,7 +522,7 @@ static unsigned long __init init_range_memory_mapping( */ can_use_brk_pgt = max(start, (u64)pgt_buf_end<= min(end, (u64)pgt_buf_top<> PAGE_SHIFT, -PAGE_KERNEL_LARGE), +prot), init); spin_unlock(&init_mm.page_table_lock); paddr_last = paddr_next; @@ -669,7 +672,7 @@ phys_pud_init(pud_t *pud_page, unsigned long paddr, unsigned long paddr_end, static unsigned long __meminit phys_p4d_init(p4d_t *p4d_page, unsigned long paddr, unsigned long paddr_end, - unsigned long page_size_mask, bool init) + unsigned long page_size_mask, pgprot_t prot, bool init) { unsigned long vaddr, vaddr_end, vaddr_next, paddr_next, paddr_last; @@ -679,7 +682,7 @@ phys_p4d_init(p4d_t *p4d_page, unsigned long paddr, unsigned long paddr_end, if (!pgtable_l5_enabled()) return phys_pud_init((pud_t *) p4d_page, paddr, paddr_end, -page_size_mask, init); +page_size_mask, prot, init); for (; vaddr < vaddr_end; vaddr = vaddr_next) { p4d_t *p4d = p4d_page + p4d_index(vaddr); @@ -702,13 +705,13 @@ phys_p4d_init(p4d_t *p4d_page, unsigned long paddr, unsigned long paddr_end, if (!p4d_none(*p4d)) { pud = pud_offset(p4d, 0); paddr_last = phys_pud_init(pud, paddr, __pa(vaddr_end), - page_size_mask, init); + page_size_mask, prot, init); continue; } pud = alloc_low_page(); paddr_last = phys_pud_init(pud, paddr, __pa(vaddr_end), - page_size_mask, init); + page_size_mask, prot, init); spin_lock(&init_mm.page_table_lock); p4d_populate_init(&init_mm, p4d, pud, init); @@ -722,7 +725,7 @@ static unsigned long __meminit __kernel_physical_mapping_init(unsigned long paddr_start, unsigned long paddr_end, unsigned long page_size_mask, - bool init) + pgprot_t prot, bool init) { bool pgd_changed = false; unsigned long vaddr, vaddr_start, vaddr_end, vaddr_next, paddr_last; @@ -743,13 +746,13 @@ __kernel_physical_mapping_init(unsi