From 3f95111302aa2599ac273bdabd566a12b126cbff Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Wed, 29 Apr 2026 11:40:30 +0100 Subject: [PATCH 1/9] disable other workflows --- .github/workflows/main.yml | 10 +- .github/workflows/morello.yml | 10 +- .github/workflows/reusable-cmake-build.yml | 122 ++++++++++----------- .github/workflows/reusable-vm-build.yml | 68 ++++++------ .github/workflows/rust.yml | 8 +- 5 files changed, 109 insertions(+), 109 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 237e5a749..1890fd68e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,11 +8,11 @@ concurrency: # Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the master branch - push: - branches: [ main ] - pull_request: - branches: [ main, snmalloc1 ] + # # Triggers the workflow on push or pull request events but only for the master branch + # push: + # branches: [ main ] + # pull_request: + # branches: [ main, snmalloc1 ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.github/workflows/morello.yml b/.github/workflows/morello.yml index 68cebc407..d81166273 100644 --- a/.github/workflows/morello.yml +++ b/.github/workflows/morello.yml @@ -1,11 +1,11 @@ name: snmalloc CI for Morello on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [ main ] - pull_request: - branches: [ main ] + # # Triggers the workflow on push or pull request events but only for the main branch + # push: + # branches: [ main ] + # pull_request: + # branches: [ main ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.github/workflows/reusable-cmake-build.yml b/.github/workflows/reusable-cmake-build.yml index fe83359b7..83da6f3af 100644 --- a/.github/workflows/reusable-cmake-build.yml +++ b/.github/workflows/reusable-cmake-build.yml @@ -1,66 +1,66 @@ name: Reusable CMake Build -on: - workflow_call: - inputs: - os: - required: true - type: string - description: 'Runner OS (e.g., ubuntu-24.04, macos-14, windows-2022)' - build-type: - required: true - type: string - description: 'CMake build type (Release, Debug)' - cmake-config: - required: false - type: string - default: '-G Ninja' - description: 'CMake configuration options (-G, -A, -T, compiler flags)' - extra-cmake-flags: - required: false - type: string - default: '' - description: 'Additional CMake flags for the project' - dependencies: - required: false - type: string - default: '' - description: 'Command to install dependencies' - build-only: - required: false - type: boolean - default: false - description: 'Skip tests if true' - self-host: - required: false - type: boolean - default: false - description: 'Run self-hosting test' - check-binary-size: - required: false - type: boolean - default: true - description: 'Check binary size is reasonable' - test-exclude-pattern: - required: false - type: string - default: '' - description: 'Regex pattern for tests to exclude' - test-extra-args: - required: false - type: string - default: '' - description: 'Extra arguments for ctest' - use-msbuild: - required: false - type: boolean - default: false - description: 'Use MSBuild instead of Ninja for building' - timeout-minutes: - required: false - type: number - default: 30 - description: 'Job timeout in minutes' +# on: +# workflow_call: +# inputs: +# os: +# required: true +# type: string +# description: 'Runner OS (e.g., ubuntu-24.04, macos-14, windows-2022)' +# build-type: +# required: true +# type: string +# description: 'CMake build type (Release, Debug)' +# cmake-config: +# required: false +# type: string +# default: '-G Ninja' +# description: 'CMake configuration options (-G, -A, -T, compiler flags)' +# extra-cmake-flags: +# required: false +# type: string +# default: '' +# description: 'Additional CMake flags for the project' +# dependencies: +# required: false +# type: string +# default: '' +# description: 'Command to install dependencies' +# build-only: +# required: false +# type: boolean +# default: false +# description: 'Skip tests if true' +# self-host: +# required: false +# type: boolean +# default: false +# description: 'Run self-hosting test' +# check-binary-size: +# required: false +# type: boolean +# default: true +# description: 'Check binary size is reasonable' +# test-exclude-pattern: +# required: false +# type: string +# default: '' +# description: 'Regex pattern for tests to exclude' +# test-extra-args: +# required: false +# type: string +# default: '' +# description: 'Extra arguments for ctest' +# use-msbuild: +# required: false +# type: boolean +# default: false +# description: 'Use MSBuild instead of Ninja for building' +# timeout-minutes: +# required: false +# type: number +# default: 30 +# description: 'Job timeout in minutes' jobs: build: diff --git a/.github/workflows/reusable-vm-build.yml b/.github/workflows/reusable-vm-build.yml index bc4e2e1a8..76f36ab76 100644 --- a/.github/workflows/reusable-vm-build.yml +++ b/.github/workflows/reusable-vm-build.yml @@ -1,39 +1,39 @@ name: Reusable VM Build -on: - workflow_call: - inputs: - vm-type: - required: true - type: string - description: 'VM type (freebsd, netbsd, openbsd)' - vm-version: - required: true - type: string - description: 'VM version' - build-type: - required: true - type: string - description: 'CMake build type' - dependencies: - required: true - type: string - description: 'Commands to install dependencies' - cmake-flags: - required: false - type: string - default: '' - description: 'Additional CMake flags' - host-os: - required: false - type: string - default: 'ubuntu-22.04' - description: 'Host runner OS' - timeout-minutes: - required: false - type: number - default: 25 - description: 'Job timeout in minutes' +# on: +# workflow_call: +# inputs: +# vm-type: +# required: true +# type: string +# description: 'VM type (freebsd, netbsd, openbsd)' +# vm-version: +# required: true +# type: string +# description: 'VM version' +# build-type: +# required: true +# type: string +# description: 'CMake build type' +# dependencies: +# required: true +# type: string +# description: 'Commands to install dependencies' +# cmake-flags: +# required: false +# type: string +# default: '' +# description: 'Additional CMake flags' +# host-os: +# required: false +# type: string +# default: 'ubuntu-22.04' +# description: 'Host runner OS' +# timeout-minutes: +# required: false +# type: number +# default: 25 +# description: 'Job timeout in minutes' jobs: build: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cb070f78b..1d43c695a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -7,10 +7,10 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} on: - push: - branches: [ main ] - pull_request: - branches: [ main ] + # push: + # branches: [ main ] + # pull_request: + # branches: [ main ] workflow_dispatch: From cd20db11b01255facb15217548e87c472762653b Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Wed, 29 Apr 2026 10:24:52 +0100 Subject: [PATCH 2/9] workflow: initial commit to see what happens Signed-off-by: Harrison Carter --- .github/workflows/capable-workflow.yml | 112 +++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/capable-workflow.yml diff --git a/.github/workflows/capable-workflow.yml b/.github/workflows/capable-workflow.yml new file mode 100644 index 000000000..7e05174e2 --- /dev/null +++ b/.github/workflows/capable-workflow.yml @@ -0,0 +1,112 @@ +name: snmalloc CI for Morello at The Capable Hub + +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + pull_request: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + inputs: + bootenv_label: + description: "Morello host environment" + type: string + required: true + default: "benchmark" + + runqueue_label: + description: "Morello runner queue (production or test scripts?)" + required: true + type: choice + options: + - "msr-morello" + - "msr-morello-test" + +jobs: + # UNIX-like, but with some needed TLC for the moment, so not folded in to the main unixlike CI. + # Morello can't easily self-host since it mixes purecap and hybrid build tools. + # We point cmake at the LLVM Clang frontend explicitly lest it pick up the more magic wrappers. + morello: + strategy: + matrix: + # Build each combination of OS and release/debug variants + os: [ "morello" ] + build-type: [ Release, Debug ] + caps: [ Hybrid, Purecap ] + include: + - os: "morello" + caps: Hybrid + dependencies: >- + cmake ninja-build + cmake-flags: > + -DCMAKE_CXX_COMPILER=/root/llvm-cheri/install/bin/clang++ + -DCMAKE_C_COMPILER=/root/llvm-cheri/install/bin/clang + -DCMAKE_CXX_FLAGS='-march=morello -Xclang -morello-vararg=new' + -DCMAKE_C_FLAGS='-march=morello -Xclang -morello-vararg=new' + - os: "morello" + caps: Purecap + dependencies: >- + cmake ninja-build + cmake-flags: > + -DCMAKE_CXX_COMPILER=/root/llvm-cheri/install/bin/clang++ + -DCMAKE_C_COMPILER=/root/llvm-cheri/install/bin/clang + -DCMAKE_CXX_FLAGS='-march=morello -mabi=purecap -Xclang -morello-vararg=new' + -DCMAKE_C_FLAGS='-march=morello -mabi=purecap -Xclang -morello-vararg=new' + # Don't abort runners if a single one fails + fail-fast: false + # Morello needs special handling to get picked up by our self-hosted runners + # When/if we do integrate this back into the unixlike matrix above, we could + # say something like:: + # runs-on: >- + # ${{ (matrix.os == 'morello' && fromJSON('["self-hosted", "msr-morello", "benchmark"]')) + # || matrix.os }} + # to dispatch dynamically. + runs-on: self-hosted + # runs-on: the-capable-hub-aws-ci + env: + BUILD_DIR: ${{github.workspace}}/volatile/${{ github.job }} + container: + image: capablehub/cheri-ca-llvm:19-riscv64-latest + steps: + - uses: actions/checkout@v2 + - name: Log environment details + run: | + uname -a + mount + - name: Configure CMake + run: | + # ${{github.workspace}}/build + apt-get update + apt-get -yy install ${{ matrix.dependencies }} + ls -l /root + cmake --version + which clang + ls -l `which clang` + clang --version + which clang++ + ls -l `which clang++` + clang++ --version + mkdir -p ./build + + cmake \ + -B ./build \ + -DCMAKE_BUILD_TYPE=${{matrix.build-type}} \ + -G Ninja ${{ matrix.cmake-flags }} \ + ${{ matrix.extra-cmake-flags }} + # Build with a nice ninja status line + - name: Build + working-directory: ./build + run: | + NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja + - name: Test file size of binaries is sane + working-directory: ./build + run: | + ls -l func-first_operation-fast ; [ $(ls -l func-first_operation-fast | awk '{ print $5}') -lt 10000000 ] + # If the tests are enabled for this job, run them + - name: Test + if: ${{ matrix.build-only != 'yes' }} + working-directory: ${{github.workspace}}/build + run: | + ctest --output-on-failure -j 4 -C ${{ matrix.build-type }} --timeout 400 From 78d3e0d5cfb2497088e7aa32fff0a31c3665fcf6 Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Tue, 19 May 2026 08:45:28 +0100 Subject: [PATCH 3/9] pal: linux: add CHERI provenance and headers Signed-off-by: Harrison Carter --- src/snmalloc/pal/pal_linux.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/snmalloc/pal/pal_linux.h b/src/snmalloc/pal/pal_linux.h index 251aaf321..df14e823f 100644 --- a/src/snmalloc/pal/pal_linux.h +++ b/src/snmalloc/pal/pal_linux.h @@ -19,6 +19,13 @@ # include # endif +# if defined(__CHERI_PURE_CAPABILITY__) //&& defined(__MORELLO__) +# include +# if !defined(CHERI_PERM_SW_VMEM) +# define CHERI_PERM_SW_VMEM CHERI_PERM_CHERIABI_VMMAP +# endif +# endif + # include namespace snmalloc @@ -161,6 +168,33 @@ namespace snmalloc madvise(p, size, MADV_DONTDUMP); } +# if defined(__CHERI_PURE_CAPABILITY__) + static_assert( + aal_supports, + "CHERI purecap support requires StrictProvenance AAL"); + + /** + * On CheriBSD, exporting a pointer means stripping it of the authority to + * manage the address space it references by clearing the SW_VMEM + * permission bit (Which sounds appropriate on Linux, too). + */ + template + static SNMALLOC_FAST_PATH CapPtr> + capptr_to_user_address_control(CapPtr p) + { + if constexpr (Aal::aal_cheri_features & Aal::AndPermsTrapsUntagged) + { + if (p == nullptr) + { + return nullptr; + } + } + return CapPtr>::unsafe_from( + __builtin_cheri_perms_and( + p.unsafe_ptr(), ~static_cast(CHERI_PERM_SW_VMEM))); + } +# endif + static uint64_t get_entropy64() { KeepErrno k; From 077a3ee8293a62660c7b3044a0371a38b9ae5a9a Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Tue, 19 May 2026 15:12:42 +0100 Subject: [PATCH 4/9] pal: port to cherilinux Signed-off-by: Harrison Carter --- src/snmalloc/pal/pal_linux.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/snmalloc/pal/pal_linux.h b/src/snmalloc/pal/pal_linux.h index df14e823f..500e53cd6 100644 --- a/src/snmalloc/pal/pal_linux.h +++ b/src/snmalloc/pal/pal_linux.h @@ -213,7 +213,7 @@ namespace snmalloc char buffer[sizeof(uint64_t)]; }; - ssize_t ret; + intptr_t ret; // give a try to SYS_getrandom # ifdef SYS_getrandom @@ -237,7 +237,10 @@ namespace snmalloc // 2. `GRND_NONBLOCK` bit is set. Since we are reading from // `urandom`, this means if the entropy pool is // not initialised, we will get a EAGAIN. - ret = syscall(SYS_getrandom, current, length, GRND_NONBLOCK); + ret = syscall(SYS_getrandom, + current, + length, + GRND_NONBLOCK); // check whether are interrupt by a signal if (SNMALLOC_UNLIKELY(ret < 0)) { From 9d39780d4ddc73acf34d7da6f1af78937c3920fc Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Tue, 19 May 2026 15:30:34 +0100 Subject: [PATCH 5/9] memory: add backup rlim64_t define Signed-off-by: Harrison Carter --- src/test/func/memory/memory.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/func/memory/memory.cc b/src/test/func/memory/memory.cc index 7c181a24a..195a33391 100644 --- a/src/test/func/memory/memory.cc +++ b/src/test/func/memory/memory.cc @@ -29,7 +29,10 @@ # ifdef __OpenBSD__ using rlim64_t = rlim_t; +# elif defined(__linux__) +using rlim64_t = size_t; # endif + #else using rlim64_t = size_t; #endif From 13f94745c4b6fe228b3a207ddac90e3b63f0b0a7 Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Tue, 19 May 2026 15:45:28 +0100 Subject: [PATCH 6/9] test: cheri: amend header inclusion Signed-off-by: Harrison Carter --- src/test/func/cheri/cheri.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/func/cheri/cheri.cc b/src/test/func/cheri/cheri.cc index 1928dbbd5..79097500e 100644 --- a/src/test/func/cheri/cheri.cc +++ b/src/test/func/cheri/cheri.cc @@ -10,7 +10,12 @@ int main() // # define SNMALLOC_TRACING +# if defined(__FreeBSD__) # include +# else +# include +# endif + # include # include From 814d900b2670e69a66c3730cc3423901d391a5f7 Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Tue, 19 May 2026 16:06:02 +0100 Subject: [PATCH 7/9] test: cheri: fix alloc config Signed-off-by: Harrison Carter --- src/test/func/cheri/cheri.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/func/cheri/cheri.cc b/src/test/func/cheri/cheri.cc index 79097500e..b56aa6b7a 100644 --- a/src/test/func/cheri/cheri.cc +++ b/src/test/func/cheri/cheri.cc @@ -12,7 +12,7 @@ int main() # if defined(__FreeBSD__) # include -# else +# else # include # endif @@ -135,10 +135,10 @@ int main() */ message("Grab Alloc from pool for inspection"); { - static_assert( - std::is_same_v>); + static_assert(std::is_same_v&>); - auto* ca = AllocPool::acquire(); + auto* ca = AllocPool::acquire(); SNMALLOC_CHECK(cap_len_is(ca, sizeof(*ca))); SNMALLOC_CHECK(cap_vmem_perm_is(ca, false)); From d7b43e25caaee6f4cb2642df6210e334415e921a Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Wed, 20 May 2026 10:22:50 +0100 Subject: [PATCH 8/9] threadalloc: redef atext impl Signed-off-by: Harrison Carter --- src/snmalloc/global/threadalloc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/snmalloc/global/threadalloc.h b/src/snmalloc/global/threadalloc.h index d037995e5..37dfd61cc 100644 --- a/src/snmalloc/global/threadalloc.h +++ b/src/snmalloc/global/threadalloc.h @@ -26,6 +26,7 @@ # error At most one out of method of thread teardown can be specified. # endif # define SNMALLOC_THREAD_TEARDOWN_DEFINED +# define __cxa_thread_atexit_impl __cxa_thread_atexit extern "C" int __cxa_thread_atexit_impl(void(func)(void*), void*, void*); extern "C" void* __dso_handle; #endif From 59b698fbc189aec0cbce6385c9a9ac0037dc75e5 Mon Sep 17 00:00:00 2001 From: Harrison Carter Date: Fri, 22 May 2026 10:59:24 +0100 Subject: [PATCH 9/9] workflow: add triples to enable morello Signed-off-by: Harrison Carter --- .github/workflows/capable-workflow.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/capable-workflow.yml b/.github/workflows/capable-workflow.yml index 7e05174e2..d39851710 100644 --- a/.github/workflows/capable-workflow.yml +++ b/.github/workflows/capable-workflow.yml @@ -50,6 +50,9 @@ jobs: dependencies: >- cmake ninja-build cmake-flags: > + -DCMAKE_ASM_COMPILER_TARGET=aarch64-unknown-linux-musl_purecap + -DCMAKE_C_COMPILER_TARGET=aarch64-unknown-linux-musl_purecap + -DCMAKE_CXX_COMPILER_TARGET=aarch64-unknown-linux-musl_purecap -DCMAKE_CXX_COMPILER=/root/llvm-cheri/install/bin/clang++ -DCMAKE_C_COMPILER=/root/llvm-cheri/install/bin/clang -DCMAKE_CXX_FLAGS='-march=morello -mabi=purecap -Xclang -morello-vararg=new'