Skip to content

uefi: Drop the panic-on-logger-errors feature #1143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions uefi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# uefi - [Unreleased]

## Removed
- Removed the `panic-on-logger-errors` feature of the `uefi` crate. Logger
errors are now silently ignored.


# uefi - 0.28.0 (2024-04-19)

Expand Down
5 changes: 0 additions & 5 deletions uefi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ repository.workspace = true
rust-version.workspace = true

[features]
default = ["panic-on-logger-errors"]
alloc = []

# Generic gate to code that uses unstable features of Rust. You usually need a nightly toolchain.
Expand All @@ -23,10 +22,6 @@ unstable = []
logger = []
global_allocator = []
panic_handler = []
# Ignore text output errors in logger as a workaround for firmware issues that
# were observed on the VirtualBox UEFI implementation (see uefi-rs#121).
# In those cases, this feature can be excluded by removing the default features.
panic-on-logger-errors = []
qemu = ["dep:qemu-exit", "panic_handler"] # panic_handler: logical, not technical dependency

[dependencies]
Expand Down
23 changes: 5 additions & 18 deletions uefi/src/helpers/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,17 @@ impl log::Log for Logger {

if !output.is_null() {
let writer = unsafe { &mut *output };
let result = DecoratedLog::write(

// Ignore all errors. Since we're in the logger implementation we
// can't log the error. We also don't want to panic, since logging
// is generally not critical functionality.
let _ = DecoratedLog::write(
Copy link
Member

Choose a reason for hiding this comment

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

nit: We could write it to the serial device and the debugcon device in that case.

writer,
record.level(),
record.args(),
record.file().unwrap_or("<unknown file>"),
record.line().unwrap_or(0),
);

// Some UEFI implementations, such as the one used by VirtualBox,
// may intermittently drop out some text from SimpleTextOutput and
// report an EFI_DEVICE_ERROR. This will be reported here as an
// `fmt::Error`, and given how the `log` crate is designed, our main
// choices when that happens are to ignore the error or panic.
//
// Ignoring errors is bad, especially when they represent loss of
// precious early-boot system diagnosis data, so we panic by
// default. But if you experience this problem and want your UEFI
// application to keep running when it happens, you can disable the
// `panic-on-logger-errors` cargo feature. If you do so, logging errors
// will be ignored by `uefi-rs` instead.
//
if cfg!(feature = "panic-on-logger-errors") {
result.unwrap()
}
}
}

Expand Down
3 changes: 0 additions & 3 deletions xtask/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ pub enum Feature {
Alloc,
GlobalAllocator,
Logger,
PanicOnLoggerErrors,
Unstable,
PanicHandler,
Qemu,
Expand All @@ -70,7 +69,6 @@ impl Feature {
Self::Alloc => "alloc",
Self::GlobalAllocator => "global_allocator",
Self::Logger => "logger",
Self::PanicOnLoggerErrors => "panic-on-logger-errors",
Self::Unstable => "unstable",
Self::PanicHandler => "panic_handler",
Self::Qemu => "qemu",
Expand All @@ -91,7 +89,6 @@ impl Feature {
Self::Alloc,
Self::GlobalAllocator,
Self::Logger,
Self::PanicOnLoggerErrors,
Self::Unstable,
Self::PanicHandler,
Self::Qemu,
Expand Down
Loading