Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1199053ybl; Tue, 13 Aug 2019 08:51:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8wFaehze6p1qQczmrgGPPUVzj1B/tuomDoNUjvS9suxEPv5uScxtRCQNkCQTNGtrrgumv X-Received: by 2002:a17:902:8d91:: with SMTP id v17mr20608825plo.88.1565711500876; Tue, 13 Aug 2019 08:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565711500; cv=none; d=google.com; s=arc-20160816; b=kkRA90qkaygSdzcfCFPmeX4VvldoBhzzFKHylTX+qpk+WbShNA7q/aArEIFWYuxvlY d7gkkTKk7RtbGTLfsSgfL8QqGo+fewSb0h1tZMBcMyHGX7Ih1Zplq4lA4h8VoDepsgvV FXz0KWM1NRkSjpztHjYWAJn1dLegMZq7Q1Ldru2D+h/9ReR9I67ATsZPoB6OY4FeQSbz I83lP7cyQBGR36RQGsJcOy9OAcXGAkMvSld2m6F+vTOox0Hu75PCJHSQKUmAZL1A8ksv dbXhUH5hsWH/VetnIR5xfp7rLwqL91s7CJS4pkjoWE85kul/NaZRMwsjq1ORph8+/R8D /nsw== 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=mDrqjntn0A722LyNZpwZDxjn4J0UQxOXPu9141wTr6M=; b=cuwX4phKfJIEcdAKWVnwKJtENtUrSPhxAf1k0YGnFPRK4NogoWbreVs3xx4xuUGWD/ Q3loLqKhiH2x2jZM0rwWd/7mlBI8Uo2L9+cN3t5rCpz0hAIpQyIlEN+znxigbJYy87tX SYLTd45MQiPiXzPULHrlqqkOvoSK+10XcVM9EMyv4KpNpwlifIlHfpRJYEA3YUCrP3lf 6jdNCZ0VfpeEuJDVhy+Xk8jaQNuDGbGCie3y5d7zBBPHQ/RYxH9TQT5wN54YoTFT4tyS RIBvBlLx9icCoGOi6Y7olxOGIEaoh+Qyfxe3GqIvk/uo/3clkDK/5koBO31Luaf6vRSw P5Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=hsRJGo1B; 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 o19si50961444pgv.497.2019.08.13.08.51.25; Tue, 13 Aug 2019 08:51:40 -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=hsRJGo1B; 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 S1730190AbfHMPsJ (ORCPT + 99 others); Tue, 13 Aug 2019 11:48:09 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44336 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730173AbfHMPsH (ORCPT ); Tue, 13 Aug 2019 11:48:07 -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=mDrqjntn0A722LyNZpwZDxjn4J0UQxOXPu9141wTr6M=; b=hsRJGo1BTc9+lrKn5go9peeJoc 8qdhFZdFt4Mu1sMyz9iZdEYGvgYN+0kr0yu8LWMRaHiF6RPa1Xc1PRKrpwXz3FwoigSmffqysGMJA qSNhhJns2yz1fC0CSzjO7UT/b1E6nu19GEV4RHRkk0xFp6/illrzFg6J0qIcJtyITlq+oOj2k9mPs g+RsnDEqgaUm/kASdQktyC1shnjVJq75w1zwWQmeLbHELZIcGZIUzMdnuFwricDUQc6QWEMSXPuCI umCL23/pKL7y5V1ag2ZJfHnMeH4a1AfYcW8LNieJUF6H9WbOGqBX6pAvXVpJ3TXr6VPRIjYqtxsUJ Apm5YEqg==; Received: from [2001:4bb8:180:1ec3:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hxZ1p-0004xF-WD; Tue, 13 Aug 2019 15:48:06 +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 06/15] riscv: provide a flat entry loader Date: Tue, 13 Aug 2019 17:47:38 +0200 Message-Id: <20190813154747.24256-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190813154747.24256-1-hch@lst.de> References: <20190813154747.24256-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. 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 | 14 ++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 arch/riscv/boot/loader.S create mode 100644 arch/riscv/boot/loader.lds diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 7a117be8297c..aa9e377400e2 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -80,13 +80,18 @@ PHONY += vdso_install vdso_install: $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@ -all: Image.gz +ifeq ($(CONFIG_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..32d2addeddba 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 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 b/arch/riscv/boot/loader.lds new file mode 100644 index 000000000000..da9efd57bf44 --- /dev/null +++ b/arch/riscv/boot/loader.lds @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +OUTPUT_ARCH(riscv) +ENTRY(_start) + +SECTIONS +{ + . = 0x80000000; + + .payload : { + *(.payload) + . = ALIGN(8); + } +} -- 2.20.1