Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5759296yba; Mon, 13 May 2019 17:13:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcWamVobH1OG57ftV644HWBJHWyr22bZufbfJ597BJmhrNmSC2YU7mpHGRmzJVSYwqCZXs X-Received: by 2002:a63:6f0b:: with SMTP id k11mr34358140pgc.342.1557792794002; Mon, 13 May 2019 17:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557792793; cv=none; d=google.com; s=arc-20160816; b=Z0PstQt6dBbJL4RswwUyXyTxSGOpfW/HRM9YRLf9ENphwOn90xX5s84emCu4pp4IE2 YKNGYZOzyNw5r537GWoeWKXqcwTyzJVvA0c1Xh6tw1u4wffkBl7xMrpsUeLXAzK/I8kk GgwFNTUtl2eG3CDxzXM3C2XQXmQMXXoUqFpxAxL1y5E4dV55jRQFWoQBdULO8XuVRZZA IAQE7zWlPzt4+/rqvCFBJpW4vKSUHeKdrHttX4LJRuxkc0UFWgHOKOqPsfdcdV9H+MRy 5o3Ozhi2A1/tTxOgXUw1DnQrp6yytO8hq7k7A4uW78f8ihOaka4qlLATy3TMtaO4YUfI YWHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=HphT3qTvq5UdCdGPdQO1TQeURllKBKA+AUqyDn7/1x0=; b=fOefINzu8P1Iex80GAuRKLzxW5zVnA+94rAwhRKu6mPqmfG/ZeXtNPm7YPJjMTxJus lL4i7TRD0VKFGaAExdZSROXMlZUFEO7aAcbpHuZkc09P9Sppd1M8gUsADmG8u/iez1E5 z/4YtGMjrw2L0OaabBgbuNWeOBP65umaK6Hn70s+3J/ej06lOrl/pwUoKdUDNfP+xjMI 6Sg+BWQFvZdb3eVS/60vtA9GfxdXeaalxFvOujQD4f4uRnsGF4BgEqV7QlssF8omjwhV 1SCcPwhE/lYtWgf5xRIYvhwdUHMvE3U8t3Ms2LKB3Gb8rJNKZDYgEnmDc3XJlpCZoDa5 +ugw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=CP1BLuEj; 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 h1si18517929pgc.83.2019.05.13.17.12.46; Mon, 13 May 2019 17:13:13 -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=@sifive.com header.s=google header.b=CP1BLuEj; 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 S1726764AbfENAJI (ORCPT + 99 others); Mon, 13 May 2019 20:09:08 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:53167 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726598AbfENAJI (ORCPT ); Mon, 13 May 2019 20:09:08 -0400 Received: by mail-it1-f195.google.com with SMTP id q65so2101387itg.2 for ; Mon, 13 May 2019 17:09:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=HphT3qTvq5UdCdGPdQO1TQeURllKBKA+AUqyDn7/1x0=; b=CP1BLuEj7GtUX8yOGSqFVWuCbXWttADOva4sWa9vu8tC6BQvUAYKviT6WDwvIM3O5r Etob3Moc5MxCOFv5xvTaSEOMksUNHQJg12UYNnL9s4YT/2gYGDVLSEIXAC5QOyH9j56I oBmx3V0G8BVII55FlQoe57BwP8YbgXNoBycnPU+oumsWNPizYDo2dOuuPDYlV9rlgCJO tWM3J+78NG7fMPrIFhrx9ISUolraR85pa4+9VO6nRCIisXHPHXwXqlx0DaTHDnNgm+QQ /iWNvE4qnxPh/+y8yl7DJcquptQItkx2Tw6yPnEA+c1B2QFWJmf5+K2ZZ635G1GEzDJN AlCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=HphT3qTvq5UdCdGPdQO1TQeURllKBKA+AUqyDn7/1x0=; b=ElHvqUOIcnJ7vAsc+juybHdC1Lsx8p2eh7+nCy/AiFPBDFMRnQC1GmZCdzmg1Ubura aywq/x72aRxXyCrKcA0EYEYlC6Cs6mZd8wqa78gdFsnFUTuQGc6tmGu+O81vhWw+enT5 1ndfk7awRolltbYUwt061RhdfhwvlF72rpCyxx4tEpnYqJnqPkp/PF0qSn91wsrMVsRA XPes6qkcdbSrYtNxC4v4N1A4unpOqK9D5BGq4NNmYk7XKeHURHbp+FIIHakkKB/wFgVP k1opGC6j7b/vgRnZZBgRaXIQ0iSgjs2+upnmk3S8kPX+yE0tD/B2KsY/sc7l8ZSmdEFr h/GA== X-Gm-Message-State: APjAAAU+OrnfUX0c/3ujF5xAdmC1VhBmt9IkZ8cYAPn9efXWZRk6z0vk hZSpq08KskGElLkz5irtkRTC1A== X-Received: by 2002:a02:1dc7:: with SMTP id 190mr19786726jaj.62.1557792547471; Mon, 13 May 2019 17:09:07 -0700 (PDT) Received: from localhost (c-73-95-159-87.hsd1.co.comcast.net. [73.95.159.87]) by smtp.gmail.com with ESMTPSA id e2sm456547ith.39.2019.05.13.17.09.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 17:09:06 -0700 (PDT) Date: Mon, 13 May 2019 17:09:06 -0700 (PDT) From: Paul Walmsley X-X-Sender: paulw@viisi.sifive.com To: Atish Patra cc: Paul Walmsley , "linux-kernel@vger.kernel.org" , "mark.rutland@arm.com" , Albert Ou , Anup Patel , Palmer Dabbelt , Zong Li , "merker@debian.org" , "linux-riscv@lists.infradead.org" Subject: Re: [v2 PATCH] RISC-V: Add a PE/COFF compliant Image header. In-Reply-To: Message-ID: References: <20190501195607.32553-1-atish.patra@wdc.com> User-Agent: Alpine 2.21.9999 (DEB 301 2018-08-15) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 13 May 2019, Atish Patra wrote: > On 5/13/19 3:31 PM, Paul Walmsley wrote: > > On Wed, 1 May 2019, Atish Patra 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 PE/COFF compliant image header that boot loaders can parse and > > > directly load kernel flat Image. The existing booting methods will > > > continue > > > to work as it is. > > > > > > Another goal of this header is to support EFI stub for RISC-V in future. > > > EFI specification needs PE/COFF image header in the beginning of the > > > kernel > > > image in order to load it as an EFI application. In order to support > > > EFI stub, code0 should be replaced with "MZ" magic string and res5(at > > > offset 0x3c) should point to the rest of the PE/COFF header (which will > > > be added during EFI support). > > > > > > Tested on both QEMU and HiFive Unleashed using OpenSBI + U-Boot + Linux. > > > > > > Signed-off-by: Atish Patra > > > > Seems like we're stuck with this basic format for EFI, etc. Even though > > we may be stuck with it, I think we should take the opportunity to add the > > possibility to extending this header format by adding fields after the > > basic PE/COFF header ends. > > > > In particular, at the very least, I'd suggest adding a u32 after the > > PE/COFF header ends, to represent a "RISC-V header format version number". > > Then if we add more fields that follow the PE/COFF header -- for example, > > to represent the RISC-V instruction set extensions that are required to > > run this binary -- we can just bump that RISC-V-specific version number > > field to indicate to bootloaders that there's more there. > > > That would be inventing our RISC-V specific header format. However, we > can always use the one of the reserved fields in proposed header (res4) > for this purpose. What are the semantics of those reserved fields? > Do we need to add it now or add it later when we actually need a version > number. My preference is to add it later based on requirement. If it isn't added now, how would bootloaders know whether it was there or not? - Paul