Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp586840rwb; Fri, 7 Oct 2022 01:03:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7D6JSHW0jXgtvtz5wptpWdKn+t6ih5C4I+UbZ/NhXve5VgEjxWojEcaytrcTYQzbpbIVRn X-Received: by 2002:aa7:c919:0:b0:459:55b:57e7 with SMTP id b25-20020aa7c919000000b00459055b57e7mr3499544edt.20.1665129788371; Fri, 07 Oct 2022 01:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665129788; cv=none; d=google.com; s=arc-20160816; b=mS93o8jwDYcCp78iyYyKidaWpRHw1kSiAejsBP2ZKQ70A1jGEfcdN1syN3ySsqVtYt N/9afU1ykQ433AdFjFtnuttmPc199GcrCitxviVxqoVytsm+3ASGUYATkT0n+AiKrRdt P9ezQFDLvem6Mk0eu7FPawj1d3/Ot2mIFzOdIgjUSi+Jz/gzAWw3Tbq51GDEyZ5lYCvs GdMfUHVTEtnOmxypL2LcnlWKrbjonQnGthnI5KGjiH35xMLDjssH+Her8yD4OsxcxBqA 3ULuLIE2lhShpvvZ39SPlzGAjI13dRyA7mKi9Bma0TlHzFh4pIA99rsaiMlr4ZA/XrAe Cp7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YMtULBVuhc9ss92jUe+D+WcboNyvjfJAcLdpgC5afT4=; b=z28kwIAzvI8qXbBnQCA4Y4u3ehUEZ6ciJn/VVuN6ItP3/gBXPVJ6umFTE1Eiu/3IwG DKN5olQQyAx7njQhX7oUf+n1DmOdwLI9mq/DFcLdsJ6bDW/t5M0a8tUSvLoCM82w6lgM nOmPgXIdR10+mzjQk/3+eA4HyWGvVnRjr3bbB2t+eLLGSof9w5Ifr/weUUTjmomGA1/V vRa8Ba62Kzbpa5JNR6PPR9OmajsCSxsjUvIR6dHUkzPC+xDALE1h72PxCNWWJ91KqIIc //r+9XgSTK3+aAkD5QZER4fGSRvyndZw+Kg5ZDjF3vPs/UNXzmUY6kFsAhtJU8eF0YjV pJYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=X3o3bgw2; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p27-20020a1709066a9b00b0078d4b605b71si1391593ejr.338.2022.10.07.01.02.22; Fri, 07 Oct 2022 01:03:08 -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=@atishpatra.org header.s=google header.b=X3o3bgw2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbiJGHzU (ORCPT + 99 others); Fri, 7 Oct 2022 03:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbiJGHzS (ORCPT ); Fri, 7 Oct 2022 03:55:18 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C69389F747 for ; Fri, 7 Oct 2022 00:55:16 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id o65so3070593iof.4 for ; Fri, 07 Oct 2022 00:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atishpatra.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YMtULBVuhc9ss92jUe+D+WcboNyvjfJAcLdpgC5afT4=; b=X3o3bgw2QtF306MV5U22AkyUGQFtuCl0MhXVGwyUbmd5TMWoQgkDslPJTUEweBMvZT afR7YuWsfMshOWtJxLYb2FHeSN59FnQONV5RXO/Kt48XQPEPNl+9P3E+UGX9NBJ6R1Tr loS8wRUfFK28GeOc8X3FlGe7EJStt8L/gK3ug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YMtULBVuhc9ss92jUe+D+WcboNyvjfJAcLdpgC5afT4=; b=C+cjMInfaw1G5C+ujITD2mM958wsDKoz0KMltk5ivUbeUMP4R2S+2zXTgz9andvc0/ ohSt+kuHg/+mEd8FX7H9jqTWayfCbAcdLXEUJwta4aVLFVY+9mmiJLZHsMgk8/Mx6TdM L5VMD1RJcrpNSv67V5HLGrOs/3c+xiw9LgHfP08/9Ldg2y8FzVnyTpMI/hl3Zwl/u1+J Vden1aZBMcyToH6iCmiFc2+N4jeyA836LqY2f9Hax2BEmOaokhDkmjQh2hbb71q799UN FcQvcBXoKggP8ieLVOCBR3TqN+SI/xAv0CEJNRssjn364BawfKUO+Rf1myXyOuQwIx/f NTfQ== X-Gm-Message-State: ACrzQf1FR8dH/cD6SLqwdZmt1vcvGlnqIgNIli+gJVxHmp6JvNRW8/E1 YYoaMKrIIogX9dfYqKRqcW1A7WDNMw09Ia3N4iAE X-Received: by 2002:a5e:9911:0:b0:6b9:c02b:3746 with SMTP id t17-20020a5e9911000000b006b9c02b3746mr1561354ioj.127.1665129316201; Fri, 07 Oct 2022 00:55:16 -0700 (PDT) MIME-Version: 1.0 References: <20221006230051.185850-1-atishp@rivosinc.com> <20221006230051.185850-3-atishp@rivosinc.com> <4ef86adf-a7c7-5ffc-6acc-9d269ea089ba@canonical.com> In-Reply-To: <4ef86adf-a7c7-5ffc-6acc-9d269ea089ba@canonical.com> From: Atish Patra Date: Fri, 7 Oct 2022 00:55:05 -0700 Message-ID: Subject: Re: [v4 PATCH 2/3] RISC-V: Update image header To: Heinrich Schuchardt Cc: Ard Biesheuvel , Atish Patra , Daniel Kiper , Fu Wei , Leif Lindholm , Nikita Ermakov , Julian Andres Klode , Ilias Apalodimas , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Fri, Oct 7, 2022 at 12:50 AM Heinrich Schuchardt wrote: > > > > On 10/7/22 09:20, Ard Biesheuvel wrote: > > On Fri, 7 Oct 2022 at 01:51, Heinrich Schuchardt > > wrote: > >> > >> > >> > >> 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. > >> > > > > Indeed. > > > > But by the same reasoning, why do we need per-arch kernel header > > typedefs at all? The only fields we access are generic PE/COFF header > > fields. > > That said I would suggest to put the series in without any further > iterations and clean up afterwards. > > Acked-by: Heinrich Schuchardt > Thanks for reviewing it. I will send the next version right now. I screwed up my scripts and grub-devel was not in the CC also. > > > >>> > >>> -/* 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 -- Regards, Atish