diff --git a/Cargo.lock b/Cargo.lock index 532c1cd..867c643 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,9 +202,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libloading" @@ -224,9 +224,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -274,9 +274,9 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "pest" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", "thiserror", @@ -285,9 +285,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" dependencies = [ "pest", "pest_generator", @@ -295,9 +295,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", @@ -308,9 +308,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" dependencies = [ "once_cell", "pest", @@ -391,9 +391,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.33" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3cc72858054fcff6d7dea32df2aeaee6a7c24227366d7ea429aada2f26b16ad" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags", "errno", @@ -417,7 +417,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sel4" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "cfg-if", "sel4-config", @@ -427,12 +427,12 @@ dependencies = [ [[package]] name = "sel4-bitfield-ops" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" [[package]] name = "sel4-bitfield-parser" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "pest", "pest_derive", @@ -442,12 +442,12 @@ dependencies = [ [[package]] name = "sel4-build-env" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" [[package]] name = "sel4-config" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "sel4-config-data", "sel4-config-generic", @@ -458,7 +458,7 @@ dependencies = [ [[package]] name = "sel4-config-data" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "lazy_static", "sel4-build-env", @@ -469,7 +469,7 @@ dependencies = [ [[package]] name = "sel4-config-generic" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "fallible-iterator", "proc-macro2", @@ -481,7 +481,7 @@ dependencies = [ [[package]] name = "sel4-config-generic-types" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "serde", ] @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "sel4-config-macros" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "sel4-config-data", "sel4-config-generic", @@ -498,7 +498,7 @@ dependencies = [ [[package]] name = "sel4-dlmalloc" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "dlmalloc", "lock_api", @@ -507,17 +507,17 @@ dependencies = [ [[package]] name = "sel4-elf-header" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" [[package]] name = "sel4-immediate-sync-once-cell" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" [[package]] name = "sel4-initialize-tls" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "cfg-if", ] @@ -525,7 +525,7 @@ dependencies = [ [[package]] name = "sel4-panicking" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "cfg-if", "rustc_version", @@ -537,12 +537,12 @@ dependencies = [ [[package]] name = "sel4-panicking-env" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" [[package]] name = "sel4-root-task" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "sel4", "sel4-dlmalloc", @@ -557,7 +557,7 @@ dependencies = [ [[package]] name = "sel4-root-task-macros" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "proc-macro2", "quote", @@ -567,7 +567,7 @@ dependencies = [ [[package]] name = "sel4-runtime-common" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "cfg-if", "sel4", @@ -580,7 +580,7 @@ dependencies = [ [[package]] name = "sel4-rustfmt-helper" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "which", ] @@ -588,7 +588,7 @@ dependencies = [ [[package]] name = "sel4-sync" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "lock_api", "sel4", @@ -598,7 +598,7 @@ dependencies = [ [[package]] name = "sel4-sys" version = "0.1.0" -source = "git+https://github.com/seL4/rust-sel4#a20aab14c0533d3145a2db75020e60151ce9b78f" +source = "git+https://github.com/seL4/rust-sel4#96e2b8c74d8fa1308d221e98134acaff68d151a6" dependencies = [ "bindgen", "glob", @@ -623,18 +623,18 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.198" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", diff --git a/Makefile b/Makefile index e9c2640..a050429 100644 --- a/Makefile +++ b/Makefile @@ -8,40 +8,39 @@ BUILD ?= build build_dir := $(BUILD) +.PHONY: none +none: + +.PHONY: clean +clean: + rm -rf $(build_dir) + sel4_prefix := $(SEL4_INSTALL_DIR) # Kernel loader binary artifacts provided by Docker container: # - `sel4-kernel-loader`: The loader binary, which expects to have a payload appended later via # binary patch. # - `sel4-kernel-loader-add-payload`: CLI which appends a payload to the loader. -loader_artifacts_dir := /deps/bin +loader_artifacts_dir := $(SEL4_INSTALL_DIR)/bin loader := $(loader_artifacts_dir)/sel4-kernel-loader loader_cli := $(loader_artifacts_dir)/sel4-kernel-loader-add-payload -.PHONY: none -none: - -.PHONY: clean -clean: - rm -rf $(build_dir) - app_crate := example app := $(build_dir)/$(app_crate).elf -app_intermediate := $(build_dir)/$(app_crate).intermediate -$(app): $(app_intermediate) +$(app): $(app).intermediate # SEL4_TARGET_PREFIX is used by build.rs scripts of various rust-sel4 crates to locate seL4 # configuration and libsel4 headers. -.INTERMDIATE: $(app_intermediate) -$(app_intermediate): +.INTERMDIATE: $(app).intermediate +$(app).intermediate: SEL4_PREFIX=$(sel4_prefix) \ cargo build \ -Z build-std=core,alloc,compiler_builtins \ -Z build-std-features=compiler-builtins-mem \ - --target aarch64-sel4 \ - --target-dir $(abspath $(build_dir)/target) \ + --target-dir $(build_dir)/target \ --out-dir $(build_dir) \ + --target aarch64-sel4 \ -p $(app_crate) image := $(build_dir)/image.elf @@ -56,8 +55,9 @@ $(image): $(app) $(loader) $(loader_cli) qemu_cmd := \ qemu-system-aarch64 \ - -machine virt,virtualization=on -cpu cortex-a57 -m 1024 \ - -nographic -serial mon:stdio \ + -machine virt,virtualization=on -cpu cortex-a57 -m size=1G \ + -serial mon:stdio \ + -nographic \ -kernel $(image) .PHONY: run diff --git a/docker/Dockerfile b/docker/Dockerfile index 234b15f..6c93ed1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,33 +6,37 @@ FROM trustworthysystems/sel4 +WORKDIR /tmp + +RUN rm -r * + RUN apt-get update -q && apt-get install -y --no-install-recommends \ - sudo man vim \ - bash-completion \ + bash-completion man sudo \ && rm -rf /var/lib/apt/lists/* RUN curl -sSf https://sh.rustup.rs | \ - bash -s -- -y --no-modify-path --default-toolchain none + bash -s -- -y --no-modify-path \ + --default-toolchain nightly-2024-05-01 \ + --component rust-src ENV PATH=/root/.cargo/bin:$PATH -RUN mkdir /deps - -WORKDIR /deps +ENV SEL4_INSTALL_DIR=/opt/seL4 RUN set -eux; \ git clone \ https://github.com/seL4/seL4.git \ --config advice.detachedHead=false; \ cd seL4; \ - git checkout a58480425c5b4c7a3d5000c797f083bc7d5fd532; + git checkout 0260fba168b74dd2504c9447f2fa8da1161ead87; RUN set -eux; \ cd seL4; \ cmake \ -DCROSS_COMPILER_PREFIX=aarch64-linux-gnu- \ - -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_INSTALL_PREFIX=$SEL4_INSTALL_DIR \ -DKernelPlatform=qemu-arm-virt \ + # TODO further develop kernel loader to make KernelArmHypervisorSupport=ON unecessary -DKernelArmHypervisorSupport=ON \ -DKernelVerificationBuild=OFF \ -DARM_CPU=cortex-a57 \ @@ -40,48 +44,54 @@ RUN set -eux; \ -S . \ -B build; \ ninja -C build all; \ - ninja -C build install; - -ENV SEL4_INSTALL_DIR=/deps/seL4/install + ninja -C build install; \ + rm -rf $(pwd); RUN set -eux; \ - export RUSTUP_TOOLCHAIN=nightly-2024-03-09; \ - rustup component add rust-src; \ url="https://github.com/seL4/rust-sel4"; \ rev="a20aab14c0533d3145a2db75020e60151ce9b78f"; \ - remote_options="--git $url --rev $rev"; \ - CC=aarch64-linux-gnu-gcc \ + common_args="--git $url --rev $rev --root $SEL4_INSTALL_DIR"; \ + CC_aarch64_unknown_none=aarch64-linux-gnu-gcc \ SEL4_PREFIX=$SEL4_INSTALL_DIR \ cargo install \ -Z build-std=core,compiler_builtins \ -Z build-std-features=compiler-builtins-mem \ --target aarch64-unknown-none \ - --root . \ - $remote_options \ + $common_args \ sel4-kernel-loader; \ cargo install \ - --root . \ - $remote_options \ + $common_args \ sel4-kernel-loader-add-payload; ARG UID ARG GID RUN set -eux; \ - if ! getent group $GID; then \ - groupadd -g $GID x; \ - fi; \ - if ! getent passwd $UID; then \ - useradd -u $UID -g $GID -G sudo -m -p x x; \ + if [ $UID -eq 0 ]; then \ + if [ $GID -ne 0 ]; then \ + echo "error: \$UID == 0 but \$GID != 0" >&2; \ + exit 1; \ + fi; \ + else \ + if getent passwd $UID; then \ + echo "error: \$UID $UID already exists" >&2; \ + exit 1; \ + fi; \ + if ! getent group $GID; then \ + groupadd --gid $GID x; \ + fi; \ + useradd --uid $UID --gid $GID --groups sudo --create-home x; \ fi; -RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers # for convenience +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers -USER $UID:$GID +USER $UID -# This time, for the non-root user -RUN curl -sSf https://sh.rustup.rs | \ - bash -s -- -y --no-modify-path --default-toolchain none +RUN set -eux; \ + if [ $UID -ne 0 ]; then \ + curl -sSf https://sh.rustup.rs | \ + bash -s -- -y --no-modify-path --default-toolchain none; \ + fi; ENV PATH=/home/x/.cargo/bin:$PATH diff --git a/docker/Makefile b/docker/Makefile index 0da4081..cfed63c 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -42,5 +42,6 @@ rm-container: test: build docker run --rm \ --mount type=bind,readonly,src=$(abspath $(work_root)),dst=/work \ - -i $(image_tag) \ + -i $$([ -t 0 ] && echo -t) \ + $(image_tag) \ make test BUILD=/tmp/build diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 67fd13b..84a9735 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -5,5 +5,5 @@ # [toolchain] -channel = "nightly-2024-03-09" +channel = "nightly-2024-05-01" components = [ "rustfmt", "rust-src", "rustc-dev", "llvm-tools-preview" ] diff --git a/support/targets/aarch64-sel4.json b/support/targets/aarch64-sel4.json index 670a527..0432c64 100644 --- a/support/targets/aarch64-sel4.json +++ b/support/targets/aarch64-sel4.json @@ -2,7 +2,6 @@ "arch": "aarch64", "crt-objects-fallback": "false", "data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", - "description": null, "disable-redzone": true, "env": "sel4", "exe-suffix": ".elf", @@ -12,6 +11,12 @@ "linker-flavor": "gnu-lld", "llvm-target": "aarch64-unknown-none", "max-atomic-width": 128, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "pre-link-args": { "gnu-lld": [ "-z",