Artifact release for the paper "GuaranTEE: Towards Attestable and Private ML with CCA", at EuroMLSys 2024.
In the following, we provide a step-by-step guide to create a realm VM that provides inference to normal world user space. We use the Armv-A Base RevC AEM FVP (Fixed Virtual Platform), a free platform provided by Arm that emulates Armv9-A architecture. The platform only works on Linux hosts. We get all the necessary firmware and software from arm-reference-solutions-docs which are compliant with Arm CCA. Given the model and input data, we also need a binary that is able to perfom inference which already exists in the repository. Details on how to build the binary is provided in another repository TFlite-CCA.
To set up the environment, follow these steps:
Download the appropriate FVP for your host by following the steps in Arm Reference Solutions-docs/docs/aemfvp-a-rme/install-fvp.rst.
Arm provides a Docker image with dependencies required to build the software stack.
First, create a folder for the simulation:
cd && mkdir cca-simulation && cd cca-simulation
Install the docker container and download the appropriate docker image by following the commands here Arm Reference Solutions-docs/docs/aemfvp-a-rme/setup-environ.rst.
Create rme-stack inside docker folder, run the container and mount the path to the rme-stack folder using the following command. Do not forget to add absolute path to rme-stack folder (It should be something like /home/user_name/cca-simulation/docker/rme-stack).
mkdir rme-stack
./container.sh -v </absolute/path/to/rme-stack> run
Run the following commands inside the container:
cd </absolute/path/to/rme-stack>
repo init -u https://git.gitlab.arm.com/arm-reference-solutions/arm-reference-solutions-manifest.git -m pinned-aemfvp-a-rme.xml -b refs/tags/AEMFVP-A-RME-2023.12.22
repo sync -c -j $(nproc) --fetch-submodules --force-sync --no-clone-bundle
We provide a script modify.sh in this repository. This script applies changes we made to the file system of the realm and the hypervisor. It also fixes an issue that arises when trying to rebuild the stack (see the Issue).
Exit the container:
exit
Clone our repository and run the modify.sh script:
cd rme-stack/
git clone https://github.com/comet-cc/GuaranTEE.git
./GuaranTEE/modify.sh
a) Run the container:
../container.sh -v </absolute/path/to/rme-stack> run
cd </absolute/path/to/rme-stack>
b) Build the stack:
./build-scripts/aemfvp-a-rme/build-test-buildroot.sh -p aemfvp-a-rme all
Note that this process takes a bit of time.
c) Exit the containter
exit
First, set the environment vairable FVP_DIR to the path of the downloaded FVP. Then, execute the boot.sh script.
export FVP_DIR=/path_to_FVP_directory
./model-scripts/aemfvp-a-rme/boot.sh -p aemfvp-a-rme shell
You should be able to see four xterms terminals. You can close these windows and use other terminals to receive data from telnet by:
telnet localhost 5000 (up to 5003)
a) Use “root” as both username and password to get into the hypervisor’s user space.
b) Create a realm instance with:
./create_realm.sh
Executing ./create_NW_VM.sh will create a virtual machine with the same configuration but inside normal world. Alternatively, you can create a realm instance with a customized setting like this:
screen lkvm run --realm -c 1 -m 300 -k /realm/Image -d /realm/realm-fs.ext4 \
--9p /root/shared_with_realm,sh -p earlycon --irqchip=gicv3 --disable-sve
To see all lkvm options:
lkvm run --help
We provide an example of how to run ML inference with a realm. In our example, we use a TensorFlow Lite model that classifies images. In order to run the example, we provide the .tflite model and a set of input images (found in the realm and normal_world directories, respectively). You can change these based on the ML application you want to run.
In our setup, there is a shared folder between the realm and the normal world. The shared folder contains a file signalling.txt which is used by both the realm and the normal world app to coordinate communication.
The normal world has a folder of images (inputs for the model). The nomral world copies an image to the shared folder and updates signalling.txt (it adds the path to the image and a state showing that there is an image to be processed).
The realm reads the content of signalling.txt, performs inference, and writes the output to output.txt in the shared folder.
The steps to perform these operations are shown below.
After creating a realm instance from step 6, use “root” as both username and password to get into the realm’s user space. Then, execute the following command:
./start_inference_service.sh
This command executes a binary file named realm_inference. This binary looks at signalling.txt in the shared folder for the input (image) path. When a new image path is written, the binary feeds it into the model. The model itself is in TensorFlow Lite (.tflite) which is stored in the realm file system.
For Further instrcutions to build realm_inference binary look at our TFlite-CCA repository.
To start to write new image paths into signalling.txt, you need to detach form the realm by pressing Ctrl + a and then d, then execute the follwing command:
./NW_signalling.sh
The results of inference is wrriten in /root/shared_with_realm/output.txt.
FVP by defaults uses two clusters each equiped with four cores. Based on our observation, disabling one cluster and using only one core of the other cluster gives the best simulation speed. Therefore, we suggest the following:
Go to the main rme-stack directory and run the following commands:
NEW_LINE="\\\t-C cluster1.NUM_CORES=0 \\\\" && SCRIPT="./model-scripts/aemfvp-a-rme/run_model.sh" && PATTERN="-C cluster1.NUM_CORES"
sed -i "/${PATTERN}/c ${NEW_LINE}" "${SCRIPT}"
NEW_LINE="\\\t-C cluster0.NUM_CORES=1 \\\\" && PATTERN="-C cluster0.NUM_CORES"
sed -i "/${PATTERN}/c ${NEW_LINE}" "${SCRIPT}"
The content of normal_world/root folder is overlayed into the hypeervisor file system. Consequently, you can add new files to the hypervisor file system by adding the files to this folder and rebuild the stack. A faster solution is to use FVP features. FVP is able to create a shared folder between the host and the hypervisor running on the FVP which enables runtime transfering of data. To do this, you need to follow these steps:
a) Go to the main rme-stack directory and add the shared folder address into FVP setting:
SHARED_FOLDER="ABSOLUTE_PATH_TO_SHARED_FOLDER"
NEW_LINE="\\\t-C bp.virtiop9device.root_path=${SHARED_FOLDER} \\\\" && SCRIPT="./model-scripts/aemfvp-a-rme/run_model.sh" && PATTERN="-C gic_distributor.extended-spi-count"
sed -i "/${PATTERN}/a ${NEW_LINE}" "${SCRIPT}"
b) Boot the stack (step 5)
c) Get into hypervisor user space and execute the following code:
mkdir mnt
mount -t 9p FM /root/mnt
You should see the content of the shared folder in the /root/mnt path now.
Realm Management Monitor (RMM specification) is a crucial part of Arm CCA providing confidentiality and integrity guarantees to the realm. When you boot the stack, terminal_3 (port 5003 on Telnet terminal) shows RMM logs. If you are working with RMM, you may see that the logs are not completely compatible with the specification. What you actually need is to enable some of RMM logs which are disabled be default. To do that, open rme-stack/rmm/runtime/core/handler.c and change false values to true inside smc_handlers[] structure for each RMI command.
GuaranTEE: Towards Attestable and Private ML with CCA Sandra Siby, Sina Abdollahi, Mohammad Maheri, Marios Kogias, Hamed Haddadi EuroMLSys, 2024
Abstract -- Machine-learning (ML) models are increasingly being deployed on edge devices to provide a variety of services. However, their deployment is accompanied by challenges in model privacy and auditability. Model providers want to ensure that (i) their proprietary models are not exposed to third parties; and (ii) be able to get attestations that their genuine models are operating on edge devices in accordance with the service agreement with the user. Existing measures to address these challenges have been hindered by issues such as high overheads and limited capability (processing/secure memory) on edge devices. In this work, we propose GuaranTEE, a framework to provide attestable private machine learning on the edge. GuaranTEE uses Confidential Computing Architecture (CCA), Arm’s latest architectural extension that allows for the creation and deployment of dynamic Trusted Execution Environments (TEEs) within which models can be executed. We evaluate CCA’s feasibility to deploy ML models by developing, evaluating, and openly releasing a prototype. We also suggest improvements to CCA to facilitate its use in protecting the entire ML deployment pipeline on edge devices.
The paper can be found here.
If you use the code/data in your research, please cite our work as follows:
@inproceedings{Siby24GuaranTEE,
title = {GuaranTEE: Towards Attestable and private ML with CCA},
author = {Sandra Siby, Sina Abdollahi, Mohammad Maheri, Marios Kogias, Hamed Haddadi},
booktitle = {The 4th Workshop on Machine Learning and Systems (EuroMLSys)},
year = {2024}
}
In case of questions, please get in touch with Sina Abdollahi and Sandra Siby.