Evaluation of performance and security strengths of library-based compartments created on Morello Boards
This repository evaluates compartments created using the library-based compartmentalisation tool available on Morello Boards running the cheriBSD 24.5 operating system. It evaluates the performance costs incurred by the compartments and the strengths of the memory isolation that they provide. It provides links to the Git repositories that store the C and Python codes used in the evaluation and the metrics collected in CSV files. It also includes the plots of the results, a discussion of our interpretation and detailed instructions to encourage practitioners to repeat our experiments and compare their results against ours.
We utilise a Morello Board, physically located in Toronto. A laptop connected to the network in Brazil is used to access the Morello Board via an SSH connection. Presented below is the primary configuration of the Morello Board, along with additional parameters, including the CheriBSD commands required to retrieve these configurations directly from the board. We specify the hardware and software configurations of the Morello Board used in the experiments in Table 1.
Table 1 lists the configuration parameters of the Morello Board used in the experiments, along with CheriBSD commands to verify them.
| Component | Specification | Command |
|---|---|---|
| Operating System | CheriBSD 24.5 (FreeBSD 15.0-CURRENT) | uname -a |
| Kernel Version | FreeBSD 15.0-CURRENT, releng/24.05 | uname -v |
| Board | Morello System Development Platform | `kenv |
| RAM | 17 GB detected (16 GB DDR4, 2933 MT/s, ECC) | dmidecode --type memory |
| Storage | SSD | camcontrol identify ada0 |
| Architecture | aarch64c (with CHERI support) | sysctl hw.machine_arch |
| Processor Model | Research Morello SoC r0p0 | sysctl hw.model |
| Number of CPUs | 4 | sysctl hw.ncpu |
| Compiler | clang (with Morello support) | clang-morello --version |
| Tool | proccontrol (for CHERI compartments) | proccontrol -m cheric18n -s enable ./binary |
| Python | Python 3 (required for Experiments 1, 5, and 6) | python3 --version |
| Access | Remote via SSH | ssh -i private_key user@server |
The inclusion of library-based compartments is determined at compilation and execution time. It is documented in:
- CHERI Software Compartmentalization Robert Watson, 2019.
- Library-based Compartmentalisation Cheri team, 2022.
- User-level software compartmentalization (experimental) Cheri team, 2024.
- Compartmentalization, c18n — Library-based software compartmentalization Dapeng Gao, 2024.
- Library-based Compartmentalisation on CHERI Dapeng Gao and Robert Watson, Plarch2023.
- Dapeng's Video Presentation (Plarch2023) provides a summary of the architecture. Watch here.
As explained in the User Level Process Environments, in CheriBSD 24.05, a user can compile a program to run in three different execution environments:
- CheriABI processes: Use
-mabi=purecap. - Benchmark ABI processes: Use
-mabi=purecap-benchmark.
A useful example of the compilation of helloworld.c can be found here.
To verify the ABI targeted by the compiler, the following command can be used:
root# file binaryPrograms to be run in library-based compartments can be compiled with either -mabi=purecap or -mabi=purecap-benchmark. However, for performance evaluation, the latter is recommended. See man compartmentalization for details.
To compile and execute a program without using library-based compartments, use:
$ clang-morello -o hello hello.c
$ ./helloworldTo enable library-based compartments during compilation, use:
$ clang-morello -march=morello+c64 -mabi=purecap -o helloworld helloworld.c-march=morello+c64: Defines the 64-bit Morello architecture.-mabi=purecap: Targets the Application Binary Interface (ABI), implementing all memory references and pointers as capabilities.
To execute the compiled program within a library-based compartment, use:
$ proccontrol -m cheric18n -s enable helloworldThe proccontrol command enables execution within a library-based compartment.
The compilation and execution process for purecap-benchmark ABI is similar to purecap ABI, with the exception of using:
$ clang-morello -march=morello+c64 -mabi=purecap-benchmark -o helloworld helloworld.c
$ proccontrol -m cheric18n -s enable helloworldIn this experiment, we executed a set of memory operations on large blocks and measured their execution time. The operations evaluated were:
- malloc: Time taken to allocate the block of memory.
- write: Time taken to write data to fill the entire memory block.
- read: Time taken to read the data from the entire memory block.
- free: Time taken to release the memory block.
We used blocks of 100 MB, 200 MB, 300 MB, ..., 1000 MB, which are typical sizes for applications that process images and access databases.
perform_tests(log_file, total_time)
begin
foreach block_size in MIN_BLOCK_SIZE to MAX_BLOCK_SIZE step BLOCK_STEP do
foreach test_num from 1 to num_of_trials do
allocation_time = time(malloc(block_size))
write_time = time(write_to_memory(block, block_size))
read_time = time(read_from_memory(block, block_size))
free_time = time(free(block))
log(log_file, block_size, test_num, allocation_time, write_time, read_time, free_time)
endfor
endfor
endThe execution starts with the perform_tests function, which takes a log file name as input to store performance metrics. The outer loop iterates over different block sizes, while the inner loop repeats the test multiple times (num_of_trials) for statistical consistency. The measured times for allocation, writing, reading, and freeing operations are logged.
The C program was executed both outside compartments and inside compartments.
The source codes for the memory experiments are available here: memory-out-experiment.c, memory-in-experiment.c and memory-in-experiment-purecap-benchmark.c
The following tables present the execution times (mean ± standard deviation) of memory operations, summarised by block size, for executions inside compartments (purecap ABI and purecap-benchmark ABI) and outside compartments.
clang-morello -o memory-out-experiment memory-out-experiment.c -lm
./memory-out-experimentThe collected metrics are stored in:
memory-out-experiment-results.csv
| Block Size (MB) | Allocation Time (ms) | Write Time (ms) | Read Time (ms) | Free Time (ms) |
|---|---|---|---|---|
| 100 | 2.27 ± 4.77 | 282,583.77 ± 13.86 | 282,580.70 ± 12.79 | 6.06 ± 4.52 |
| 200 | 3.58 ± 4.19 | 565,164.33 ± 17.12 | 565,163.29 ± 18.85 | 10.29 ± 4.03 |
| 300 | 3.95 ± 1.77 | 847,755.11 ± 21.18 | 847,752.32 ± 64.89 | 13.42 ± 3.66 |
| 400 | 4.51 ± 3.09 | 1,130,330.18 ± 21.00 | 1,130,327.53 ± 28.20 | 14.38 ± 2.27 |
| 500 | 4.56 ± 3.07 | 1,412,907.30 ± 31.49 | 1,412,903.42 ± 28.92 | 15.17 ± 2.37 |
| 600 | 4.69 ± 1.56 | 1,695,492.67 ± 32.97 | 1,695,492.69 ± 30.19 | 16.20 ± 1.28 |
| 700 | 4.80 ± 1.52 | 1,978,083.02 ± 52.24 | 1,978,097.85 ± 79.47 | 17.07 ± 0.86 |
| 800 | 4.71 ± 1.73 | 2,260,662.02 ± 41.09 | 2,260,660.49 ± 53.11 | 17.57 ± 0.62 |
| 900 | 4.54 ± 0.54 | 2,543,248.84 ± 47.19 | 2,543,233.58 ± 42.16 | 17.57 ± 0.97 |
| 1000 | 4.57 ± 0.50 | 2,825,822.71 ± 47.72 | 2,825,817.71 ± 41.68 | 17.80 ± 0.64 |
clang-morello -march=morello+c64 -mabi=purecap -o memory-in-experiment-purecap memory-in-experiment-purecap.c -lm
proccontrol -m cheric18n -s enable memory-in-experiment-purecapMetrics are stored in:
memory-in-experiment-purecap-results.csv
The following table presents the execution time (mean ± standard deviation) of memory operations performed within compartments created for the purecap-benchmark ABI.
| Block Size (MB) | Allocation Time (ms) | Write Time (ms) | Read Time (ms) | Free Time (ms) |
|---|---|---|---|---|
| 100 | 81 ± 158.99 | 40,369 ± 4.84 | 80,737 ± 7.56 | 86 ± 178.33 |
| 200 | 92 ± 219.79 | 80,737 ± 6.36 | 161,472 ± 10.22 | 210 ± 395.51 |
| 300 | 94 ± 295.34 | 121,105 ± 7.88 | 242,209 ± 12.70 | 219 ± 452.59 |
| 400 | 122 ± 430.07 | 161,472 ± 8.04 | 322,946 ± 17.29 | 425 ± 783.85 |
| 500 | 153 ± 596.27 | 201,842 ± 11.20 | 403,681 ± 14.85 | 215 ± 417.51 |
| 600 | 146 ± 646.07 | 242,210 ± 12.87 | 484,417 ± 17.45 | 436 ± 917.23 |
| 700 | 191 ± 879.02 | 282,579 ± 13.21 | 565,154 ± 18.71 | 453 ± 987.35 |
| 800 | 213 ± 1,088.59 | 322,947 ± 14.35 | 645,893 ± 17.43 | 822 ± 1,529.08 |
| 900 | 283 ± 1,535.56 | 363,315 ± 14.68 | 726,626 ± 17.13 | 818 ± 1,587.88 |
| 1000 | 246 ± 1,538.68 | 403,685 ± 15.61 | 807,368 ± 18.86 | 443 ± 1,004.74 |
clang-morello -march=morello+c64 -mabi=purecap -o memory-in-experiment-purecap-benchmark memory-in-experiment-purecap-benchmark.c -lm
proccontrol -m cheric18n -s enable memory-in-experiment-purecap-benchmarkMetrics are stored in:
memory-in-experiment-purecap-benchmark-results.csv
The following plot compares the execution times of allocate, write, read, and free operations with and without compartments.
- Allocation Time: Memory allocation is significantly slower inside compartments. 100 MB takes ~2ms without a compartment but 93ms in Purecap ABI and 81ms in Purecap-Benchmark ABI.
- Write Time: Write operations increase linearly with block size, with execution inside compartments always taking longer.
- Read Time: Read operations also take longer inside compartments compared to non-compartmentalized execution.
- Free Time: Memory release is significantly delayed inside compartments, increasing execution time variability.
A boxplot visualizing execution time dispersion is shown below:
This experiment evaluates how the use of compartments affects the performance of communication over Unix pipes. We implemented a C program that establishes communication between a parent and a child process through a pipe, collecting metrics on write and read operations.
The parent process writes a 1024-byte random string to the pipe, and the child process reads it. This message size is widely used in inter-process communication applications.
The program was executed inside compartments and without compartments.
The source code for the pipe experiment inside compartments is available here:
pipe-in-experiment.c
clang-morello -march=morello+c64 -mabi=purecap -o pipe-in-experiment pipe-in-experiment.c
proccontrol -m cheric18n -s enable pipe-in-experimentclang-morello -o pipe-out-experiment pipe-out-experiment.c
./pipe-out-experimentThe write time (time taken by the parent process to write data) and the read time (time taken by the child process to read data) were measured. Each operation was repeated 100 times, following the Central Limit Theorem, which states that a larger sample size helps detect finer fluctuations in latency patterns.
The following pseudocode describes the experiment:
start_test(log_file)
begin
define MESSAGE_SIZE
define NUM_OF_TRIALS
for test_num from 1 to NUM_OF_TRIALS do
if parent_process
start_timer(write_time)
write(pipe, message of size MESSAGE_SIZE)
stop_timer(write_time)
write(pipe, write_time)
else
read(pipe, message of size MESSAGE_SIZE)
read(pipe, write_time)
start_timer(read_time)
stop_timer(read_time)
log(log_file, test_num, write_time, read_time)
endif
endfor
endWe collected the execution metrics and stored them in CSV files:
- Inside Compartments (Purecap ABI): pipe-in-experiment-purecap-results.csv
- Inside Compartments (Purecap-Benchmark ABI): pipe-in-experiment-purecap-benchmark-results.csv
- Outside Compartments: pipe-out-experiment-results.csv
| Trial | Message Size (Bytes) | Write Time (ms) | Read Time (ms) | Total Time (ms) |
|---|---|---|---|---|
| 1 | 1024 | 0.016 | 0.161 | 0.177 |
| 2 | 1024 | 0.003 | 0.068 | 0.071 |
| 3 | 1024 | 0.003 | 0.075 | 0.078 |
| 4 | 1024 | 0.003 | 0.077 | 0.080 |
| ... | ... | ... | ... | ... |
| 100 | 1024 | 0.003 | 0.079 | 0.082 |
| Trial | Message Size (Bytes) | Write Time (ms) | Read Time (ms) | Total Time (ms) |
|---|---|---|---|---|
| 1 | 1024 | 0.014 | 0.106 | 0.119 |
| 2 | 1024 | 0.001 | 0.001 | 0.003 |
| 3 | 1024 | 0.003 | 0.019 | 0.022 |
| 4 | 1024 | 0.003 | 0.024 | 0.027 |
| ... | ... | ... | ... | ... |
| 100 | 1024 | 0.003 | 0.032 | 0.035 |
| Trial | Message Size (Bytes) | Write Time (ms) | Read Time (ms) | Total Time (ms) |
|---|---|---|---|---|
| 1 | 1024 | 0.013 | 0.059 | 0.072 |
| 2 | 1024 | 0.001 | 0.001 | 0.003 |
| 3 | 1024 | 0.001 | 0.001 | 0.002 |
| 4 | 1024 | 0.001 | 0.001 | 0.002 |
| ... | ... | ... | ... | ... |
| 100 | 1024 | 0.001 | 0.002 | 0.003 |
The figure below compares write and read times in different configurations.
- Write Time: Execution inside compartments consistently shows higher latency. Write time ranges from 0.016 ms to 0.003 ms in the purecap ABI and 0.014 ms to 0.003 ms in the purecap-benchmark ABI. Outside compartments, write time is significantly lower, consistently around 0.001 ms.
- Read Time: The effect of compartments is less severe but still noticeable. The first test for purecap ABI shows 0.161 ms, compared to 0.059 ms outside compartments. The purecap-benchmark ABI performs slightly better but remains slower than the non-compartmentalised case.
If needed, these Python scripts can be used to summarise the raw collected metrics and present results graphically. They produce aggregated CSV files and comparative plots.




