All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: Frediano Ziglio <freddy77@gmail.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Oleksii Kurochko" <oleksii.kurochko@gmail.com>,
	"Frediano Ziglio" <frediano.ziglio@citrix.com>,
	xen-devel@lists.xenproject.org,
	"Frediano Ziglio" <frediano.ziglio@cloud.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Julien Grall" <julien@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Demi Marie Obenour" <demiobenour@gmail.com>,
	"Stewart Hildebrand" <stewart.hildebrand@amd.com>
Subject: Re: [PATCH v8] xen: Strip xen.efi by default
Date: Wed, 19 Nov 2025 16:06:59 +0100	[thread overview]
Message-ID: <aR3dFPTeH4Wegodd@mail-itl> (raw)
In-Reply-To: <CAHt6W4eDDm-fNUB7W1Zgj+x-bkK2fxTB50C38T4Uy0_Ofy_cww@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4873 bytes --]

On Sat, Nov 15, 2025 at 06:23:08AM +0000, Frediano Ziglio wrote:
> On Fri, 14 Nov 2025 at 19:18, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> >
> > On 14/11/2025 3:40 pm, Oleksii Kurochko wrote:
> > >
> > >
> > > On 11/13/25 4:43 PM, Frediano Ziglio wrote:
> > >> From: Frediano Ziglio <frediano.ziglio@cloud.com>
> > >>
> > >> For xen.gz file we strip all symbols and have an additional
> > >> xen-syms.efi file version with all symbols.
> > >> Make xen.efi more coherent stripping all symbols too.
> > >> xen-syms.efi can be used for debugging.
> > >>
> > >> Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
> > > Release-Acked-By: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> > >
> > > Thanks.
> >
> > Thanks.  Unfortunately CI says no.
> >
> > Ubuntu's 20.04, 18.04 and 16.04 all fail:
> > https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2159622869
> >
> > From 16.04:
> >
> > 2025-11-14T18:01:51.192964Z 01O strip xen-syms.efi -o xen.efi
> > 2025-11-14T18:01:51.198151Z 01O strip:xen-syms.efi[.init]: relocation count is negative: File truncated
> > 2025-11-14T18:01:51.198166Z 01O strip: xen.efi: Failed to read debug data section
> > 2025-11-14T18:01:51.198169Z 01O strip:xen.efi: error copying private BFD data: File truncated
> > 2025-11-14T18:01:51.198932Z 01O arch/x86/Makefile:207: recipe for target 'xen.efi' failed
> > 2025-11-14T18:01:51.198937Z 01O make[3]: *** [xen.efi] Error 1
> > 2025-11-14T18:01:51.199616Z 01O build.mk:90: recipe for target 'xen' failed
> > 2025-11-14T18:01:51.199619Z 01O make[2]: *** [xen] Error 2
> > 2025-11-14T18:01:51.200402Z 01O Makefile:600: recipe for target 'xen' failed
> > 2025-11-14T18:01:51.200409Z 01O make[1]: *** [xen] Error 2
> >
> >
> > I find it hard to believe that the relocation count is really negative,
> > and given that newer binuitls works, I expect this is a binutils bug.
> >
> 
> Unless the message is just misleading I find it hard to have a
> negative number of items in a container.
> 
> > Nevertheless, we need some workaround.  Given that the previous
> > behaviour was not to strip, I think we can reuse that for broken toolchains?
> >
> 
> Something like that ?
> 
> diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
> index a154ffe6b2..c465eb12e2 100644
> --- a/xen/arch/x86/Makefile
> +++ b/xen/arch/x86/Makefile
> @@ -236,7 +236,9 @@ ifeq ($(CONFIG_DEBUG_INFO),y)
>         $(if $(filter --strip-debug,$(EFI_LDFLAGS)),:$(space))$(OBJCOPY) \
>                 -O elf64-x86-64 $(TARGET)-syms.efi $@.elf
>  endif
> -       $(STRIP) $(TARGET)-syms.efi -o $@
> +       $(STRIP) $(TARGET)-syms.efi -o $@ || { \
> +               LANG=C strip $(TARGET)-syms.efi -o $@ 2>&1 | grep -q \
> +               "relocation count is negative" && mv -f $(TARGET)-syms.efi $@; }
>  ifneq ($(CONFIG_DEBUG_INFO),y)
>         rm -f $(TARGET)-syms.efi
>  endif

