Skip to content

Commit

Permalink
Merge pull request rust-osdev#1143 from nicholasbishop/bishop-drop-pa…
Browse files Browse the repository at this point in the history
…nic-log

uefi: Drop the panic-on-logger-errors feature
  • Loading branch information
phip1611 authored Apr 21, 2024
2 parents ddb81bd + bcac03d commit 2e5dea4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 26 deletions.
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(
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

0 comments on commit 2e5dea4

Please sign in to comment.