Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp244224rwb; Thu, 6 Oct 2022 17:50:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6oQFHowPdPK3Nh8RERK1+G1theJNXqhuT/Lmt/HcLZjHNdYlrP+GNtwdcIsSr3GFXuk2Jf X-Received: by 2002:a17:90b:1648:b0:203:c8d3:99b0 with SMTP id il8-20020a17090b164800b00203c8d399b0mr13575056pjb.54.1665103811499; Thu, 06 Oct 2022 17:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665103811; cv=none; d=google.com; s=arc-20160816; b=jgVuX76Q/HV25Y1KtQ8VabCSUMEVyX7WgpRxwYv4mOsN9nvGm4kEYKvvwfotA16vVy Dek9stpJ9cFc4yi1c8dWZQcQN6DaoDQNhgWKM577CtyWnEMK6Q0EkrP4KZXFrRFAdDEh wWXeeDgHRbLOVu8kzd07w2lcMsg+ajkoN28viGKKpwOWyeOMkxvMniZaU7dIYvMzFOTD EeP0EitUuRvb0C/7sjyfVvVb8kXfPj6qTkVye9q0DUfqYnd4y4HVQXfRvkl9FBP2n/vJ gd02B7TuPdVbuXo7uMRY1pMb/2F7xbWppBJK6BFCl6keOvlS/VJcS1k8e8AuSocVPz1/ fuQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=f7kGweGAvVrWoZ0XynvIzuUJDcE2Jq/GgJuC22F875M=; b=W6H0aIOCC0FBWKCQjfBsbtK7EeW5X7qq9DRkDupbDgzHSp6ZIz2tWTTQL81DUCYyyc d812wI2tiaWRGjpU7LsE1U4Gky6oqaJDvaa/iu/5lI+9Lbgyom3FKqbhzLsaerey1rpX ACuTe2peeta4U6YegRSnxByIt+FnlDVWMdqr5HAT1fM8k6ZY5vUuMR2e4dp4Prt8MYjX XujdcbN49XndSXcp8bQjrWR/v81yeUhDtKeScyIUgXkh5DGSFinQBF1wwcg2g8y5ZbVn CYl/oxMRXXYnrjuhc0PbQ/XSDqIw43yxa0fz/xykFAK+fFMnxyQVv50IId8cTi+2vvKd mYow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="ZktXPd/N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x29-20020a056a00189d00b0052acaf4a3c0si854233pfh.17.2022.10.06.17.49.57; Thu, 06 Oct 2022 17:50:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="ZktXPd/N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232112AbiJFXvj (ORCPT + 99 others); Thu, 6 Oct 2022 19:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbiJFXvg (ORCPT ); Thu, 6 Oct 2022 19:51:36 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9470060480 for ; Thu, 6 Oct 2022 16:51:35 -0700 (PDT) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 1563E41477 for ; Thu, 6 Oct 2022 23:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1665100293; bh=f7kGweGAvVrWoZ0XynvIzuUJDcE2Jq/GgJuC22F875M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZktXPd/NrOcuFRhDkVYrhrAHRnmFHb1QCdmMejDyyNydH2kGu84hPtQ0DB1pcHhMF /ACFP8G/eYIMeg9Fz+ciLW+0NpRka0lqhw5TjdueqIm+DhCvfQBp0gqwLhPGUlxhwZ Ei5zJ+bcI1A3Ej//mghx/O5+UfQzABypUVKa+CppWFMAktgM6v4bWku+m3p5gRWx4D iS2hJaYCtGMs1GqCQOK2tHtoxSVTKtt9CcmXg/dZJidc3eq/9xzrMgUCjNiNMsRiIY gk3O7Rp8r6X1S5N+iWWzBIecST7SVGjIaHSMqpx5o4BUsR1su5W+VQGZG8SvK2yIIo Tijza4Zd7QAOw== Received: by mail-ed1-f71.google.com with SMTP id l7-20020a056402254700b004591f1de8ffso2626059edb.15 for ; Thu, 06 Oct 2022 16:51:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f7kGweGAvVrWoZ0XynvIzuUJDcE2Jq/GgJuC22F875M=; b=7+1mDYD+NRuqfNGoVPkXegN92FA2zooGenZ+fMoCRFDpjKuYJig+9JCcmKJByYx09V PiT9a+/Hm3gY7XVMAocEShU/xOk5fZz8VFl3QzzvpKRZrUY/R1mV8VcEcnHv7SPYjL7I gRoVqU3JgkdRqYYTxTBPkbh79KNJh5VlgZMdYS/5wH3RKCGcVoHa+W7Br+VOgIdDcm35 PW8GTD9Su9FRWPfKgWhxTGPKipoIjFoh4di9I5DuOkKD+ZcZGQAcpWkO0TAM0vXYwBKd 9OOpbXrOlcGXKvkc1Q1GM7Tt+4apdhXb5AGDiJHTN4DPQYrMZSrT0t4gims4/Y5ZrX/v f2cQ== X-Gm-Message-State: ACrzQf1wYD1Cri13pdx2fqetHzD1B/3+fnfnkusIa1mFhs1lFWrp/Pye XvVNhhdHZ1js3CZVe4ex0leLIGGEq5s14vwHbToJxye1OTIHhC1V/b3f3dN1tO1gdnbYI2Sh/pJ 6JRzR4zAIIcISGTF7fF3JWcqG9Qwxid+guuyDKWVDdQ== X-Received: by 2002:a17:907:2672:b0:734:a952:439a with SMTP id ci18-20020a170907267200b00734a952439amr1754764ejc.539.1665100291895; Thu, 06 Oct 2022 16:51:31 -0700 (PDT) X-Received: by 2002:a17:907:2672:b0:734:a952:439a with SMTP id ci18-20020a170907267200b00734a952439amr1754740ejc.539.1665100291651; Thu, 06 Oct 2022 16:51:31 -0700 (PDT) Received: from [172.25.0.170] (ip-084-118-157-002.um23.pools.vodafone-ip.de. [84.118.157.2]) by smtp.gmail.com with ESMTPSA id ee47-20020a056402292f00b0044eb5b922bdsm371026edb.24.2022.10.06.16.51.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Oct 2022 16:51:31 -0700 (PDT) Message-ID: Date: Fri, 7 Oct 2022 01:51:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [v4 PATCH 2/3] RISC-V: Update image header Content-Language: en-US To: Atish Patra Cc: Ard Biesheuvel , Daniel Kiper , Fu Wei , Leif Lindholm , Nikita Ermakov , Atish Patra , Julian Andres Klode , Ilias Apalodimas , linux-kernel@vger.kernel.org References: <20221006230051.185850-1-atishp@rivosinc.com> <20221006230051.185850-3-atishp@rivosinc.com> From: Heinrich Schuchardt In-Reply-To: <20221006230051.185850-3-atishp@rivosinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/7/22 01:00, Atish Patra wrote: > Update the RISC-V Linux kernel image headers as per the current header. > > Reference: > /Documentation/riscv/boot-image-header.rst > > 474efecb65dc: ("riscv: modify the Image header to improve compatibility with the ARM64 header") > > Signed-off-by: Atish Patra > --- > include/grub/riscv32/linux.h | 15 ++++++++------- > include/grub/riscv64/linux.h | 21 +++++++++++++-------- > 2 files changed, 21 insertions(+), 15 deletions(-) > > diff --git a/include/grub/riscv32/linux.h b/include/grub/riscv32/linux.h > index 512b777c8a41..de0dbdcd1be5 100644 > --- a/include/grub/riscv32/linux.h > +++ b/include/grub/riscv32/linux.h > @@ -19,20 +19,21 @@ > #ifndef GRUB_RISCV32_LINUX_HEADER > #define GRUB_RISCV32_LINUX_HEADER 1 > > -#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x52534356 /* 'RSCV' */ > +#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x05435352 /* 'RSC\0x5' */ Thanks for following up on this series. Considering 69edb312056 ("loader/arm64/linux: Remove magic number header field check") why should this constant exist in GRUB at all? In a follow up patch we could remove it together with GRUB_LINUX_ARM_MAGIC_SIGNATURE, GRUB_LINUX_ARMXX_MAGIC_SIGNATURE, and GRUB_LINUX_ARMXX_MAGIC_SIGNATURE. > > -/* From linux/Documentation/riscv/booting.txt */ > +/* From linux/Documentation/riscv/boot-image-header.rst */ > struct linux_riscv_kernel_header > { > grub_uint32_t code0; /* Executable code */ > grub_uint32_t code1; /* Executable code */ > - grub_uint64_t text_offset; /* Image load offset */ > - grub_uint64_t res0; /* reserved */ > - grub_uint64_t res1; /* reserved */ > + grub_uint64_t text_offset; /* Image load offset, little endian */ > + grub_uint64_t image_size; /* Effective Image size, little endian */ > + grub_uint64_t flags; /* kernel flags, little endian */ > + grub_uint32_t version; /* Version of this header */ > + grub_uint32_t res1; /* reserved */ > grub_uint64_t res2; /* reserved */ > grub_uint64_t res3; /* reserved */ According to tag next-20221006 of Documentation/riscv/boot-image-header.rst and of arch/riscv/include/asm/image.h this field is called 'magic' and filled it with the string 'RISCV\0\0\0'. > - grub_uint64_t res4; /* reserved */ > - grub_uint32_t magic; /* Magic number, little endian, "RSCV" */ > + grub_uint32_t magic; /* Magic number, little endian, "RSC\x05" */ The Linux kernel documentation calls this field magic2. Of course this is functionally irrelevant as we don't care about the content of both fields. > grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ > }; > > diff --git a/include/grub/riscv64/linux.h b/include/grub/riscv64/linux.h > index 3630c30fbf1a..ea77f8718222 100644 > --- a/include/grub/riscv64/linux.h > +++ b/include/grub/riscv64/linux.h > @@ -19,23 +19,28 @@ > #ifndef GRUB_RISCV64_LINUX_HEADER > #define GRUB_RISCV64_LINUX_HEADER 1 > > -#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x52534356 /* 'RSCV' */ > +#include > + > +#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x05435352 /* 'RSC\0x5' */ to be removed in future Best regards Heinrich > > #define GRUB_EFI_PE_MAGIC 0x5A4D > > -/* From linux/Documentation/riscv/booting.txt */ > +/* From linux/Documentation/riscv/boot-image-header.rst */ > struct linux_riscv_kernel_header > { > grub_uint32_t code0; /* Executable code */ > grub_uint32_t code1; /* Executable code */ > - grub_uint64_t text_offset; /* Image load offset */ > - grub_uint64_t res0; /* reserved */ > - grub_uint64_t res1; /* reserved */ > + grub_uint64_t text_offset; /* Image load offset, little endian */ > + grub_uint64_t image_size; /* Effective Image size, little endian */ > + grub_uint64_t flags; /* kernel flags, little endian */ > + grub_uint32_t version; /* Version of this header */ > + grub_uint32_t res1; /* reserved */ > grub_uint64_t res2; /* reserved */ > - grub_uint64_t res3; /* reserved */ > - grub_uint64_t res4; /* reserved */ > - grub_uint32_t magic; /* Magic number, little endian, "RSCV" */ > + grub_uint64_t magic; /* magic (RISC-V specifc, deprecated)*/ > + grub_uint32_t magic2; /* Magic number 2 (to match the ARM64 'magic' field pos) */ > grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ > + > + struct grub_coff_image_header coff_image_header; > }; > > #define linux_arch_kernel_header linux_riscv_kernel_header