Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1280286ybg; Fri, 18 Oct 2019 15:08:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9si0HwYXzyVEm9BN5E4qdcsUzGyVUvWU+kdGdlLX+/LwYHlykfHkzLpCeagQQHEpm8an1 X-Received: by 2002:a17:906:c49:: with SMTP id t9mr10987975ejf.267.1571436503057; Fri, 18 Oct 2019 15:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571436503; cv=none; d=google.com; s=arc-20160816; b=mdkRW3chuEayXPto/fl8wzI6PiYjsZyCydHgblnurALhABD+z9kr4+XgOuo2riLSZO nOMGfiwCvApBZvBPc5wlAhhycIkMhPi44Q5xjk9hqJ1r3BBmF5Ow3wsOXshgzMRd66dk hTBDrcdhXHaR+rQgGHGoAnVEDiusJEkvjkM4+IU1tnD5sK7jdC/RLN/7B7iTPSYda6sP KcJ5JoPoaddGBQYS5QTsT3VE1zz0qPREgq5LTnI41/7iFWA+NvH/dgsywu16QDyT6Fhg 7qqubP4dsbPrOsTb9HwFqveMdeRWffa6b9L/YImpuYBQs8flYAsq685dw73V/TmEJS95 pr6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=21a37jt2II3dx18r6KfoTWUT/y2eaPKVhcMYtWfTTv4=; b=lUhbYuGIoB6rLh2SLQLhXvWLYduLbltB3N9FlWlkYPiUIjG6LjcoeTOMWBAeEn2sdp KVyFWX5/86pOVtXqJsIvU/Y+vDB7WYW0P5MH4jPU6Ue/u50hM3D0mf2qjVjVVdUfL4gj gzPiUTs3AHMjPnSpvvCjVxcfXj5uqti+7iHz6yd+pHMEScuB/9Fg3fiuJoX6cdSMGaSe Jux48q27nmoMjb+Xs2FZwFieQimNpbNs5dseMbviSMd4o9zxWT7AjlTBXf8tQnI7RFCX 8fLrxL/DDoanvlfI1hBkjTZZfhwWQ1gcz1ApfQP4MvFHmIHTSPG+me6+WV/t02+Tiosc 6buA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PYSrxZsg; 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 a9si4583623edy.136.2019.10.18.15.08.00; Fri, 18 Oct 2019 15:08:23 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PYSrxZsg; 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 S2503160AbfJQRid (ORCPT + 99 others); Thu, 17 Oct 2019 13:38:33 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38360 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503129AbfJQRiX (ORCPT ); Thu, 17 Oct 2019 13:38:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=21a37jt2II3dx18r6KfoTWUT/y2eaPKVhcMYtWfTTv4=; b=PYSrxZsg8mE/e0WedJEf76y2ia x9WyUu9SA52INx6R7iStxsnRJbqFoNT31XFg9n01oaTRJtvjfypH2n3eiLkU675GZrwoG6uN7INVy UV/bnHMut6OW1sQ5NwTXolsieC0LVlsIz1COoiwVB1v962YDqOdhpplifiFAdrHWtRedbIwEwVOLv eCzb9SdL+lOLrycd4UxvSa4chGdSzIomXSQOsqazjwhZjVWx4vCzGiMJqRYC8V+nH+gNVebphwOyc s+pDC5ikmntZvPbDqfsXaDgBOT+RMQja/Pn8odpBHzU+oho6Izr5rIHGF40EUWwaK8CBmmsJAB3JO eGBZNY1Q==; Received: from [2001:4bb8:18c:d7b:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iL9jB-00089A-3v; Thu, 17 Oct 2019 17:38:21 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/15] riscv: provide a flat image loader Date: Thu, 17 Oct 2019 19:37:42 +0200 Message-Id: <20191017173743.5430-15-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017173743.5430-1-hch@lst.de> References: <20191017173743.5430-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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