Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@linux.ibm.com>
To: Anup Patel <Anup.Patel@wdc.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>,
	Palmer Dabbelt <palmer@sifive.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Christoph Hellwig <hch@infradead.org>,
	Atish Patra <Atish.Patra@wdc.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>
Subject: Re: [PATCH v2 5/5] RISC-V: Fix memory reservation in setup_bootmem()
Date: Sat, 23 Mar 2019 17:44:47 +0200	[thread overview]
Message-ID: <20190323154447.GB25149@rapoport-lnx> (raw)
In-Reply-To: <20190321094710.16552-6-anup.patel@wdc.com>

On Thu, Mar 21, 2019 at 09:47:58AM +0000, Anup Patel wrote:
> Currently, the setup_bootmem() reserves memory from RAM start to the
> kernel end. This prevents us from exploring ways to use the RAM below
> (or before) the kernel start hence this patch updates setup_bootmem()
> to only reserve memory from the kernel start to the kernel end.
> 
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> Signed-off-by: Anup Patel <anup.patel@wdc.com>
> ---
>  arch/riscv/mm/init.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 2e2f2567964c..99b42380d17d 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -18,6 +18,8 @@
>  #include <asm/pgtable.h>
>  #include <asm/io.h>
>  
> +extern char _start[];
> +
>  static void __init zone_sizes_init(void)
>  {
>  	unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
> @@ -93,15 +95,17 @@ void __init setup_bootmem(void)
>  
>  	/* Find the memory region containing the kernel */
>  	for_each_memblock(memory, reg) {
> -		phys_addr_t vmlinux_end = __pa(_end);
> +		phys_addr_t vmlinux_end = __pa(&_end);
> +		phys_addr_t vmlinux_start = __pa(&_start);
>  		phys_addr_t end = reg->base + reg->size;
>  
>  		if (reg->base <= vmlinux_end && vmlinux_end <= end) {
>  			/*
> -			 * Reserve from the start of the region to the end of
> +			 * Reserve from the start of the kernel to the end of
>  			 * the kernel
>  			 */
> -			memblock_reserve(reg->base, vmlinux_end - reg->base);
> +			memblock_reserve(vmlinux_start,
> +					 vmlinux_end - vmlinux_start);

Sorry for misleading you here, but this can be done outside the loop as
well as the calculation of vmlinux_{start,end}.

>  			mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET);
>  		}
>  	}
> @@ -177,7 +181,6 @@ struct mapping_ops {
>  
>  static inline void *__load_addr(void *ptr, uintptr_t load_pa)
>  {
> -	extern char _start;
>  	uintptr_t va = (uintptr_t)ptr;
>  	uintptr_t sz = (uintptr_t)(&_end) - (uintptr_t)(&_start);
>  
> -- 
> 2.17.1
> 

-- 
Sincerely yours,
Mike.


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

      parent reply	other threads:[~2019-03-23 15:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21  9:47 [PATCH v2 0/5] Boot RISC-V kernel from any 4KB aligned address Anup Patel
2019-03-21  9:47 ` [PATCH v2 1/5] RISC-V: Add separate defconfig for 32bit systems Anup Patel
2019-03-21  9:47 ` [PATCH v2 2/5] RISC-V: Make setup_vm() independent of GCC code model Anup Patel
2019-03-23 15:45   ` Mike Rapoport
2019-03-25  4:19     ` Anup Patel
2019-03-21  9:47 ` [PATCH v2 3/5] RISC-V: Allow booting kernel from any 4KB aligned address Anup Patel
2019-03-23 15:40   ` Mike Rapoport
2019-03-23 17:24     ` Christoph Hellwig
2019-03-24  4:16       ` Anup Patel
2019-03-24  3:32     ` Anup Patel
2019-03-21  9:47 ` [PATCH v2 4/5] RISC-V: Remove redundant trampoline page table Anup Patel
2019-03-22 13:33   ` Christoph Hellwig
2019-03-25  4:17     ` Anup Patel
2019-03-21  9:47 ` [PATCH v2 5/5] RISC-V: Fix memory reservation in setup_bootmem() Anup Patel
2019-03-22 13:31   ` Christoph Hellwig
2019-03-23 15:44   ` Mike Rapoport [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190323154447.GB25149@rapoport-lnx \
    --to=rppt@linux.ibm.com \
    --cc=Anup.Patel@wdc.com \
    --cc=Atish.Patra@wdc.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@sifive.com \
    --cc=paul.walmsley@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox