[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH RFC] EFI: strip xen.efi when putting it on the EFI partition


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 26 Apr 2022 12:26:26 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KNUztbPFo3Lr9FHKh0MxM/uivONhzKNC1jZQvPVxjdM=; b=fpWR+RGgcM48dI75Ia3IbZ20h3IgJ+DUKXpkFYNIp2hDI2lFSfjVDUjGOqWt5YTmn+qUPt0ppRVBNa96J4r0UgTP08xdxx+WLXiZj/78UtyKJLy6fAgVDEKK0MyVLnWi8RMrPcKx/vQTjGBHl7CcUHUqz4wYon/Zsm114JYNNU85lFrZGf0DFrcZ2Z+Vf47fqmMzrvevMCQTXaaqrPQG5KZOTebgXZIabFt9LqP0/gnTiGOR6p1F2Qq6NnCYP5kNFHahQsSZ03rvrSznJeB88tzqRBFF+tfYFMYUYxlLW3v6J7dPZWQs6Ub3BmwmYcDZgf5xftL2xded9ncf1lhsQg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jebITiMSQi0k0NeAz+8J65Dkiez/w+WKRpBwCBZUsxnQNNbU3N/STtzV6iNUaIqr3u+hpfzkkTcusrhlWsobP0/ZyAVUEWGozgGLrkVuLsSmybc1N21esmr1kgI+cIveOaHQplK9Xkb4Oi162zW+x0FIAe/UigXCkyf6ODrXsxgQYIor89VltuFfFZq7cZfUTduFQyCli4DhMMl2Cice/TfVt4d9RAMY7a9W1BM1BpsRJ0zW2apBhps1PFl2pROYFnk0rFA/6zh5L4roWkT14P33d+vx9yVqqfnPzBkRepm83Hwfu3mARaoK2g78vc4srE2fVl8x73yWyybw6rqw7w==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 26 Apr 2022 12:26:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYWJHILrDj2EEGDUWtEVYmIvMHMK0CII4A
  • Thread-topic: [PATCH RFC] EFI: strip xen.efi when putting it on the EFI partition

Hi Jan,

> On 25 Apr 2022, at 11:46, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> With debug info retained, xen.efi can be quite large. Unlike for xen.gz
> there's no intermediate step (mkelf32 there) involved which would strip
> debug info kind of as a side effect. While the installing of xen.efi on
> the EFI partition is an optional step (intended to be a courtesy to the
> developer), adjust it also for the purpose of documenting what distros
> would be expected to do during boot loader configuration (which is what
> would normally put xen.efi into the EFI partition).
> 
> Model the control over stripping after Linux'es module installation,
> except that the stripped executable is constructed in the build area
> instead of in the destination location. This is to conserve on space
> used there - EFI partitions tend to be only a few hundred Mb in size.
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> RFC: GNU strip 2.38 appears to have issues when acting on a PE binary:
>     - the new file positions of the sections do not respect the file
>       alignment specified by the header (a resulting looks to work on
>       one EFI implementation where I did actually try it, but I don't
>       think we can rely on that),
>     - file name symbols are also stripped; while there is a separate
>       --keep-file-symbols option (which I would have thought to be on
>       by default anyway), its use makes no difference.
>     Older GNU strip (observed with 2.35.1) doesn't work at all ("Data
>     Directory size (1c) exceeds space left in section (8)").
> 
> --- a/xen/Makefile
> +++ b/xen/Makefile
> @@ -461,6 +461,22 @@ endif
> .PHONY: _build
> _build: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX)
> 
> +# Strip
> +#
> +# INSTALL_EFI_STRIP, if defined, will cause xen.efi to be stripped before it
> +# is installed. If INSTALL_EFI_STRIP is '1', then the default option
> +# --strip-debug will be used. Otherwise, INSTALL_EFI_STRIP value will be used
> +# as the option(s) to the strip command.
> +ifdef INSTALL_EFI_STRIP
> +
> +ifeq ($(INSTALL_EFI_STRIP),1)
> +efi-strip-opt := --strip-debug
> +else
> +efi-strip-opt := $(INSTALL_EFI_STRIP)
> +endif
> +
> +endif

This does sound very complex and using combination of ifdef and ifeq on an 
external variable is not done anywhere else.

How about splitting into a variable to turn strip on or off and let the user 
override a local variable setting up the strip options if he wants to ?

Something like:

EFI_STRIP_OPTION ?= "—strip-debug"

And then just using INSTALL_EFI_STRIP to strip or not during the _install phase 

One wanting to use no specific option would have to pass INSTALL_EFI_STRIP=1 
EFI_STRIP_OPTION=“” for example.

Cheers
Bertrand

> +
> .PHONY: _install
> _install: D=$(DESTDIR)
> _install: T=$(notdir $(TARGET))
> @@ -485,6 +501,9 @@ _install: $(TARGET)$(CONFIG_XEN_INSTALL_
>               ln -sf $(T)-$(XEN_FULLVERSION).efi 
> $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).efi; \
>               ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T).efi; \
>               if [ -n '$(EFI_MOUNTPOINT)' -a -n '$(EFI_VENDOR)' ]; then \
> +                     $(if $(efi-strip-opt), \
> +                          $(STRIP) $(efi-strip-opt) -p -o 
> $(TARGET).efi.stripped $(TARGET).efi && \
> +                          $(INSTALL_DATA) $(TARGET).efi.stripped 
> $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$(T)-$(XEN_FULLVERSION).efi ||) \
>                       $(INSTALL_DATA) $(TARGET).efi 
> $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$(T)-$(XEN_FULLVERSION).efi; \
>               elif [ "$(D)" = "$(patsubst $(shell cd $(XEN_ROOT) && 
> pwd)/%,%,$(D))" ]; then \
>                       echo 'EFI installation only partially done (EFI_VENDOR 
> not set)' >&2; \
> 
> 


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.