Message ID | 20210629091349.3802690-1-alex@ghiti.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] riscv: Fix memory_limit for 64-bit kernel | expand |
On 2021/6/29 17:13, Alexandre Ghiti wrote: > As described in Documentation/riscv/vm-layout.rst, the end of the > virtual address space for 64-bit kernel is occupied by the modules/BPF/ > kernel mappings so this actually reduces the amount of memory we are able > to map and then use in the linear mapping. So make sure this limit is > correctly set. > > Fixes: c9811e379b21 ("riscv: Add mem kernel parameter support") Should the Fixes tag be de043da0b9e7 (“RISC-V: Fix usage of memblock_enforce_memory_limit“), The -PAGE_OFFSET is set to the maximal physical memory from this point :) > Signed-off-by: Alexandre Ghiti <alex@ghiti.fr> > --- > arch/riscv/mm/init.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index 12f956b3a674..04a5db3a9788 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -124,10 +124,17 @@ void __init mem_init(void) > } > > /* > - * The default maximal physical memory size is -PAGE_OFFSET, > - * limit the memory size via mem. > + * The default maximal physical memory size is -PAGE_OFFSET for 32-bit kernel, > + * whereas for 64-bit kernel, the end of the virtual address space is occupied > + * by the modules/BPF/kernel mappings which reduces the available size of the > + * linear mapping. > + * Limit the memory size via mem. > */ > +#ifdef CONFIG_64BIT > +static phys_addr_t memory_limit = -PAGE_OFFSET - SZ_4G; > +#else > static phys_addr_t memory_limit = -PAGE_OFFSET; > +#endif > > static int __init early_mem(char *p) > {
Le 1/07/2021 à 12:44, Kefeng Wang a écrit : > > On 2021/6/29 17:13, Alexandre Ghiti wrote: >> As described in Documentation/riscv/vm-layout.rst, the end of the >> virtual address space for 64-bit kernel is occupied by the modules/BPF/ >> kernel mappings so this actually reduces the amount of memory we are able >> to map and then use in the linear mapping. So make sure this limit is >> correctly set. >> >> Fixes: c9811e379b21 ("riscv: Add mem kernel parameter support") > > > Should the Fixes tag be de043da0b9e7 (“RISC-V: Fix usage of > memblock_enforce_memory_limit“), > > The -PAGE_OFFSET is set to the maximal physical memory from this point :) Oops, thank you! Alex > >> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr> >> --- >> arch/riscv/mm/init.c | 11 +++++++++-- >> 1 file changed, 9 insertions(+), 2 deletions(-) >> >> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c >> index 12f956b3a674..04a5db3a9788 100644 >> --- a/arch/riscv/mm/init.c >> +++ b/arch/riscv/mm/init.c >> @@ -124,10 +124,17 @@ void __init mem_init(void) >> } >> /* >> - * The default maximal physical memory size is -PAGE_OFFSET, >> - * limit the memory size via mem. >> + * The default maximal physical memory size is -PAGE_OFFSET for >> 32-bit kernel, >> + * whereas for 64-bit kernel, the end of the virtual address space is >> occupied >> + * by the modules/BPF/kernel mappings which reduces the available >> size of the >> + * linear mapping. >> + * Limit the memory size via mem. >> */ >> +#ifdef CONFIG_64BIT >> +static phys_addr_t memory_limit = -PAGE_OFFSET - SZ_4G; >> +#else >> static phys_addr_t memory_limit = -PAGE_OFFSET; >> +#endif >> static int __init early_mem(char *p) >> { > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv
Le 1/07/2021 à 21:01, Alex Ghiti a écrit : > Le 1/07/2021 à 12:44, Kefeng Wang a écrit : >> >> On 2021/6/29 17:13, Alexandre Ghiti wrote: >>> As described in Documentation/riscv/vm-layout.rst, the end of the >>> virtual address space for 64-bit kernel is occupied by the modules/BPF/ >>> kernel mappings so this actually reduces the amount of memory we are >>> able >>> to map and then use in the linear mapping. So make sure this limit is >>> correctly set. >>> >>> Fixes: c9811e379b21 ("riscv: Add mem kernel parameter support") >> >> >> Should the Fixes tag be de043da0b9e7 (“RISC-V: Fix usage of >> memblock_enforce_memory_limit“), >> >> The -PAGE_OFFSET is set to the maximal physical memory from this point :) > > Oops, thank you! Actually the commit you mentioned was merged way before I moved the kernel to the end of the address space, so the proper Fixes tag should be: Fixes: 2bfc6cd81bd1 ("riscv: Move kernel mapping outside of linear mapping") Thanks anyway, > > Alex > >> >>> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr> >>> --- >>> arch/riscv/mm/init.c | 11 +++++++++-- >>> 1 file changed, 9 insertions(+), 2 deletions(-) >>> >>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c >>> index 12f956b3a674..04a5db3a9788 100644 >>> --- a/arch/riscv/mm/init.c >>> +++ b/arch/riscv/mm/init.c >>> @@ -124,10 +124,17 @@ void __init mem_init(void) >>> } >>> /* >>> - * The default maximal physical memory size is -PAGE_OFFSET, >>> - * limit the memory size via mem. >>> + * The default maximal physical memory size is -PAGE_OFFSET for >>> 32-bit kernel, >>> + * whereas for 64-bit kernel, the end of the virtual address space >>> is occupied >>> + * by the modules/BPF/kernel mappings which reduces the available >>> size of the >>> + * linear mapping. >>> + * Limit the memory size via mem. >>> */ >>> +#ifdef CONFIG_64BIT >>> +static phys_addr_t memory_limit = -PAGE_OFFSET - SZ_4G; >>> +#else >>> static phys_addr_t memory_limit = -PAGE_OFFSET; >>> +#endif >>> static int __init early_mem(char *p) >>> { >> >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 12f956b3a674..04a5db3a9788 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -124,10 +124,17 @@ void __init mem_init(void) } /* - * The default maximal physical memory size is -PAGE_OFFSET, - * limit the memory size via mem. + * The default maximal physical memory size is -PAGE_OFFSET for 32-bit kernel, + * whereas for 64-bit kernel, the end of the virtual address space is occupied + * by the modules/BPF/kernel mappings which reduces the available size of the + * linear mapping. + * Limit the memory size via mem. */ +#ifdef CONFIG_64BIT +static phys_addr_t memory_limit = -PAGE_OFFSET - SZ_4G; +#else static phys_addr_t memory_limit = -PAGE_OFFSET; +#endif static int __init early_mem(char *p) {
As described in Documentation/riscv/vm-layout.rst, the end of the virtual address space for 64-bit kernel is occupied by the modules/BPF/ kernel mappings so this actually reduces the amount of memory we are able to map and then use in the linear mapping. So make sure this limit is correctly set. Fixes: c9811e379b21 ("riscv: Add mem kernel parameter support") Signed-off-by: Alexandre Ghiti <alex@ghiti.fr> --- arch/riscv/mm/init.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)