From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69105C433B4 for ; Wed, 19 May 2021 09:30:06 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 230536100A for ; Wed, 19 May 2021 09:30:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 230536100A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.129957.243691 (Exim 4.92) (envelope-from ) id 1ljIWV-0001Ny-Uk; Wed, 19 May 2021 09:29:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 129957.243691; Wed, 19 May 2021 09:29:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ljIWV-0001Nr-RY; Wed, 19 May 2021 09:29:51 +0000 Received: by outflank-mailman (input) for mailman id 129957; Wed, 19 May 2021 09:29:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ljIWU-0001Nj-IJ for xen-devel@lists.xenproject.org; Wed, 19 May 2021 09:29:50 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d5c28893-fc35-4c89-8241-fac1070c28d8; Wed, 19 May 2021 09:29:49 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 84F3BAE39; Wed, 19 May 2021 09:29:48 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d5c28893-fc35-4c89-8241-fac1070c28d8 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1621416588; h=from:from:reply-to: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=70fZJvNZqwFm//PLmJ2D6mSvvED+4URflxvX5wyUEiw=; b=UcrhyrzPWpUdVWTzvspsKzKq7tHfVXSF3pQQieM4GqdTK/6zK97L9U8oqfEUAtyQ/3JCtd /x8bQmv9YGusAr5cNsprTkCBWAM0LLPFZ3TARRzMo6w2F9qbVFA9uvbyZeicCR8zCaz73b gkWOBVM/In89PBmVi2WskOt3TLHe9jw= Subject: Re: [PATCH v3 2/5] xen/x86: manually build xen.mb.efi binary To: Daniel Kiper Cc: Bob Eshleman , Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu , Xen-devel References: <28d5536a2f7691e8f79d55f1470fa89ce4fae93d.1611273359.git.bobbyeshleman@gmail.com> <3c621726-31c4-6a79-a020-88c59644111b@suse.com> <74ea104d-3826-d80d-3af5-f444d065c73f@gmail.com> <20210517132039.6czppjfge27x4mwg@tomti.i.net-space.pl> <20210518174633.spo5kmgcbuo6dg5k@tomti.i.net-space.pl> From: Jan Beulich Message-ID: <51333867-d693-38e2-bd1c-fce28241a604@suse.com> Date: Wed, 19 May 2021 11:29:43 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210518174633.spo5kmgcbuo6dg5k@tomti.i.net-space.pl> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 18.05.2021 19:46, Daniel Kiper wrote: > On Mon, May 17, 2021 at 03:24:28PM +0200, Jan Beulich wrote: >> On 17.05.2021 15:20, Daniel Kiper wrote: >>> On Mon, May 17, 2021 at 08:48:32AM +0200, Jan Beulich wrote: >>>> On 07.05.2021 22:26, Bob Eshleman wrote: >>>>> What is your intuition WRT the idea that instead of trying add a PE/COFF hdr >>>>> in front of Xen's mb2 bin, we instead go the route of introducing valid mb2 >>>>> entry points into xen.efi? >>>> >>>> At the first glance I think this is going to be less intrusive, and hence >>>> to be preferred. But of course I haven't experimented in any way ... >>> >>> When I worked on this a few years ago I tried that way. Sadly I failed >>> because I was not able to produce "linear" PE image using binutils >>> exiting that days. >> >> What is a "linear" PE image? > > The problem with Multiboot family protocols is that all code and data > sections have to be glued together in the image and as such loaded into > the memory (IIRC BSS is an exception but it has to live behind the > image). So, you cannot use PE image which has different representation > in file and memory. IIRC by default at least code and data sections in > xen.efi have different sizes in PE file and in memory. I tried to fix > that using linker script and objcopy but it did not work. Sadly I do > not remember the details but there is pretty good chance you can find > relevant emails in Xen-devel archive with me explaining what kind of > problems I met. Ah, this rings a bell. Even the .bss-is-last assumption doesn't hold, because .reloc (for us as well as in general) comes later, but needs loading (in the right place). Since even xen.gz isn't simply the compressed linker output, but a post-processed (by mkelf32) image, maybe what we need is a build tool doing similar post-processing on xen.efi? Otoh getting disk image and in-memory image aligned ought to be possible by setting --section-alignment= and --file-alignment= to the same value (resulting in a much larger file) - adjusting file positions would effectively be what a post-processing tool would need to do (like with mkelf32 perhaps we could then at least save the first ~2Mb of space). Which would still leave .reloc to be dealt with - maybe we could place this after .init, but still ahead of __init_end (such that the memory would get freed late in the boot process). Not sure whether EFI loaders would "like" such an unusual placement. Also not sure what to do with Dwarf debug info, which just recently we managed to avoid needing to strip unconditionally. >>> Maybe >>> newer binutils are more flexible and will be able to produce a PE image >>> with properties required by Multiboot2 protocol. >> >> Isn't all you need the MB2 header within the first so many bytes of the >> (disk) image? Or was it the image as loaded into memory? Both should be >> possible to arrange for. > > IIRC Multiboot2 protocol requires the header in first 32 kiB of an image. > So, this is not a problem. I was about to ask "Disk image or in-memory image?" But this won't matter if the image as a whole got linearized, as long as the first section doesn't start to high up. I notice that xen-syms doesn't fit this requirement either, only the output of mkelf32 does. Which suggests that there may not be a way around a post-processing tool. Jan