Skip to content

Fix kernel hashes build failure#5129

Closed
CookieComputing wants to merge 3 commits into
project-oak:mainfrom
CookieComputing:fix-kernel-hashes-build
Closed

Fix kernel hashes build failure#5129
CookieComputing wants to merge 3 commits into
project-oak:mainfrom
CookieComputing:fix-kernel-hashes-build

Conversation

@CookieComputing
Copy link
Copy Markdown
Contributor

@CookieComputing CookieComputing commented May 26, 2026

When I was trying to build stage0 with the new sev_kernel_hashes feature introduced in 6fe1a11, I noticed that I was getting build failures:

ERROR: /home/kevinhui/oak/stage0/BUILD:25:13: Compiling Rust rlib stage0 (37 files) failed: (Exit 1): process_wrapper failed: error executing Rustc command (from target //stage0:stage0) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_rust+/util/process_wrapper/process_wrapper --arg-file ... (remaining 168 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error[E0599]: no method named `as_bytes` found for struct `KernelCmdLine` in the current scope
   --> stage0/src/lib.rs:223:21
    |
223 |             cmdline.as_bytes(),
    |                     ^^^^^^^^ method not found in `KernelCmdLine`
    |
   ::: stage0/src/kernel.rs:120:1
    |
120 | pub struct KernelCmdLine {
    | ------------------------ method `as_bytes` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `as_bytes`, perhaps you need to implement it:
            candidate #1: `IntoBytes`

error: aborting due to 1 previous error

This is replicable with the following changes:

[kevinhui ~/oak (main)]$ git diff
diff --git a/stage0/BUILD b/stage0/BUILD
index ddf5dd06d1..d08bc2a2e1 100644
--- a/stage0/BUILD
+++ b/stage0/BUILD
@@ -26,7 +26,7 @@ rust_library(
     name = "stage0",
     srcs = glob(["src/**"]),
     # Enable if you want to use kernel hashes
-    # crate_features = ["sev_kernel_hashes"],
+    crate_features = ["sev_kernel_hashes"],
     target_compatible_with = any_platform([
         "//:x86_64-none-setting",
         "//:x86_64-none-no_avx-setting",
diff --git a/stage0_sev/BUILD b/stage0_sev/BUILD
index 169115a6f7..d923906883 100644
--- a/stage0_sev/BUILD
+++ b/stage0_sev/BUILD
@@ -25,7 +25,7 @@ rust_library(
     name = "stage0_sev",
     srcs = glob(["src/**/*.rs"]),
     # Enable if you want to use kernel hashes
-    # crate_features = ["sev_kernel_hashes"],
+    crate_features = ["sev_kernel_hashes"],
     aliases = {"//stage0": "oak_stage0"},
     deps = [
         "//oak_attestation",

After this PR, those build failures go away:

[kevinhui ~/oak (fix-kernel-hashes-build)]$ bazel build //stage0_bin
INFO: Analyzed target //stage0_bin:stage0_bin (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //stage0_bin:stage0_bin up-to-date:
  bazel-bin/stage0_bin/stage0_bin
INFO: Elapsed time: 8.894s, Critical Path: 8.34s
INFO: 4 processes: 1 internal, 3 linux-sandbox.
INFO: Build completed successfully, 4 total actions

I also took the liberty to add a note to stage0_bin/README to add a comment about kernel hashes

Signed-off-by: Kevin Hui <kevinhui@meta.com>
Signed-off-by: Kevin Hui <kevinhui@meta.com>
Copy link
Copy Markdown
Collaborator

@conradgrobler conradgrobler left a comment

Choose a reason for hiding this comment

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

Thanks! Could you please run just format? The linter is failing on the README change.

@CookieComputing
Copy link
Copy Markdown
Contributor Author

Thanks! Just formatted it

@conradgrobler
Copy link
Copy Markdown
Collaborator

Imported as d1fb4aa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants