msb_krun_cpuid: fix compilation on Rust 1.93 by wrapping CPUID calls in unsafe blocks#50
Merged
appcypher merged 3 commits intosuperradcompany:krunfrom Apr 24, 2026
Merged
Conversation
…in unsafe blocks
Recent Rust versions (e.g., 1.93.0) require explicit `unsafe` blocks
when calling low-level CPU intrinsics such as `__cpuid`,
`__cpuid_count`, and `__get_cpuid_max`.
This crate was invoking these functions without `unsafe` blocks,
which results in compilation errors:
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
Wrap all such calls in explicit `unsafe {}` blocks to satisfy
the compiler and maintain correctness.
No functional changes intended—this aligns the code with
Rust’s safety requirements for intrinsic operations.
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Author
|
An attempt to fix this -> #50 |
Author
appcypher
approved these changes
Apr 23, 2026
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
379924a to
ff4cbf1
Compare
Syncs `common.rs` and `brand_string.rs` with containers/libkrun upstream:
- Fix import typo: `target_arch = "x86_64"` now correctly imports from
`std::arch::x86_64` (not `x86`), restoring compilation on x86_64.
- Add `#[allow(unused_unsafe)]` to `get_cpuid` and `from_host_cpuid`.
Rust 1.94 relaxed `__cpuid`, `__cpuid_count`, and `__get_cpuid_max`
to safe `fn` via stdarch PR #1935, so the `unsafe {}` blocks needed
on Rust 1.93 now trip `-D warnings` under clippy on 1.94+. The
`allow` silences the lint while keeping the code compatible with
both toolchains.
- Wrap the remaining `host_cpuid` calls in the test module in `unsafe`
blocks for the same reason.
4 tasks
appcypher
added a commit
that referenced
this pull request
Apr 26, 2026
Bump all msb_krun_* workspace crates and their internal path-dependency version refs from 0.1.10 to 0.1.11, and refresh both lockfiles. The libkrun C-API crate (1.17.3) and the rust_vm example are unchanged. Changes since 0.1.10: - feat(krun): expand DiskBuilder with id, cache, direct_io, sync (#51) - msb_krun_cpuid: fix compilation on Rust 1.93 by wrapping CPUID calls in unsafe blocks (#50)
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recent Rust versions (e.g., 1.93.0) require explicit
unsafeblocks when calling low-level CPU intrinsics such as__cpuid,__cpuid_count, and__get_cpuid_max.This crate was invoking these functions without
unsafeblocks, which results in compilation errors:Wrap all such calls in explicit
unsafe {}blocks to satisfy the compiler and maintain correctness.No functional changes intended—this aligns the code with Rust’s safety requirements for intrinsic operations.