Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 913935 - sys-kernel/gentoo-kernel-bin-6.4.15 failed to boot on arm64 (error: invalid magic number)
Summary: sys-kernel/gentoo-kernel-bin-6.4.15 failed to boot on arm64 (error: invalid m...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: ARM64 Linux
: Normal normal (vote)
Assignee: Distribution Kernel Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-10 12:08 UTC by Leonid Kopylov
Modified: 2023-10-16 05:19 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leonid Kopylov 2023-09-10 12:08:45 UTC
trying to boot, gives errors:
error: invalid magic number
error: you need to load the kernel first.

please tell what more info required

# emerge =sys-kernel/gentoo-kernel-bin-6.4.15 -pvq
[ebuild   R   ] sys-kernel/gentoo-kernel-bin-6.4.15  USE="initramfs -secureboot -test"

# emerge --info =sys-kernel/gentoo-kernel-bin-6.4.15
Portage 3.0.51 (python 3.12.0-candidate-2, default/linux/arm64/17.0/desktop/gnome/systemd/merged-usr, gcc-13, glibc-2.38-r1, 6.5.2-gentoo-arm64 aarch64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-6.5.2-gentoo-arm64-aarch64-with-glibc2.38
KiB Mem:    32817324 total,  29628580 free
KiB Swap:    8388604 total,   8388604 free
Timestamp of repository gentoo: Sun, 10 Sep 2023 06:00:01 +0000
Head commit of repository gentoo: b9a54f1ae1d8fab63820ce2492548efcd175f059
Timestamp of repository EmilienMottet: Wed, 23 Aug 2023 07:46:54 +0000
Head commit of repository EmilienMottet: 99cf86efee6f2ad830e71376a387aa062b2fe728

Timestamp of repository HomeAssistantRepository: Sat, 26 Aug 2023 15:31:40 +0000
Head commit of repository HomeAssistantRepository: 9f9976b7b96fb688ae7de88bf149b618d997c8eb

Timestamp of repository darkelf: Tue, 29 Aug 2023 15:50:51 +0000
Head commit of repository darkelf: f6fe9577d081e80b8661ea6976047cff9e0700b1

Timestamp of repository guru: Sat, 09 Sep 2023 12:31:59 +0000
Head commit of repository guru: 35e47a4c31837f96aa222fc34fe5e34d5e5d3ea4

Timestamp of repository inode64-overlay: Thu, 07 Sep 2023 05:32:13 +0000
Head commit of repository inode64-overlay: bfcf385ae2bb6b2c29a394c48469cde2c27f864a

Timestamp of repository kde: Sat, 09 Sep 2023 18:02:02 +0000
Head commit of repository kde: d4aa6c2713630343b668b4ce635e2019e2f834c7

sh bash 5.2_p15-r6
ld GNU ld (Gentoo 2.41 p2) 2.41.0
ccache version 4.8.3 [enabled]
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p15-r6::gentoo
dev-java/java-config:      2.3.1-r1::gentoo
dev-lang/perl:             5.38.0-r1::gentoo
dev-lang/python:           3.10.13::gentoo, 3.11.5::gentoo, 3.12.0_rc2_p1-r1::gentoo
dev-lang/rust:             1.72.0::gentoo
dev-util/ccache:           4.8.3::gentoo
dev-util/cmake:            3.27.4::gentoo
dev-util/meson:            1.2.1-r1::gentoo
sys-apps/baselayout:       2.14::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-apps/systemd:          254.3::gentoo
sys-devel/autoconf:        2.13-r8::gentoo, 2.71-r7::gentoo
sys-devel/automake:        1.16.5-r1::gentoo
sys-devel/binutils:        2.41-r1::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           15.0.7-r3::gentoo, 16.0.6::gentoo
sys-devel/gcc:             12.3.1_p20230825::gentoo, 13.2.1_p20230826::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             16.0.6::gentoo
sys-devel/llvm:            14.0.6-r4::gentoo, 15.0.7-r3::gentoo, 16.0.6::gentoo
sys-devel/make:            4.4.1-r1::gentoo
sys-kernel/linux-headers:  6.5::gentoo (virtual/os-headers)
sys-libs/glibc:            2.38-r1::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://server.kopylovs.net/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts:
    sync-rsync-verify-jobs: 1

EmilienMottet
    location: /var/db/repos/EmilienMottet
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/EmilienMottet.git
    masters: gentoo
    volatile: False

HomeAssistantRepository
    location: /var/db/repos/HomeAssistantRepository
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/HomeAssistantRepository.git
    masters: gentoo
    volatile: False

darkelf
    location: /var/db/repos/darkelf
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/darkelf.git
    masters: gentoo
    volatile: False

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/guru.git
    masters: gentoo
    volatile: False

inode64-overlay
    location: /var/db/repos/inode64-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/inode64-overlay.git
    masters: gentoo
    volatile: False

kde
    location: /var/db/repos/kde
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/kde.git
    masters: gentoo
    volatile: False

Binary Repositories:

gentoobinhost
    priority: 1
    sync-uri: https://gentoo.osuosl.org/releases/arm64/binpackages/17.0/arm64

ACCEPT_KEYWORDS="arm64 ~arm64"
ACCEPT_LICENSE="* -@EULA geekbench Microsoft-vscode TeamViewer Vivaldi"
CBUILD="aarch64-unknown-linux-gnu"
CFLAGS="-march=armv8-a+crc+lse+rcpc+rdma+dotprod+aes+fp16fml+sb+ssbs+flagm+pauth -O2 -pipe -fomit-frame-pointer"
CHOST="aarch64-unknown-linux-gnu"
CONFIG_PROTECT="/etc /opt/zookeeper-bin/conf /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php8.1/ext-active/ /etc/php/apache2-php8.2/ext-active/ /etc/php/cgi-php8.1/ext-active/ /etc/php/cgi-php8.2/ext-active/ /etc/php/cli-php8.1/ext-active/ /etc/php/cli-php8.2/ext-active/ /etc/php/fpm-php8.1/ext-active/ /etc/php/fpm-php8.2/ext-active/ /etc/php/phpdbg-php8.1/ext-active/ /etc/php/phpdbg-php8.2/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=armv8-a+crc+lse+rcpc+rdma+dotprod+aes+fp16fml+sb+ssbs+flagm+pauth -O2 -pipe -fomit-frame-pointer"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-march=armv8-a+crc+lse+rcpc+rdma+dotprod+aes+fp16fml+sb+ssbs+flagm+pauth -O2 -pipe -fomit-frame-pointer"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live ccache config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict strict-keepdir unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync warn-on-large-env xattr"
FFLAGS="-march=armv8-a+crc+lse+rcpc+rdma+dotprod+aes+fp16fml+sb+ssbs+flagm+pauth -O2 -pipe -fomit-frame-pointer"
GENTOO_MIRRORS="https://mirror.isoc.org.il/pub/gentoo/ https://mirror.eu.oneandone.net/linux/distributions/gentoo/gentoo/"
LANG="en_US.utf8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
MAKEOPTS="-j6"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="X a52 aac accessibility acl acpi alsa arm64 audit bash-completion berkdb bidi bluetooth branding brotli btrfs bzip2 cairo cdda cdr cgi cli colord crypt cryptsetup cups curl dbus designer device-mapper doc dri dts dvdr eds emacs encode evdev evo examples exif experimental ffmpeg flac fortran fuse gamepad gdbm gif git gmp gnome gnome-keyring gnome-online-accounts gnutls go gpg gpm gstreamer gtk gtk-doc gui heif hscolour html http ibus iconv icu idn introspection iodbc ipv6 jack java jemalloc joystick jpeg json kde kerberos keyring lcms ldap libnotify libtirpc lua lvm lz4 lzma lzo mad man mbedtls mng mongodb mp3 mp4 mpeg multimedia mysql nas nautilus ncurses netlink network networkmanager nfs nls nptl nss odbc offensive ogg opengl openmp openssl pam pango pcap pcre pdf perl pkcs11 plasma plugins png policykit postgres ppds pulseaudio python qml qt5 readline redis samba sasl screencast sdl seccomp semantic-desktop snmp sound source speech spell sqlite ssl startup-notification svg symlink systemd tcl tcpd telemetry test-rust threads tiff tk tools tracker truetype udev udisks unicode unwind upnp upower usb utils v4l vala vim-syntax vnc vorbis vulkan wayland webengine webkit webp wxwidgets x264 xattr xcb xft xinerama xml xv xvid yaml zeroconf zip zlib zstd" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words stage" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_ARM="edsp vfp vfpv3 vfpv4 vfp-d32 aes sha1 sha2 crc32 v8" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="evdev joystick libinput" KERNEL="linux" L10N="en en-US he ru" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="nlpsolver scripting-beanshell scripting-javascript wiki-publisher" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11 python3_10 python3_12" RUBY_TARGETS="ruby31 ruby32" VIDEO_CARDS="virgl" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS

=================================================================
                        Package Settings
=================================================================

sys-kernel/gentoo-kernel-bin-6.4.15::gentoo was built with the following:
USE="initramfs -secureboot -test"
FEATURES="unmerge-logs preserve-libs xattr binpkg-docompress merge-sync binpkg-multi-instance sfperms warn-on-large-env ccache multilib-strict unknown-features-warn network-sandbox sandbox ebuild-locks qa-unresolved-soname-deps strict-keepdir pid-sandbox binpkg-logs usersandbox fixlafiles protect-owned userfetch usersync distlocks userpriv ipc-sandbox config-protect-if-modified strict buildpkg-live binpkg-dostrip assume-digests parallel-fetch news unmerge-orphans"
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-09-10 12:21:10 UTC
>error: invalid magic number
>error: you need to load the kernel first.

* Could you run `file /path/to/kernel` please on both the initramfs + kernel in /boot?

* What bootloader?

* What HW / VM software? (it matters because of diff. EFI impls)

thanks
Comment 2 Leonid Kopylov 2023-09-10 12:25:51 UTC
(In reply to Sam James from comment #1)
> >error: invalid magic number
> >error: you need to load the kernel first.
> 
> * Could you run `file /path/to/kernel` please on both the initramfs + kernel
> in /boot?

# file /boot/vmlinuz-6.4.15-gentoo-dist /boot/initramfs-6.4.15-gentoo-dist.img
/boot/vmlinuz-6.4.15-gentoo-dist:       PE32+ executable (EFI application) Aarch64 (stripped to external PDB), for MS Windows, 2 sections
/boot/initramfs-6.4.15-gentoo-dist.img: gzip compressed data, max compression, from Unix, original size modulo 2^32 62921728

> * What bootloader?
# emerge grub -pvq
[ebuild   R   ] sys-boot/grub-2.06-r7  USE="device-mapper doc fonts mount nls sdl themes truetype -efiemu -libzfs (-test) -verify-sig" GRUB_PLATFORMS="efi-64 -coreboot -efi-32 -emu -ieee1275 (-loongson) -multiboot -pc (-qemu) (-qemu-mips) (-uboot) -xen (-xen-32) -xen-pvh"

> * What HW / VM software? (it matters because of diff. EFI impls)
It's VM on Parallels Desktop on Apple M1 Max (Mac Studio)

> thanks


Hi, please see answers above
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2023-09-10 14:31:43 UTC
I'm pretty sure it's CONFIG_EFI_ZBOOT.  The question is, whether this can be reasonably resolved or we need to revert to non-signed kernels.
Comment 4 Andrew Ammerlaan gentoo-dev 2023-09-10 14:50:41 UTC
I think your problem might be resolved in grub 2.12_rc1, would you be willing to check?

https://lore.kernel.org/all/20220811145157.3237840-1-ardb@kernel.org/T/

> I'm pretty sure it's CONFIG_EFI_ZBOOT.  The question is, whether this can be 
> reasonably resolved or we need to revert to non-signed kernels.

If the problem is indeed grub, then probably we should build the arm64 gentoo-kernel-bin with USE=-secureboot for now. Once we have the next release of grub in the tree and stable, we can revisit this and enable it again.

Other arches should be uneffected so we can still enable USE=secureboot for the binary kernels there.
Comment 5 Andrew Ammerlaan gentoo-dev 2023-09-10 14:55:38 UTC
(In reply to Andrew Ammerlaan from comment #4)
> If the problem is indeed grub, then probably we should build the arm64
> gentoo-kernel-bin with USE=-secureboot for now. Once we have the next
> release of grub in the tree and stable, we can revisit this and enable it
> again.

Or alternatively we can apply the above patch to grub 2.06.
Comment 6 Leonid Kopylov 2023-09-10 15:00:19 UTC
(In reply to Andrew Ammerlaan from comment #4)
> I think your problem might be resolved in grub 2.12_rc1, would you be
> willing to check?
> 
> https://lore.kernel.org/all/20220811145157.3237840-1-ardb@kernel.org/T/
> 
> > I'm pretty sure it's CONFIG_EFI_ZBOOT.  The question is, whether this can be 
> > reasonably resolved or we need to revert to non-signed kernels.
> 
> If the problem is indeed grub, then probably we should build the arm64
> gentoo-kernel-bin with USE=-secureboot for now. Once we have the next
> release of grub in the tree and stable, we can revisit this and enable it
> again.
> 
> Other arches should be uneffected so we can still enable USE=secureboot for
> the binary kernels there.

sys-boot/grub-2.12_rc1-r1 is not keyworded, i added it to '/etc/portage/package.accept_keywords/' - and installed.
and yes - it boots now:

# uname -r
6.4.15-gentoo-dist
Comment 7 Andrew Ammerlaan gentoo-dev 2023-09-10 15:09:00 UTC
(In reply to Leonid Kopylov from comment #6)
> sys-boot/grub-2.12_rc1-r1 is not keyworded, i added it to
> '/etc/portage/package.accept_keywords/' - and installed.
> and yes - it boots now:
> 
> # uname -r
> 6.4.15-gentoo-dist

Great, Thanks for testing.

Adding the maintainers of Grub to CC. How do we want to proceed? Patch grub 2.06, or disable USE=secureboot (and in effect disable EFI_ZBOOT) for the arm64 gentoo-kernel-bin gpkg (until we have a new grub release)?
Comment 8 Larry the Git Cow gentoo-dev 2023-09-11 01:49:26 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=070361537d8ace58dd617b3520c0e2751e1f5574

commit 070361537d8ace58dd617b3520c0e2751e1f5574
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2023-09-11 01:48:19 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2023-09-11 01:48:19 +0000

    sys-boot/grub: backport fix for arm64
    
    Closes: https://bugs.gentoo.org/913935
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 ...grub-2.06-arm64-linux-Remove-magic-number.patch | 45 ++++++++++++++++++++++
 .../{grub-2.06-r7.ebuild => grub-2.06-r8.ebuild}   |  1 +
 2 files changed, 46 insertions(+)
Comment 9 Mike Gilbert gentoo-dev 2023-09-11 01:52:54 UTC
(In reply to Andrew Ammerlaan from comment #7)

Always happy to back port simple fixes like this one.