|
| 1 | +# Arm CCA Support for Unikraft |
| 2 | + |
| 3 | +## GSoC Contributor |
| 4 | + |
| 5 | +* **Name:** Xingjian Zhang |
| 6 | + |
| 7 | +* **Github profile:** [@zhxj9823](https://github.com/zhxj9823/) |
| 8 | + |
| 9 | +## Mentors |
| 10 | + |
| 11 | +* [Michalis Pappas](https://github.com/michpappas) |
| 12 | +* [Hugo Lefeuvre](https://github.com/hlef) |
| 13 | +* [Răzvan Vîrtan](https://github.com/razvanvirtan) |
| 14 | +* [Maria Sfîrăială](https://github.com/mariasfiraiala) |
| 15 | +* [Vlad Bădoiu](https://github.com/vladandrew) |
| 16 | + |
| 17 | +## Contributions |
| 18 | + |
| 19 | +### Project Description |
| 20 | + |
| 21 | +[Arm CCA](https://www.arm.com/architecture/security-features/arm-confidential-compute-architecture) introduces the Realm Management Extension (RME), which extends [Arm TrustZone technology](https://www.arm.com/technologies/trustzone-for-cortex-a) with two new security states: the `realm` state and the `root` state. |
| 22 | +Instead of running a VM in the normal world, the CCA can run a VM in the realm state. |
| 23 | +The realm state constructs protected execution environments called realms, which protect the data in the realms from other components. |
| 24 | +This architecture allows the hypervisor to control the VM but removes the right for access to that VM. |
| 25 | +The following figure shows the system architecture of Arm CCA. |
| 26 | +**The primary goal of this project is to bring Arm CCA support to Unikraft, so it can run as a realm VM.** |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +### Arm CCA Support for Unikraft |
| 31 | + |
| 32 | +The main contributions of this project are in [PR #964](https://github.com/unikraft/unikraft/pull/964), which adds necessary modifications to Unikraft to support Arm CCA. |
| 33 | +The work can be categorized into three main parts. |
| 34 | + |
| 35 | +#### Changes to the Bootflow |
| 36 | + |
| 37 | +To use Unikraft in the realm world, we need to make some changes to the bootflow. |
| 38 | +The changes include the detection of RSI interfaces, setup of the realm memory region, and the marking of device memory regions as unprotected. |
| 39 | + |
| 40 | +#### Implementing `ukrsi` |
| 41 | + |
| 42 | +The latest [Realm Management Monitor specification](https://developer.arm.com/documentation/den0137/latest/) specifies the RSI commands, which provide certain functionalities for the realm VM. |
| 43 | +A new `ukrsi` under `drivers/arm-cca` implements all these commands: |
| 44 | + |
| 45 | +* `RSI_ATTESTATION_TOKEN_CONTINUE` |
| 46 | +* `RSI_ATTESTATION_TOKEN_INIT` |
| 47 | +* `RSI_HOST_CALL` |
| 48 | +* `RSI_IPA_STATE_GET` |
| 49 | +* `RSI_IPA_STATE_SET` |
| 50 | +* `RSI_MEASUREMENT_EXTEND` |
| 51 | +* `RSI_MEASUREMENT_READ` |
| 52 | +* `RSI_REALM_CONFIG` |
| 53 | +* `RSI_VERSION` |
| 54 | + |
| 55 | +#### Application Compatibility |
| 56 | + |
| 57 | +To demonstrate the use of Unikraft in the realm world, we bring several applications to the realm world. |
| 58 | +Launching an application in the realm world uses kvmtool, so we need to make applications compatible with kvmtool and the realm world. |
| 59 | +Currently, `app-helloworld`, `app-sqlite`, `app-httpreply`, `app-redis` can work with kvmtool. |
| 60 | +These applications leverage various devices, including the serial console, the `initrd` filesystem, and the networking device. |
| 61 | +Besides, `app-helloworld` and `app-sqlite` with initrd can work in the realm world, while other applications require additional support. |
| 62 | + |
| 63 | +### Other PRs |
| 64 | + |
| 65 | +In addition to my main contribution of bringing Arm CCA support to Unikraft, I also contributed to other PRs in the Unikraft repository. |
| 66 | +These PRs address issues that I encountered when trying to make applications compatible with kvmtool. |
| 67 | + |
| 68 | +#### Merged PRs |
| 69 | + |
| 70 | +* [PR #970](https://github.com/unikraft/unikraft/pull/970) fixes an issue relating to unaligned read and write operations in `virtio_mmio`. |
| 71 | +* [PR #985](https://github.com/unikraft/unikraft/pull/985) adds two configurations to `ns16550`, so the serial driver can suit more use cases. |
| 72 | +* [PR #1059](https://github.com/unikraft/unikraft/pull/1059) swaps the last two arguments of `virtio_9p_feature_negotiate`'s first call to `virtio_config_get`. |
| 73 | + |
| 74 | +#### Pending PRs |
| 75 | + |
| 76 | +* [PR #986](https://github.com/unikraft/unikraft/pull/986) migrates console APIs into a new `libuktty`. |
| 77 | + |
| 78 | +## Blog Posts |
| 79 | + |
| 80 | +- [First blog post](https://unikraft.org/blog/2023-06-23-unikraft-gsoc-arm-cca-1/) |
| 81 | +- [Second blog post](https://github.com/unikraft/docs/pull/287) |
| 82 | +- [Third blog post](https://github.com/unikraft/docs/pull/301) |
| 83 | +- [Forth blog post](https://github.com/unikraft/docs/pull/310) |
| 84 | + |
| 85 | +## Documentation |
| 86 | + |
| 87 | +A more detailed documentation of `ukrsi` is in `drivers/arm-cca/ukrsi/README.md`, which decribes the implementation of `ukrsi` and how to use it. |
| 88 | + |
| 89 | +## Current Status |
| 90 | + |
| 91 | +The table below summarizes the compatibility of applications with different environments. |
| 92 | +Three environments are considered: applications running in a native ARM64 machine using kvmtool, applications running in the normal world on FVP, and applications running in the realm world on FVP. |
| 93 | + |
| 94 | +| Applications | native kvmtool | kvmtool in FVP | Realm world | |
| 95 | +|-------------------------------------------------------------------- |:--------------: |:--------------: |:-----------: | |
| 96 | +| [`app-helloworld`](https://github.com/unikraft/app-helloworld) | Y | Y | Y | |
| 97 | +| [`app-httpreply`](https://github.com/unikraft/app-httpreply) | Y | N | N | |
| 98 | +| [`app-sqlite`](https://github.com/unikraft/app-sqlite) with initrd | Y | Y | Y | |
| 99 | +| [`app-sqlite`](https://github.com/unikraft/app-sqlite) with 9pfs | Y | Y | N | |
| 100 | +| [`app-redis`](https://github.com/unikraft/app-redis) | Y | N | N | |
| 101 | + |
| 102 | +## Future Work |
| 103 | + |
| 104 | +While, my GSoC project journey is coming to an end, my work on Arm CCA support for Unikraft is not. |
| 105 | +As some applications do not work in the realm world, I will continue to work on making them work. |
| 106 | +Besides, as the Arm CCA technology continues to evolve, I will continue to improve its support for Unicraft. |
| 107 | + |
| 108 | +## Acknowledgements |
| 109 | + |
| 110 | +Thanks to all my mentors and the Unikraft community for their guidance and support. |
0 commit comments