Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6311698yba; Wed, 1 May 2019 09:46:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfWPY9NTE0Ssagne7HtTf4E4Nm18bst6wJqTunHXBHHXk7PYCx8Yjt48VkrGHuCsxXoE9u X-Received: by 2002:a17:902:968c:: with SMTP id n12mr32957798plp.105.1556729162563; Wed, 01 May 2019 09:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556729162; cv=none; d=google.com; s=arc-20160816; b=cx9B/ZAXwuxcy+D5AnaYBwSRBi1D/vD0FVt8v9cYOuECZBhJ3WXXTLOoiJgfZy+CrC JI5lyHij8ruoOlbJAyC0w0Bjh3JvJZmNtgEBuen9fTahazQM0MTWVTRIXAxLEuMz+iS2 vk7z0T7GEOUHPM9xBhaE1xvYc/sJpaw4v4hz+DjLLd4qY3Dx6Q3KEwVCtFCMNZDnoyZs pClvTpZP/z6hhhCHxYHSjRk3djaxB8eEYcpo8o0c6HFzO8PTytYMjhqQqTTe3X4eteUY NTNkvPvwuoxr5RSk2y7LRh6QKRGqwbHXhP0+1zDHbTZ8b7GNE5F8MLL6Sp/HxV+jz2wV kjeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=D2u9abXCSam0aKZBpp6AjiBINirf/RfeODQo7yfhohs=; b=UOh2th1EyjhoHFFBCisIJXv4tz0xdnzKzW4A6nPlaOqNTRKCQmZxPNavkQtVXtJn25 1HnHZJCUSrtrp3EC3wAAxdjw4nZTD/rBO3LiLmXExGJfDSfNDG50yFqvG5YtlKBF8jW4 5pt+SjGVMlmL4tWbOQ7q/zkBdi07SRnM9tp5uRHmmgFzdakEEYFQpGvKRa9xaeSTi1bx kdLmNho4RLxw6pwYlvyMTB2GzemykSNjGo78UEfmZNdR6zhhffFtFsznzFi+0LgycylK UX+zpzzTjanl1o8zAYF1JhEMrS3v0F//iGAX84Zw4ZeUJ7b2ht6Dtj2mSVKJFPjzX+JC 8kgQ== ARC-Authentication-Results: i=1; mx.google.com; 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 m6si31319010pgd.78.2019.05.01.09.45.46; Wed, 01 May 2019 09:46:02 -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; 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 S1726731AbfEAQoQ (ORCPT + 99 others); Wed, 1 May 2019 12:44:16 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:37379 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726224AbfEAQoQ (ORCPT ); Wed, 1 May 2019 12:44:16 -0400 Received: from excalibur.cnev.de ([213.196.200.188]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MKKd7-1h3NB22Z3P-00Lomo; Wed, 01 May 2019 18:43:59 +0200 Received: from karsten by excalibur.cnev.de with local (Exim 4.89) (envelope-from ) id 1hLsKq-0008J7-9P; Wed, 01 May 2019 18:43:56 +0200 Date: Wed, 1 May 2019 18:43:56 +0200 From: Karsten Merker To: Atish Patra Cc: Palmer Dabbelt , "zong@andestech.com" , "anup@brainfault.org" , "linux-riscv@lists.infradead.org" , "aou@eecs.berkeley.edu" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] RISC-V: Add an Image header that boot loader can parse. Message-ID: <20190501164355.ce76wjmq6sszrf5g@excalibur.cnev.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-Provags-ID: V03:K1:gQfgRV52/wutLP5y4mCshUvfjXUXinHlk5dmAqDo68cRBMaQlCw rMRY/Jx6izGcZPqiRMaSb8TjWhuJqrPuMAF0Fn/0Q/dASGB8KEcGrzvbkC+MlFBwE54km/c LZJ1xJzk3KnHcCEUwGyz6l354+2IcaYV8khYD6vipm2Ux7lPy8qoDldT2oEghZd9pVZgYD2 OhOx/c3oYlexeVwooxJig== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:sDbHHpX80m8=:h9K1eA/AIbnevYg/2MjTYp Cz/vGhw0jx6Rtn/drvlUS4qRjpysjAndbHb5S4rgGxjUqadjr1dy+r9xhlyZWbbwA6RKLJny5 emXj7SB+er8B30aMNeU3UcEihU4EIWklCWilbUa/o7Bl26x1Kf6324T20osihtUq9FmczgszF NFIA1iwxmHl7UyjYRhZkb3XACeDAy0AWaR4kt+i1D2HVNvyIi54/jSWxQ1zP8mT2Bajnpt15Q XcTx7h9QCZ14U/tu1wk6zNUv5gb6Op+CUFu0MhEjC8OC8fHC6ASrWsCYxFABGcr0+b1VY0A4D dmxex9febOQEt0kVFfq0NI9ixcip3RnfWZE4cB703e1InyKGO5UtBwL5g01yvpFF+wzfI/1Rm /H9uyaas5JfiNXvDeomTsrk6woMDxLpsLmEZ4duR+4kezNpd06/WxhdMRQq79JPoA1HQ67F45 NRzR9IgW8blSJxg2NztAfcPNKdKGMJly6CFS+IcTA6X+40vRpTgxpfVu272dPmJHhArZCtO7R drHt+61Yw0fxHjMQ2kzmIzYKyqPtSYvPCWXMZwSF2zUarFd6mZgUeKgOHkIGvYNOpmnuwLK2c pgNe+urP0WZJAVHX6dJYvhz+FBS4Iv6Mjq0S0c3Y7ZZaQ2ET9QOfYgYeAC4reeYns4n81Vaxn KqSesOAjZMMUfmCBvYcvG465EHdp0+aCokXMRLZnY7SOwfMubkmjT5H7IxPaSUAClpaFL/wGW JzYKAewCRpDa/VDw2M5qPtv0Nq4XfZXi+kMutg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 29, 2019 at 10:42:40PM -0700, Atish Patra wrote: > On 4/29/19 4:40 PM, Palmer Dabbelt wrote: > > On Tue, 23 Apr 2019 16:25:06 PDT (-0700), atish.patra@wdc.com wrote: > > > Currently, last stage boot loaders such as U-Boot can accept only > > > uImage which is an unnecessary additional step in automating boot flows. > > > > > > Add a simple image header that boot loaders can parse and directly > > > load kernel flat Image. The existing booting methods will continue to > > > work as it is. > > > > > > Tested on both QEMU and HiFive Unleashed using OpenSBI + U-Boot + Linux. > > > > > > Signed-off-by: Atish Patra > > > --- > > > arch/riscv/include/asm/image.h | 32 ++++++++++++++++++++++++++++++++ > > > arch/riscv/kernel/head.S | 28 ++++++++++++++++++++++++++++ > > > 2 files changed, 60 insertions(+) > > > create mode 100644 arch/riscv/include/asm/image.h > > > > > > diff --git a/arch/riscv/include/asm/image.h b/arch/riscv/include/asm/image.h > > > new file mode 100644 > > > index 000000000000..76a7e0d4068a > > > --- /dev/null > > > +++ b/arch/riscv/include/asm/image.h > > > @@ -0,0 +1,32 @@ > > > +/* SPDX-License-Identifier: GPL-2.0 */ > > > + > > > +#ifndef __ASM_IMAGE_H > > > +#define __ASM_IMAGE_H > > > + > > > +#define RISCV_IMAGE_MAGIC "RISCV" > > > + > > > +#ifndef __ASSEMBLY__ > > > +/* > > > + * struct riscv_image_header - riscv kernel image header > > > + * > > > + * @code0: Executable code > > > + * @code1: Executable code > > > + * @text_offset: Image load offset > > > + * @image_size: Effective Image size > > > + * @reserved: reserved > > > + * @magic: Magic number > > > + * @reserved: reserved > > > + */ > > > + > > > +struct riscv_image_header { > > > + u32 code0; > > > + u32 code1; > > > + u64 text_offset; > > > + u64 image_size; > > > + u64 res1; > > > + u64 magic; > > > + u32 res2; > > > + u32 res3; > > > +}; > > > > I don't want to invent our own file format. Is there a reason we can't just > > use something standard? Off the top of my head I can think of ELF files and > > multiboot. > > Additional header is required to accommodate PE header format. Currently, > this is only used for booti command but it will be reused for EFI headers as > well. Linux kernel Image can pretend as an EFI application if PE/COFF header > is present. This removes the need of an explicit EFI boot loader and EFI > firmware can directly load Linux (obviously after EFI stub implementation > for RISC-V). > > ARM64 follows the similar header format as well. > https://www.kernel.org/doc/Documentation/arm64/booting.txt Hello Atish, the arm64 header looks a bit different (quoted from the aforementioned URL): u32 code0; /* Executable code */ u32 code1; /* Executable code */ u64 text_offset; /* Image load offset, little endian */ u64 image_size; /* Effective Image size, little endian */ u64 flags; /* kernel flags, little endian */ u64 res2 = 0; /* reserved */ u64 res3 = 0; /* reserved */ u64 res4 = 0; /* reserved */ u32 magic = 0x644d5241; /* Magic number, little endian, "ARM\x64" */ u32 res5; /* reserved (used for PE COFF offset) */ What I am unclear about is in which ways a RISC-V PE/COFF header differs from an arm64 one as the arm64 struct is longer than your RISC-V header and for arm64 the PE offset field is in the last field, i.e. outside of the area covered by your RISC-V structure definition. Can you perhaps explain this part in a bit more detail or does anybody else have a pointer to a specification of the RISC-V PE/COFF header format (I have found a lot of documents about COFF in general, but nothing specific to RISC-V). Regards, Karsten -- Ich widerspreche hiermit ausdrücklich der Nutzung sowie der Weitergabe meiner personenbezogenen Daten für Zwecke der Werbung sowie der Markt- oder Meinungsforschung.