From 7d3e58311954b3b1e3222eb264b6aa93162f54af Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Thu, 20 Jun 2024 01:47:28 +0000 Subject: [PATCH 01/13] cmm: Pass lib around Signed-off-by: Nick Spinale --- hacking/cargo-manifest-management/default.nix | 4 +++- hacking/cargo-manifest-management/manual-manifests.nix | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hacking/cargo-manifest-management/default.nix b/hacking/cargo-manifest-management/default.nix index ac069c052..619a27493 100644 --- a/hacking/cargo-manifest-management/default.nix +++ b/hacking/cargo-manifest-management/default.nix @@ -17,7 +17,9 @@ rec { inherit lib; }; - manualManifests = import ./manual-manifests.nix; + manualManifests = import ./manual-manifests.nix { + inherit lib; + }; workspace = makeBlueprint { inherit manifestScope manualManifests; diff --git a/hacking/cargo-manifest-management/manual-manifests.nix b/hacking/cargo-manifest-management/manual-manifests.nix index b91b5cc71..64991c4f6 100644 --- a/hacking/cargo-manifest-management/manual-manifests.nix +++ b/hacking/cargo-manifest-management/manual-manifests.nix @@ -4,6 +4,8 @@ # SPDX-License-Identifier: BSD-2-Clause # +{ lib }: + let relativeToWorkspaceRoot = relativePath: "${toString ../..}/${relativePath}"; From db9cfbfd59fcfd9763956e6e3b7a0eb57010b00b Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Thu, 20 Jun 2024 08:29:17 +0000 Subject: [PATCH 02/13] cmm: Clean up Signed-off-by: Nick Spinale --- hacking/cargo-manifest-management/tool/make-blueprint.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/hacking/cargo-manifest-management/tool/make-blueprint.nix b/hacking/cargo-manifest-management/tool/make-blueprint.nix index d45b32ae1..d4c3c6f66 100644 --- a/hacking/cargo-manifest-management/tool/make-blueprint.nix +++ b/hacking/cargo-manifest-management/tool/make-blueprint.nix @@ -88,9 +88,6 @@ in let cargoNixPaths = - let - dirFilter = relativePathSegments: lib.head relativePathSegments == "crates"; - in scanDirForFilesWithName workspaceDirFilter "Cargo.nix" workspaceRoot; generateManifest = cargoNixAbsolutePath: From a816967dfd2cb0c7d2610f4a15e5c025ea735bee Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 07:13:08 +0000 Subject: [PATCH 03/13] crates/private/support/sel4-simple-task: Fix bitrot Signed-off-by: Nick Spinale --- .../sel4-simple-task/config-types/src/when_not_sel4.rs | 6 ++---- crates/private/support/sel4-simple-task/rpc/src/easy.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/private/support/sel4-simple-task/config-types/src/when_not_sel4.rs b/crates/private/support/sel4-simple-task/config-types/src/when_not_sel4.rs index 33f0fe03a..fa82ac2ab 100644 --- a/crates/private/support/sel4-simple-task/config-types/src/when_not_sel4.rs +++ b/crates/private/support/sel4-simple-task/config-types/src/when_not_sel4.rs @@ -29,10 +29,8 @@ dummies! { SmallPage LargePage HugePage - PageGlobalDirectory - PageUpperDirectory - PageDirectory - PageTable + PT + VSpace IrqControl IrqHandler AsidControl diff --git a/crates/private/support/sel4-simple-task/rpc/src/easy.rs b/crates/private/support/sel4-simple-task/rpc/src/easy.rs index 3a3680f57..5d15762bf 100644 --- a/crates/private/support/sel4-simple-task/rpc/src/easy.rs +++ b/crates/private/support/sel4-simple-task/rpc/src/easy.rs @@ -10,7 +10,7 @@ use core::mem; use serde::{Deserialize, Serialize}; -use sel4::{Badge, Endpoint, IpcBuffer, MessageInfo, MessageInfoBuilder, Word}; +use sel4::{cap::Endpoint, Badge, IpcBuffer, MessageInfo, MessageInfoBuilder, Word}; const BYTES_PER_WORD: usize = mem::size_of::() / mem::size_of::(); From 42b7d904c162471d10c2146b3a14576ac95df0fd Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 07:13:46 +0000 Subject: [PATCH 04/13] crates/sel4-kernel-loader: Specify dependency with more precision Signed-off-by: Nick Spinale --- crates/sel4-kernel-loader/Cargo.nix | 2 +- crates/sel4-kernel-loader/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/sel4-kernel-loader/Cargo.nix b/crates/sel4-kernel-loader/Cargo.nix index fc6859ad4..be5cbb167 100644 --- a/crates/sel4-kernel-loader/Cargo.nix +++ b/crates/sel4-kernel-loader/Cargo.nix @@ -32,7 +32,7 @@ mk { }; target."cfg(target_arch = \"aarch64\")".dependencies = { smccc = "0.1.1"; - aarch64-cpu = "9.0.0"; + aarch64-cpu = "9.4.0"; }; build-dependencies = { inherit (versions) diff --git a/crates/sel4-kernel-loader/Cargo.toml b/crates/sel4-kernel-loader/Cargo.toml index bc4cb2175..554ab3dac 100644 --- a/crates/sel4-kernel-loader/Cargo.toml +++ b/crates/sel4-kernel-loader/Cargo.toml @@ -54,5 +54,5 @@ riscv = "0.10.0" sbi = "0.2.0" [target."cfg(target_arch = \"aarch64\")".dependencies] -aarch64-cpu = "9.0.0" +aarch64-cpu = "9.4.0" smccc = "0.1.1" From c24f91a89b71c3c396c11194f5b5381e935d20c8 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 07:14:20 +0000 Subject: [PATCH 05/13] crates/sel4-capdl-initializer: Fix bug Signed-off-by: Nick Spinale --- crates/sel4-capdl-initializer/core/src/memory.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sel4-capdl-initializer/core/src/memory.rs b/crates/sel4-capdl-initializer/core/src/memory.rs index 019fc1dcd..deae49477 100644 --- a/crates/sel4-capdl-initializer/core/src/memory.rs +++ b/crates/sel4-capdl-initializer/core/src/memory.rs @@ -50,7 +50,7 @@ impl CopyAddrs { let outer_span = 1u64 << sel4::vspace_levels::span_bits(level); let inner_span = 1usize << sel4::vspace_levels::step_bits(level); let addr_space_footprint = coarsen_footprint( - &(user_image_bounds.start..(user_image_bounds.start + bootinfo.footprint_size())), + &(user_image_bounds.start..(user_image_bounds.end + bootinfo.footprint_size())), inner_span, ); match ( From 67d3d11b0d8f3d37b60f9b888396671e2b15bf98 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 07:15:18 +0000 Subject: [PATCH 06/13] nix: Make elaborateRustEnvironment overridable Signed-off-by: Nick Spinale --- hacking/nix/rust-utils/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hacking/nix/rust-utils/default.nix b/hacking/nix/rust-utils/default.nix index e796e57eb..aca139e0b 100644 --- a/hacking/nix/rust-utils/default.nix +++ b/hacking/nix/rust-utils/default.nix @@ -55,7 +55,7 @@ in isBuiltin = false; }; - elaborateRustEnvironment = + elaborateRustEnvironment = lib.makeOverridable ( { rustToolchain , channel ? null , isNightly ? @@ -79,5 +79,6 @@ in inherit rustToolchain; lockfile = symlinkToRegularFile "Cargo.lock" "${rustToolchain}/lib/rustlib/src/rust/Cargo.lock"; }; - }; + } + ); } From ac1cc1e6f71d19416153418206da6c23c9cc4418 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 07:16:28 +0000 Subject: [PATCH 07/13] nix: Fix linking for cross compilation targeting Linux Signed-off-by: Nick Spinale --- hacking/nix/rust-utils/crate-utils.nix | 17 +++++++++++++---- hacking/nix/scope/default.nix | 16 ++++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/hacking/nix/rust-utils/crate-utils.nix b/hacking/nix/rust-utils/crate-utils.nix index 28f2c636f..d14c3d1c4 100644 --- a/hacking/nix/rust-utils/crate-utils.nix +++ b/hacking/nix/rust-utils/crate-utils.nix @@ -5,6 +5,7 @@ # { lib, buildPlatform, hostPlatform +, stdenv, buildPackages , writeText, linkFarm, runCommand , toTOMLFile , mkBuiltinRustTargetTriple @@ -97,10 +98,10 @@ rec { # TODO improve this mechanism linkerConfig = { rustEnvironment, targetTriple }@args: let - f = { targetTriple, platform }: + f = { targetTriple, platform, cc }: let linker = rustEnvironment.chooseLinker { - inherit targetTriple platform; + inherit targetTriple platform cc; }; in lib.optionalAttrs (linker != null) { @@ -110,8 +111,16 @@ rec { }; in clobber [ - (f { targetTriple = mkBuiltinRustTargetTriple buildPlatform.config; platform = buildPlatform; }) - (f { inherit targetTriple; platform = hostPlatform; }) + (f { + targetTriple = mkBuiltinRustTargetTriple buildPlatform.config; + platform = buildPlatform; + inherit (buildPackages.stdenv) cc; + }) + (f { + inherit targetTriple; + platform = hostPlatform; + inherit (stdenv) cc; + }) ]; baseConfig = { rustEnvironment, targetTriple }@args: clobber [ diff --git a/hacking/nix/scope/default.nix b/hacking/nix/scope/default.nix index 31edf7d47..473a1115e 100644 --- a/hacking/nix/scope/default.nix +++ b/hacking/nix/scope/default.nix @@ -83,10 +83,18 @@ superCallPackage ../rust-utils {} self // mkDefaultElaborateRustEnvironmentArgs = { rustToolchain }: rec { inherit rustToolchain; - chooseLinker = { targetTriple, platform }: - if platform.isNone - then "${rustToolchain}/lib/rustlib/${buildPlatform.config}/bin/rust-lld" - else null; + chooseLinker = { targetTriple, platform, cc }: + if platform.config == buildPlatform.config + then null + else ( + if platform.isNone + then "${rustToolchain}/lib/rustlib/${buildPlatform.config}/bin/rust-lld" + else ( + if platform.isMusl # HACK for proper static linking on musl + then "${cc.targetPrefix}ld" + else "${cc.targetPrefix}cc" + ) + ); vendoredSuperLockfile = vendoredTopLevelLockfile; }; From b7d9e7711a13530c076f53060784f9d8e6b2edf6 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 07:17:38 +0000 Subject: [PATCH 08/13] nix: Support building sysroot with std Signed-off-by: Nick Spinale --- hacking/nix/rust-utils/build-sysroot.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hacking/nix/rust-utils/build-sysroot.nix b/hacking/nix/rust-utils/build-sysroot.nix index 77beca05d..8ad68557b 100644 --- a/hacking/nix/rust-utils/build-sysroot.nix +++ b/hacking/nix/rust-utils/build-sysroot.nix @@ -15,6 +15,7 @@ , release ? true , profile ? if release then "release" else null , alloc ? true +, std ? false , compilerBuiltinsMem ? true , compilerBuiltinsC ? rustEnvironment.compilerRTSource != null , extraManifest ? {} @@ -68,6 +69,8 @@ let "compiler_builtins" ] ++ lib.optionals alloc [ "alloc" + ] ++ lib.optionals std [ + "std" ]); features = lib.concatStringsSep "," (lib.flatten [ From 343e1a0b6d9490cdc6fa7eadd10b9e89da745046 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 07:15:54 +0000 Subject: [PATCH 09/13] nix: Clean up Cargo profile args Signed-off-by: Nick Spinale --- hacking/nix/rust-utils/build-crates-in-layers.nix | 2 +- hacking/nix/rust-utils/build-sysroot.nix | 2 +- hacking/nix/scope/world/mk-task.nix | 4 +++- hacking/nix/scope/world/sel4-kernel-loader.nix | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hacking/nix/rust-utils/build-crates-in-layers.nix b/hacking/nix/rust-utils/build-crates-in-layers.nix index b753433d0..e0365b8a9 100644 --- a/hacking/nix/rust-utils/build-crates-in-layers.nix +++ b/hacking/nix/rust-utils/build-crates-in-layers.nix @@ -43,7 +43,7 @@ in , lastLayerModifications ? {} , release ? false -, profile ? if release then "release" else null +, profile ? if release then "release" else (if test then "test" else "dev") , features ? [] , noDefaultFeatures ? false diff --git a/hacking/nix/rust-utils/build-sysroot.nix b/hacking/nix/rust-utils/build-sysroot.nix index 8ad68557b..b90c00092 100644 --- a/hacking/nix/rust-utils/build-sysroot.nix +++ b/hacking/nix/rust-utils/build-sysroot.nix @@ -13,7 +13,7 @@ { rustEnvironment ? defaultRustEnvironment , targetTriple ? defaultRustTargetTriple , release ? true -, profile ? if release then "release" else null +, profile ? if release then "release" else "dev" , alloc ? true , std ? false , compilerBuiltinsMem ? true diff --git a/hacking/nix/scope/world/mk-task.nix b/hacking/nix/scope/world/mk-task.nix index cc9a8e255..f90d22e7c 100644 --- a/hacking/nix/scope/world/mk-task.nix +++ b/hacking/nix/scope/world/mk-task.nix @@ -31,9 +31,11 @@ in , replaceSysroot ? null , getELF ? if test then getELFDefaultForTest else getELFDefault -, test ? false , release ? false , profile ? if release then "release" else (if test then "test" else "dev") + +, test ? false + , ... } @ args: diff --git a/hacking/nix/scope/world/sel4-kernel-loader.nix b/hacking/nix/scope/world/sel4-kernel-loader.nix index b0bab1dd8..106c13e16 100644 --- a/hacking/nix/scope/world/sel4-kernel-loader.nix +++ b/hacking/nix/scope/world/sel4-kernel-loader.nix @@ -17,8 +17,9 @@ let rootCrate = crates.sel4-kernel-loader; - profile = "release"; - # profile = "dev"; + release = true; + + profile = if release then "release" else "dev"; profiles = crateUtils.clobber [ { From 16928d3345d04607e95c72bc8ba6748a4530fcfa Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 07:20:23 +0000 Subject: [PATCH 10/13] nix: Default to building with --release Signed-off-by: Nick Spinale --- hacking/nix/rust-utils/build-crates-in-layers.nix | 2 +- hacking/nix/scope/world/mk-task.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hacking/nix/rust-utils/build-crates-in-layers.nix b/hacking/nix/rust-utils/build-crates-in-layers.nix index e0365b8a9..aafff843c 100644 --- a/hacking/nix/rust-utils/build-crates-in-layers.nix +++ b/hacking/nix/rust-utils/build-crates-in-layers.nix @@ -42,7 +42,7 @@ in , commonModifications ? {} , lastLayerModifications ? {} -, release ? false +, release ? true , profile ? if release then "release" else (if test then "test" else "dev") , features ? [] diff --git a/hacking/nix/scope/world/mk-task.nix b/hacking/nix/scope/world/mk-task.nix index f90d22e7c..f45de1a5f 100644 --- a/hacking/nix/scope/world/mk-task.nix +++ b/hacking/nix/scope/world/mk-task.nix @@ -31,7 +31,7 @@ in , replaceSysroot ? null , getELF ? if test then getELFDefaultForTest else getELFDefault -, release ? false +, release ? true , profile ? if release then "release" else (if test then "test" else "dev") , test ? false From 559396118715467b10b4c8e614425520d99a9ade Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 07:40:22 +0000 Subject: [PATCH 11/13] nix: Fix formatting Signed-off-by: Nick Spinale --- hacking/nix/scope/world/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hacking/nix/scope/world/default.nix b/hacking/nix/scope/world/default.nix index fd2051fc5..2e02c12cc 100644 --- a/hacking/nix/scope/world/default.nix +++ b/hacking/nix/scope/world/default.nix @@ -130,7 +130,7 @@ self: with self; inherit (worldConfig) kernelLoaderConfig; }; - mkSeL4KernelLoaderWithPayload = { appELF } : callPackage ./mk-sel4-kernel-loader-with-payload.nix {} { + mkSeL4KernelLoaderWithPayload = { appELF }: callPackage ./mk-sel4-kernel-loader-with-payload.nix {} { app = appELF; }; From 17310e85cadfa6d39333e4fbccf97bb50629426f Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 09:07:57 +0000 Subject: [PATCH 12/13] nix: Remove musl special case Signed-off-by: Nick Spinale --- hacking/nix/scope/default.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hacking/nix/scope/default.nix b/hacking/nix/scope/default.nix index 473a1115e..53dda5e00 100644 --- a/hacking/nix/scope/default.nix +++ b/hacking/nix/scope/default.nix @@ -89,11 +89,7 @@ superCallPackage ../rust-utils {} self // else ( if platform.isNone then "${rustToolchain}/lib/rustlib/${buildPlatform.config}/bin/rust-lld" - else ( - if platform.isMusl # HACK for proper static linking on musl - then "${cc.targetPrefix}ld" - else "${cc.targetPrefix}cc" - ) + else "${cc.targetPrefix}cc" ); vendoredSuperLockfile = vendoredTopLevelLockfile; From e4aa3f092d8fa8aa999284ec89673547820fa15b Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Fri, 21 Jun 2024 09:08:11 +0000 Subject: [PATCH 13/13] nix: Clean up Signed-off-by: Nick Spinale --- hacking/nix/rust-utils/crate-utils.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hacking/nix/rust-utils/crate-utils.nix b/hacking/nix/rust-utils/crate-utils.nix index d14c3d1c4..ca59429a2 100644 --- a/hacking/nix/rust-utils/crate-utils.nix +++ b/hacking/nix/rust-utils/crate-utils.nix @@ -105,9 +105,7 @@ rec { }; in lib.optionalAttrs (linker != null) { - target = { - "${targetTriple.name}".linker = linker; - }; + target."${targetTriple.name}".linker = linker; }; in clobber [