Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2027619ybd; Sun, 23 Jun 2019 22:46:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXxOiT44PU5lakDwmQjfpdmC/L2UJPr7zeZYcCyrkq8UXBZ0fiPhewLYmqnYrwBbA8lKJx X-Received: by 2002:a17:902:294a:: with SMTP id g68mr149187481plb.169.1561355217765; Sun, 23 Jun 2019 22:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355217; cv=none; d=google.com; s=arc-20160816; b=gfMydY7vargZzh8ZKiY5zZKlXZf6fg45NyjNswXABz1S8EUZAAiA0RuPNjRICqQXLv lIeWQY2Um1162KBMAoBXmwRN8TdzicnXryskRqRDHo7t45CSHNVkQZesBzBNaGE98vAT WE3+KTH/2sCVeHXOVRLgHpF8ueZCqDXxNaJv/+F3iTF0lXl1gnKFAmj1hsbVGvwh0eZ6 0WNXWsNbh5Q90sYNLNNDGyglOpvX0Cfk7cuv3fY16eChTcOV64thogo55gW9C/oJp5ao Sztapkyrp7qFsItAfRORxCH8nQitSiyYXd717+dKCwdGsBoGXfF7ZWG9snJsuM7Sg0mz NX2g== 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=skB+ZnavO/i7RNPtU2wJ23sFxTsqRf+NEErVUiBdRM8=; b=mPdz4cnifLeDOF/gQopuA0EBg+wmLvB5QHasoOAJMm1sf5ShEyNxRUJK62N0h+Thak xrs0pqOAVb571+x5n5hDet9kABZGcLiN5KwzuXfcoqLkeydE7PhhNPbZVbZ8phByJUbJ j8tcyj7qjQKZ+LcG8ABXu6oPjDtaRRiUVGM5km4q4ZlJvAOnLHWxiKomtdgrOlowjc2Y 0+iKlpGg6U/C35fGd4It+WDA/YgF7ew43luAUtw+8YHcg9lH56/f0+2eQLhaTgUExHcI k0/Gsj6Etff7Stn8oP1qJ+u1ftRv0mIjFPwxP+Yflk0WRMAqQw37n7bm98dUxGW3SZUi ofTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=t+2vO2nF; 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 q18si2313170plr.108.2019.06.23.22.46.42; Sun, 23 Jun 2019 22:46:57 -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=t+2vO2nF; 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 S1727437AbfFXFnx (ORCPT + 99 others); Mon, 24 Jun 2019 01:43:53 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36642 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727409AbfFXFns (ORCPT ); Mon, 24 Jun 2019 01:43:48 -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=skB+ZnavO/i7RNPtU2wJ23sFxTsqRf+NEErVUiBdRM8=; b=t+2vO2nFTl72dJHuKdBfsPVdXB PpN4mUwQTM7uVVMBYemMWRy7TO6gT0foijMGEEFeKV4uMpaJeS7qSaL5ucgqPVCxwZrtbPlPp19Da aqyr1nEhcizmT1bqw0YevN+FGcf0/OYne3Oepy6C+pN0QROZYbNapyQkwh5WhJpTkQZiTywAon4cA r85QDsSSL1jXX30Ue8PHJp9qgNOGx/Zwc7vrTgAy5NwVztpDW8OlKMsoqOwaUNpk5k8xj3sWraNC4 RTk3jha4jQXHwplpwmyxVqldpftE7xCFg0DjpblKhPjvOPMSDLEZR4e+gDg/zk4OBHuakmfmsrQmz 3x0/tFLw==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlZ-0006UH-Uw; Mon, 24 Jun 2019 05:43:46 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/17] riscv: provide a flat entry loader Date: Mon, 24 Jun 2019 07:43:03 +0200 Message-Id: <20190624054311.30256-10-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-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 6b0741c9f348..69dbb6cb72f3 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -84,13 +84,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