FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

kexec: explain kexec_file_load failures by alanhc · Pull Request #3774 · u-root/u-root · GitHub

/ u-root Public

kexec: explain kexec_file_load failures - #3774

Open
alanhc wants to merge 2 commits into
u-root:mainfrom
alanhc:kexec-errors
Open

alanhc wants to merge 2 commits into
u-root:mainfrom
alanhc:kexec-errors

Conversation

alanhc commented Oct 3, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Fixes #3384.

On arm, where FileLoad is a stub, kexec printed only function not implemented, after an invalid FDT magic line from the universal payload probe. Neither says what failed or what to do about it.

  • Name kexec_file_load and the architecture in the ENOSYS stub error (still wraps syscall.ENOSYS).
  • When kexec_file_load fails with ENOSYS or ENOEXEC for a Linux image, suggest --loadsyscall. ENOEXEC is what riscv returns for an Image before Linux 6.16 (kexec_file_load error #3236).
  • Only log the universal payload probe failure with -d when the file is not an FDT at all (ErrFailToReadFdtFile), since that is the common case. A file that is a universal payload but fails to load or exec now returns that error instead of falling back to the legacy path.
  • Drop (default true) from the -d and -L docs; both default to false.

Before (arm32 vmtest kernel, kexec -l -c KEXEC=Y /kernel):

Failed to load universalpayload (failed to read fdt file: fdt file: /kernel, err: reading FDT header: invalid FDT magic, got 0x0000a0e1, expected 0xd00dfeed), try legacy kernel..
function not implemented

After:

kexec_file_load failed, try --loadsyscall to use kexec_load instead: SYS_kexec_file_load is not supported on arm: function not implemented

and on riscv64 with the 6.6 vmtest kernel:

kexec_file_load failed, try --loadsyscall to use kexec_load instead: SYS_kexec_file_load(7, 0, KEXEC=Y, 4) = exec format error

Testing: added TestLoadError; go test ./cmds/core/kexec ./pkg/boot ./pkg/boot/kexec ./pkg/boot/universalpayload passes, and the outputs above are from QEMU runs under runvmtest with VMTEST_ARCH=arm and riscv64.

On arm, where FileLoad is a stub, kexec printed only "function not
implemented", after an "invalid FDT magic" line from the universal
payload probe. Neither says what failed or what to do about it.

- Name kexec_file_load and the architecture in the ENOSYS stub error.
- When kexec_file_load fails with ENOSYS or ENOEXEC, suggest
  --loadsyscall. ENOEXEC is what riscv returns for an Image before
  Linux 6.16.
- Only log the universal payload probe failure with -d when the file is
  not an FDT at all, since that is the common case.
- Drop "(default true)" from the -d and -L docs; both default to false.

On arm the output goes from

  Failed to load universalpayload (failed to read fdt file: ... invalid
  FDT magic, got 0x0000a0e1, expected 0xd00dfeed), try legacy kernel..
  function not implemented

to

  SYS_kexec_file_load is not supported on arm: function not
  implemented; try --loadsyscall to use kexec_load instead

Fixes u-root#3384

Signed-off-by: Hung-Chun Tseng <alan.tseng.cs@gmail.com>
alanhc mentioned this pull request Oct 3, 2026

codecov Bot commented Oct 3, 2026 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.33%. Comparing base (8c86aab) to head (1942ca9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3774      +/-   ##
==========================================
- Coverage   61.46%   61.33%   -0.14%     
==========================================
  Files         648      648              
  Lines       45716    45727      +11     
==========================================
- Hits        28099    28045      -54     
- Misses      17617    17682      +65     
Flag Coverage Δ
.-amd64 90.90% <ø> (ø)
cmds/...-amd64 52.39% <43.75%> (+<0.01%) ⬆️
integration/generic-tests/...-amd64 29.34% <25.00%> (-0.02%) ⬇️
integration/generic-tests/...-arm 31.75% <0.00%> (ø)
integration/generic-tests/...-arm64 28.13% <25.00%> (+0.05%) ⬆️
integration/gotests/...-amd64 60.33% <43.75%> (-0.22%) ⬇️
integration/gotests/...-arm 60.67% <43.75%> (+0.09%) ⬆️
integration/gotests/...-arm64 60.77% <43.75%> (-0.01%) ⬇️
pkg/...-amd64 59.10% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
everything 66.26% <64.70%> (-0.16%) ⬇️
cmds/exp 34.30% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread cmds/core/kexec/kexec_linux.go Outdated
return err
}
if errors.Is(err, syscall.ENOSYS) || errors.Is(err, syscall.ENOEXEC) {
return fmt.Errorf("%w; try --loadsyscall to use kexec_load instead", err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I sometimes get complaints from tools that the %w should be last, not first; can you make it last?

}
} else {
// universalpayload package suppresses warning message, we print messages here.
if warningMsg != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I am sad to see packages returning nil pointers, it's going to catch us sooner or later. Any chance of fixing that package?

Comment thread cmds/core/kexec/kexec_linux.go Outdated
// case. Only mention it when debugging.
linux.Debug("%s is not a universal payload (%v), loading it as a kernel", opts.kernelpath, err)
} else {
log.Printf("Failed to load universalpayload (%v), try legacy kernel..", err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

if this is an error, shouldn't it just return here? This thicket of if ... else might be reduced a bit.

rminnich added the Awaiting author Waiting for new changes or feedback for author. label Oct 3, 2026

Copy link
Copy Markdown
Member

Awesome, thanks for looking into this!

I just referenced this PR in the corresponding issue I had filed a good while ago.

Address review on u-root#3774:

- A file that is a universal payload but fails to load or execute now
  returns the error instead of falling back to loading it as a kernel,
  which could only fail again with a less useful message. The if/else
  becomes a switch.
- Move %w to the end of the --loadsyscall hint.

Signed-off-by: Hung-Chun Tseng <alan.tseng.cs@gmail.com>

alanhc commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Pushed 1942ca9:

  • %w is now last.
  • If the file is a universal payload but fails to load or exec, kexec now returns that error instead of falling back to the legacy path, which could only fail again with a less useful message. The if/else is a switch now.
  • universalpayload.Load returning (error, error) with a nil warning: agreed, I'll fix the package in a separate PR so this one stays small.

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Awaiting author Waiting for new changes or feedback for author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kexec error feedback misleading / unclear

3 participants


Back | FazBrowse Home | New Git URL