From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lXQHm-0000ie-1I for mharc-grub-devel@gnu.org; Fri, 16 Apr 2021 11:21:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXQHf-0000fJ-L6 for grub-devel@gnu.org; Fri, 16 Apr 2021 11:21:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30184) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXQHd-0003oB-Pl for grub-devel@gnu.org; Fri, 16 Apr 2021 11:21:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618586485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pzL1nP1l72yUCf1TS26BAm2gXUq/eFBB0ZDFOf4nASU=; b=NNqwwAorAu84rWIPZFoc/BPvsI+DPQJQY7XHUEFfjuhOxzzFAS+wvoShtxn2aIeX6FO3We 5bnDAcbWkW9ws14YQ0uPnixeqZFVQ93OaUk2b5Nk9nFLNtYc57v2QMzA7g+0G3SYaRG6HJ oFwbvYiyBMBADuRiOaBo/vfBigNNT0w= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-326-GAR6olUaPDOhCTc9ndAeqg-1; Fri, 16 Apr 2021 11:21:23 -0400 X-MC-Unique: GAR6olUaPDOhCTc9ndAeqg-1 Received: by mail-wm1-f70.google.com with SMTP id 26-20020a05600c021ab029012e366eff83so1094543wmi.4 for ; Fri, 16 Apr 2021 08:21:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pzL1nP1l72yUCf1TS26BAm2gXUq/eFBB0ZDFOf4nASU=; b=fayHDeTmCG2M5UAdduuMSrqDu1rNbyrZ7odR8Sld1XexDop/+fcnzRzITPSIrM3LrW 6/kImgTGidjSG4XzZj2WrvIHo+/8BnGNA+8+cqMAUhtzosaSY39KUfwl+U02d3dzj5FT TpC17vhe/XijC4mvBFzsVnMhIIukPYfnviFwyp3SOxY3Wd/Mp+t/VgkzQEf+CKOgHmtt ejn8x6rQkmpcL2TPdRKIKGzguLLFoXbfb/u5BaFXUbKVCTCm02c0Y8CdZjkxufVTVGnq ljk503p9HaahPSK3hFjfoZRGlXAD30tPP9O5rsKMnulVyBlAQIyulDjYsVVQ5AY8ZFlp qqPA== X-Gm-Message-State: AOAM531MAY2LV1lg6Ts2EBbOJ+XTRMZnOQAhi2VKHCfH9JKFZ1s7uJ4n BXfWd9Qa8InD6pvC8GPoQK6oh/LXWLeHyrUsv3S1YiqxeKA3bAwoUzaT+ojx2JbxIkwRsvL32is TNyL4Lx11dCw= X-Received: by 2002:a5d:6182:: with SMTP id j2mr9607957wru.317.1618586482286; Fri, 16 Apr 2021 08:21:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygZJeIsbrtCcHWi4xd8Qv81L7zjyMXh3rvvuTEzu3i35S13Mp4O2LZR0wEUGIHvYnppjTi2Q== X-Received: by 2002:a5d:6182:: with SMTP id j2mr9607945wru.317.1618586482138; Fri, 16 Apr 2021 08:21:22 -0700 (PDT) Received: from [192.168.1.101] ([92.176.231.106]) by smtp.gmail.com with ESMTPSA id l9sm10810926wrz.7.2021.04.16.08.21.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Apr 2021 08:21:21 -0700 (PDT) Subject: Re: GRUB error: unknown filesystem on ia64 To: The development of GNU GRUB , John Paul Adrian Glaubitz References: <20210326180133.z5qjvtwt7loxvuqt@tomti.i.net-space.pl> <20210326184315.awfdlparysi3hqii@tomti.i.net-space.pl> <5b041746-09e9-0557-9f2a-ac3b37837728@physik.fu-berlin.de> Cc: Daniel Kiper , Peter Jones From: Javier Martinez Canillas Message-ID: <1105e718-55bd-e276-e531-fa55a07c262d@redhat.com> Date: Fri, 16 Apr 2021 17:21:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=fmartine@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=fmartine@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Apr 2021 15:21:29 -0000 Hello Adrian, Sorry for the delay, I didn't have time to look at this issue before. On 4/12/21 8:57 AM, John Paul Adrian Glaubitz wrote: > Hi Javier! > > On 4/12/21 8:21 AM, Javier Martinez Canillas wrote: >> Interesting, thanks for the input. >> >> Could you please share a both GRUB binary that works and one that >> fails to compare ? > > Here are both the EFI as well as the GRUB directory for the broken > and working cases: > >> https://people.debian.org/~glaubitz/grub-ia64/ > > If you compare the two core.efi images, you will see the issue immediately: > Thanks for the binaries, as you said the ".data" and "mods" sections had wrong size and content. Could you please try the following patch [0] ? It's an RFC since I'm not really an expert on binary formats, but there were a few problems with the patch you mentioned as far as I can tell. I Cc'ed Daniel and Peter so they can correct me if I got anything wrong. Best regards, Javier [0] >From 31c9864ff6543b624d404d8fabc9c517756a470a Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 16 Apr 2021 17:01:44 +0200 Subject: [RFC PATCH] util/mkimage: Some fixes to PE binaries section size calculation Commit f60ba9e5945 (util/mkimage: Refactor section setup to use a helper) added a helper function to setup PE sections, but it caused regressions in some arches where the natural alignment lead to wrong section sizes. This patch fixes a few things that were caused the section sizes to be calculated wrongly. These fixes are: * Only align the virtual memory addresses but not the raw data offsets. * Use aligned sizes for virtual memory sizes but not for raw data sizes. * Always align the sizes to set the virtual memory sizes. These seems to not cause problems for x64 and aa64 EFI platforms but was a problem for ia64. Because the size of the ".data" and "mods" sections were wrong and didn't have the correct content. Which lead to GRUB not being able to load any built-in module. Reported-by: John Paul Adrian Glaubitz Signed-off-by: Javier Martinez Canillas --- util/mkimage.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/util/mkimage.c b/util/mkimage.c index 8b475a69109..0d33f0e9766 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -841,7 +841,7 @@ init_pe_section(const struct grub_install_image_target_desc *image_target, section->raw_data_offset = grub_host_to_target32 (*rda); section->raw_data_size = grub_host_to_target32 (rsz); - (*rda) = ALIGN_UP (*rda + rsz, GRUB_PE32_FILE_ALIGNMENT); + (*rda) = *rda + rsz; section->characteristics = grub_host_to_target32 (characteristics); @@ -1389,26 +1389,26 @@ grub_install_generate_image (const char *dir, const char *prefix, section = init_pe_section (image_target, section, ".data", &vma, scn_size, image_target->section_align, - &raw_data, scn_size, + &raw_data, layout.kernel_size - layout.exec_size, GRUB_PE32_SCN_CNT_INITIALIZED_DATA | GRUB_PE32_SCN_MEM_READ | GRUB_PE32_SCN_MEM_WRITE); - scn_size = pe_size - layout.reloc_size - raw_data; + scn_size = ALIGN_UP (pe_size - layout.reloc_size - raw_data, GRUB_PE32_FILE_ALIGNMENT); section = init_pe_section (image_target, section, "mods", &vma, scn_size, image_target->section_align, - &raw_data, scn_size, + &raw_data, pe_size - layout.reloc_size - raw_data, GRUB_PE32_SCN_CNT_INITIALIZED_DATA | GRUB_PE32_SCN_MEM_READ | GRUB_PE32_SCN_MEM_WRITE); - scn_size = layout.reloc_size; + scn_size = ALIGN_UP (layout.reloc_size, GRUB_PE32_FILE_ALIGNMENT); PE_OHDR (o32, o64, base_relocation_table.rva) = grub_host_to_target32 (vma); PE_OHDR (o32, o64, base_relocation_table.size) = grub_host_to_target32 (scn_size); memcpy (pe_img + raw_data, layout.reloc_section, scn_size); init_pe_section (image_target, section, ".reloc", &vma, scn_size, image_target->section_align, - &raw_data, scn_size, + &raw_data, layout.reloc_size, GRUB_PE32_SCN_CNT_INITIALIZED_DATA | GRUB_PE32_SCN_MEM_DISCARDABLE | GRUB_PE32_SCN_MEM_READ); -- 2.30.2