Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1299729ybg; Fri, 18 Oct 2019 15:28:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDnyeQtQiMFUmbbSyrzd8XsJ49Kc66CQraTZLSCVdr5zMSdxXY9lri65BtqDrjM4YDtwx3 X-Received: by 2002:a50:af44:: with SMTP id g62mr12374288edd.164.1571437685296; Fri, 18 Oct 2019 15:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571437685; cv=none; d=google.com; s=arc-20160816; b=qPcKYQa4EP9SUWau+kjbj++5Wlq6erpkHgqMMSFlAvl1kAibhUygTKcuwlym6cc7Ty NPSwlrmlXJXh5HYmyFRs7OKHeu5ZBU2CyrhSTMoiG5BKiUnc9VUWChlyOqpuNgjgDlts EqRg8M55JyPa5ILsR0i2jYysv0F7gQftLchygh93gXQQWc/raJ9z3EVwrF5UyQ0/bHBG dqs8QjfFHTLu/OckrT7zFOcAKqQvR0oV/qK5fdAIClUwTbeOFcl62pnA5WgBah8s9vCR p1/zP2gZ17TPx0NWOcJQP6BAxZpejGNhmtVhdePcJsfllmtJBJG31/TD6VeYi443Pk1S ScQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=9yj5eEKEUBkc8EGiDNUkG6uoCF1b8NJEVMhQxadJQgw=; b=J+66AGBOTbr5ZEdJGVIf+REPvVAmlN3rQUQ8Cy/EQ3HoIaEzFbC6EsfKnG1ze+loRJ owGFkhnKodWBK32mskQV8cI5L0WIyO1hVDvdMVXQWtQteUyCfNvp2bvNM+rTlgi+akXT cI2/iBxFNBopvDBZF0CQSQq8o+2HkA7mmhAoncCs8pRdvHH+5chECjJCHICgpsF2vLDZ zuuT2mAV2S/TG5mamqNVe6oiw9Trt3i2A/L5xWbmPUJS+tGpXonGPpibI7tqrQ0V70jH 6Z6EUZipt+5GvMDOEGNsqvnlvQs8QhNO3pzC+SI8gLpbccSDwgh13F20kvHPI1za5Rmr LZUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b="19h/jLrd"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f14si4936955edf.102.2019.10.18.15.27.42; Fri, 18 Oct 2019 15:28:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b="19h/jLrd"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409528AbfJRFBH (ORCPT + 99 others); Fri, 18 Oct 2019 01:01:07 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40361 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407184AbfJRFBG (ORCPT ); Fri, 18 Oct 2019 01:01:06 -0400 Received: by mail-wr1-f68.google.com with SMTP id o28so4690518wro.7 for ; Thu, 17 Oct 2019 22:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9yj5eEKEUBkc8EGiDNUkG6uoCF1b8NJEVMhQxadJQgw=; b=19h/jLrdlN0B0n8LD8ZZQQHpidcoIaOwMafQQWuaDBcFghw3DpbmISFkIZf6JbOeJY HflrdbPbT0Y81K+zDisvGr/7nGSCcI9+c9LxtNdnjeIkrttEwlV1gof5CXb5NKRTszqE Gyimc1zuhUD2XrxIxEEdFgjEOAytYe1Uwlp5zfRwNYYj/1mggw4xcTogycK4uDNiDS9C 3W9IIft16YhFIpE8CT0RvgU241dSnGZXG8JbhxF/st0rCeuLPktc9JG9eztKFdQG0GHb ONC4dNvNaHRIjqrAFPo6W5osvgrgdl5IM29T796hQ5L6voXRWbbApWvz8iMsuN1R8Vmz xPYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9yj5eEKEUBkc8EGiDNUkG6uoCF1b8NJEVMhQxadJQgw=; b=Mkum6Xs20hT95fDB9wMc9/j1vMJaR13kQWVvXFY6fdRuzNyg8rJwFyzyMI+JbbxH+q 0iSefpYYGgKg64yHW3tIKYnAqErDQZNApI6agm0DNkrsk1Kg4hsg0uMR0xfETzE0xiVn NPKGaYfRfN0WMMlQp5Sjxa7uV00pWjcFaH8mo0XMcjG/GOvAzbZMhGbj+DUBTzTysxYK YOyV4cb4NUdg8d19aeVGFBtzANNeaV8/K37/38pOpyIeTY3SK+eccSp8UP1fpXqrhPoA 07DoRonSnts1I4JtVZG8gwGIX4Aq/kr6q1fotCCgh7UsUP/fEbkLLa8BL0dId6bQg7nb cJ1Q== X-Gm-Message-State: APjAAAU9ojBLOqCYlo9ClPSGtkzfrWGovrDQ5svAn4uY0l42yNxIDO/t ezkRVyMvD+B2HKd6O00jbWbnueX1CcEJZ3sZizyPnv2ALqk= X-Received: by 2002:a5d:42c2:: with SMTP id t2mr5364797wrr.251.1571368004794; Thu, 17 Oct 2019 20:06:44 -0700 (PDT) MIME-Version: 1.0 References: <20191017173743.5430-1-hch@lst.de> <20191017173743.5430-15-hch@lst.de> In-Reply-To: <20191017173743.5430-15-hch@lst.de> From: Anup Patel Date: Fri, 18 Oct 2019 08:36:33 +0530 Message-ID: Subject: Re: [PATCH 14/15] riscv: provide a flat image loader To: Christoph Hellwig Cc: Palmer Dabbelt , Paul Walmsley , Damien Le Moal , linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 17, 2019 at 11:08 PM Christoph Hellwig wrote: > > This allows just loading the kernel at a pre-set address without > qemu going bonkers trying to map the ELF file. > > Contains a controbution from Aurabindo Jayamohanan to reuse the > PAGE_OFFSET definition. > > Signed-off-by: Christoph Hellwig > --- > arch/riscv/Makefile | 13 +++++++++---- > arch/riscv/boot/Makefile | 7 ++++++- > arch/riscv/boot/loader.S | 8 ++++++++ > arch/riscv/boot/loader.lds.S | 16 ++++++++++++++++ > 4 files changed, 39 insertions(+), 5 deletions(-) > create mode 100644 arch/riscv/boot/loader.S > create mode 100644 arch/riscv/boot/loader.lds.S > > diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile > index f5e914210245..b9009a2fbaf5 100644 > --- a/arch/riscv/Makefile > +++ b/arch/riscv/Makefile > @@ -83,13 +83,18 @@ PHONY += vdso_install > vdso_install: > $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@ > > -all: Image.gz > +ifeq ($(CONFIG_RISCV_M_MODE),y) > +KBUILD_IMAGE := $(boot)/loader > +else > +KBUILD_IMAGE := $(boot)/Image.gz > +endif > +BOOT_TARGETS := Image Image.gz loader > > -Image: vmlinux > - $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ > +all: $(notdir $(KBUILD_IMAGE)) > > -Image.%: Image > +$(BOOT_TARGETS): vmlinux > $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ > + @$(kecho) ' Kernel: $(boot)/$@ is ready' > > zinstall install: > $(Q)$(MAKE) $(build)=$(boot) $@ > diff --git a/arch/riscv/boot/Makefile b/arch/riscv/boot/Makefile > index 0990a9fdbe5d..8639e0dd2cdf 100644 > --- a/arch/riscv/boot/Makefile > +++ b/arch/riscv/boot/Makefile > @@ -16,7 +16,7 @@ > > OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S > > -targets := Image > +targets := Image loader > > $(obj)/Image: vmlinux FORCE > $(call if_changed,objcopy) > @@ -24,6 +24,11 @@ $(obj)/Image: vmlinux FORCE > $(obj)/Image.gz: $(obj)/Image FORCE > $(call if_changed,gzip) > > +loader.o: $(src)/loader.S $(obj)/Image > + > +$(obj)/loader: $(obj)/loader.o $(obj)/Image $(obj)/loader.lds FORCE > + $(Q)$(LD) -T $(src)/loader.lds -o $@ $(obj)/loader.o > + > install: > $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \ > $(obj)/Image System.map "$(INSTALL_PATH)" > diff --git a/arch/riscv/boot/loader.S b/arch/riscv/boot/loader.S > new file mode 100644 > index 000000000000..5586e2610dbb > --- /dev/null > +++ b/arch/riscv/boot/loader.S > @@ -0,0 +1,8 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > + .align 4 > + .section .payload, "ax", %progbits > + .globl _start > +_start: > + .incbin "arch/riscv/boot/Image" > + > diff --git a/arch/riscv/boot/loader.lds.S b/arch/riscv/boot/loader.lds.S > new file mode 100644 > index 000000000000..47a5003c2e28 > --- /dev/null > +++ b/arch/riscv/boot/loader.lds.S > @@ -0,0 +1,16 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +#include > + > +OUTPUT_ARCH(riscv) > +ENTRY(_start) > + > +SECTIONS > +{ > + . = PAGE_OFFSET; > + > + .payload : { > + *(.payload) > + . = ALIGN(8); > + } > +} > -- > 2.20.1 > LGTM. Reviewed-by: Anup Patel Regards, Anup