On Ubuntu 20.04 it fails different way:

    strip: xen.efi: Data Directory size (1c) exceeds space left in section (18)
    strip: xen.efi: error copying private BFD data: file in wrong format

Looks similar to:
https://lore.kernel.org/all/3TMd7J2u5gCA8ouIG_Xfcw7s5JKMG06XsDIesEB3Fi9htUJ43Lfl057wXohlpCHcszqoCmicpIlneEDO26ZqT8QfC2Y39VxBuqD3nS1j5Q4=@trmm.net/

Qubes has this patch:
https://github.com/QubesOS/qubes-vmm-xen/blob/main/0608-Fix-buildid-alignment.patch

    diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
    index 9a1dfe1b340a..26a23a7b0651 100644
    --- a/xen/arch/x86/xen.lds.S
    +++ b/xen/arch/x86/xen.lds.S
    @@ -171,6 +171,7 @@ SECTIONS
            __note_gnu_build_id_end = .;
       } PHDR(note) PHDR(text)
     #elif defined(BUILD_ID_EFI)
    +  . = ALIGN(32);
       DECL_SECTION(.buildid) {
            __note_gnu_build_id_start = .;
            *(.buildid)

Lets see if that helps:
https://gitlab.com/xen-project/people/marmarek/xen/-/pipelines/2167783980

And few lines earlier there is also:

    ld: xen-syms.efi: warning: section .init: alignment 2**15 not representable

> It will fall back to not stripping in case that bug is detected. I
> don't know how to test it.
> (the LANG=C is to always force the English message).

If going this way, use LC_ALL=C (otherwise LC_ALL=something present in
the env would override your LANG=C). But given there are different
messages, this may not be the best option.

And TBH, I don't like silent behavior change based on (unknown) version
of binutils. Lets see if the alignment adjustment helps. While it
shouldn't be necessary on newer binutils (thanks to Jan's fix there -
see thread linked above), IMO it isn't too bad to add it, to keep older
versions happy. And it can be dropped, once we raise toolchain base
version next time.

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2025-11-19 15:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 15:43 [PATCH v8] xen: Strip xen.efi by default Frediano Ziglio
2025-11-13 18:35 ` Marek Marczykowski-Górecki
2025-11-13 18:40   ` [PATCH for-4.21 " Andrew Cooper
2025-11-13 23:32     ` Frediano Ziglio
2025-11-14 15:40 ` [PATCH " Oleksii Kurochko
2025-11-14 19:18   ` Andrew Cooper
2025-11-15  6:23     ` Frediano Ziglio
2025-11-19 15:06       ` Marek Marczykowski-Górecki [this message]
2025-11-19 16:02         ` Andrew Cooper
2025-11-19 17:08           ` Marek Marczykowski-Górecki
2025-11-19 18:05             ` Andrew Cooper
2025-11-20  8:27             ` Jan Beulich
2025-11-20 13:59       ` Frediano Ziglio
2025-11-20 14:04         ` Jan Beulich
2025-11-20 14:05         ` Marek Marczykowski-Górecki
2025-11-20 14:32           ` Frediano Ziglio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aR3dFPTeH4Wegodd@mail-itl \
    --to=marmarek@invisiblethingslab.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=demiobenour@gmail.com \
    --cc=freddy77@gmail.com \
    --cc=frediano.ziglio@citrix.com \
    --cc=frediano.ziglio@cloud.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=oleksii.kurochko@gmail.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=stewart.hildebrand@amd.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.