18c737793SSebastien Boeuf# Intel TDX 28c737793SSebastien Boeuf 38c737793SSebastien BoeufIntel® Trust Domain Extensions (Intel® TDX) is an Intel technology designed to 48c737793SSebastien Boeufisolate virtual machines from the VMM, hypervisor and any other software on the 5bc59ca72SBo Chenhost platform. Here are some useful links: 68c737793SSebastien Boeuf 7*abcbf434SRuoqing He- [TDX Homepage](https://www.intel.com/content/www/us/en/developer/tools/trust-domain-extensions/overview.html): 8bc59ca72SBo Chen more information about TDX technical aspects, design and specification 98c737793SSebastien Boeuf 10*abcbf434SRuoqing He- [KVM TDX tree](https://github.com/intel/tdx/tree/kvm): the required 11bc59ca72SBo Chen Linux kernel changes for the host side 128c737793SSebastien Boeuf 13*abcbf434SRuoqing He- [Guest TDX tree](https://github.com/intel/tdx/tree/guest): the Linux 14bc59ca72SBo Chen kernel changes for the guest side 158c737793SSebastien Boeuf 16*abcbf434SRuoqing He- [EDK2 project](https://github.com/tianocore/edk2): the TDVF firmware 17bc59ca72SBo Chen 18*abcbf434SRuoqing He- [Confidential Containers project](https://github.com/confidential-containers/td-shim): 19bc59ca72SBo Chen the TDShim firmware 20bc59ca72SBo Chen 21*abcbf434SRuoqing He- [TDX Linux](https://github.com/intel/tdx-linux): a collection of tools 22bc59ca72SBo Chen and scripts to setup TDX environment for testing purpose (such as 23bc59ca72SBo Chen installing required packages on the host, creating guest images, and 24bc59ca72SBo Chen building the custom Linux kernel for TDX host and guest) 25072114d7SSebastien Boeuf 268c737793SSebastien Boeuf## Cloud Hypervisor support 278c737793SSebastien Boeuf 28bc59ca72SBo ChenIt is required to use a machine with TDX enabled in hardware and 298c737793SSebastien Boeufwith the host OS compiled from the [KVM TDX tree](https://github.com/intel/tdx/tree/kvm). 30*abcbf434SRuoqing HeThe host environment can also be setup with the [TDX Linux](https://github.com/intel/tdx-linux). 318c737793SSebastien Boeuf 32bc59ca72SBo ChenCloud Hypervisor can run TDX VM (Trust Domain) by loading a TD firmware ([TDVF](https://github.com/tianocore/edk2)), 338c737793SSebastien Boeufwhich will then load the guest kernel from the image. The image must be custom 348c737793SSebastien Boeufas it must include a kernel built from the [Guest TDX tree](https://github.com/intel/tdx/tree/guest). 35bc59ca72SBo ChenCloud Hypervisor can also boot a TDX VM with direct kernel boot using [TDshim](https://github.com/confidential-containers/td-shim). 36*abcbf434SRuoqing HeThe custom Linux kernel for the guest can be built with the [TDX Linux](https://github.com/intel/tdx-linux). 37072114d7SSebastien Boeuf 38072114d7SSebastien Boeuf### TDVF 39072114d7SSebastien Boeuf 40bc59ca72SBo Chen> **Note** 41bc59ca72SBo Chen> The latest version of TDVF being tested is [_13b9773_](https://github.com/tianocore/edk2/commit/13b97736c876919b9786055829caaa4fa46984b7). 42bc59ca72SBo Chen 438c737793SSebastien BoeufThe firmware can be built as follows: 448c737793SSebastien Boeuf 458c737793SSebastien Boeuf```bash 46e151483fSRuslan Mstoisudo apt-get update 47e151483fSRuslan Mstoisudo apt-get install uuid-dev nasm iasl build-essential python3-distutils git 48e151483fSRuslan Mstoi 49ec45daacSBo Chengit clone https://github.com/tianocore/edk2.git 50ec45daacSBo Chencd edk2 51bc59ca72SBo Chengit checkout 13b97736c876919b9786055829caaa4fa46984b7 52b904d666SRuslan Mstoisource ./edksetup.sh 538c737793SSebastien Boeufgit submodule update --init --recursive 546d395c51SRuslan Mstoimake -C BaseTools -j `nproc` 55ec45daacSBo Chenbuild -p OvmfPkg/IntelTdx/IntelTdxX64.dsc -a X64 -t GCC5 -b RELEASE 568c737793SSebastien Boeuf``` 578c737793SSebastien Boeuf 588c737793SSebastien BoeufIf debug logs are needed, here is the alternative command: 598c737793SSebastien Boeuf 608c737793SSebastien Boeuf```bash 61ec45daacSBo Chenbuild -p OvmfPkg/IntelTdx/IntelTdxX64.dsc -a X64 -t GCC5 -D DEBUG_ON_SERIAL_PORT=TRUE 628c737793SSebastien Boeuf``` 638c737793SSebastien Boeuf 648c737793SSebastien BoeufOn the Cloud Hypervisor side, all you need is to build the project with the 658c737793SSebastien Boeuf`tdx` feature enabled: 668c737793SSebastien Boeuf 678c737793SSebastien Boeuf```bash 688c737793SSebastien Boeufcargo build --features tdx 698c737793SSebastien Boeuf``` 708c737793SSebastien Boeuf 718c737793SSebastien BoeufAnd run a TDX VM by providing the firmware previously built, along with the 722963e5c9SSebastien Boeufguest image containing the TDX enlightened kernel. The latest image 732963e5c9SSebastien Boeuf`td-guest-rhel8.5.raw` contains `console=hvc0` on the kernel boot parameters, 742963e5c9SSebastien Boeufmeaning it will be printing guest kernel logs to the `virtio-console` device. 758c737793SSebastien Boeuf 768c737793SSebastien Boeuf```bash 778c737793SSebastien Boeuf./cloud-hypervisor \ 783793ffe8SSebastien Boeuf --platform tdx=on 79ec45daacSBo Chen --firmware edk2/Build/IntelTdx/RELEASE_GCC5/FV/OVMF.fd \ 808c737793SSebastien Boeuf --cpus boot=1 \ 818c737793SSebastien Boeuf --memory size=1G \ 828c737793SSebastien Boeuf --disk path=tdx_guest_img 838c737793SSebastien Boeuf``` 848c737793SSebastien Boeuf 852963e5c9SSebastien BoeufAnd here is the alternative command when looking for debug logs from the 862963e5c9SSebastien Boeuffirmware: 878c737793SSebastien Boeuf 888c737793SSebastien Boeuf```bash 898c737793SSebastien Boeuf./cloud-hypervisor \ 903793ffe8SSebastien Boeuf --platform tdx=on 91ec45daacSBo Chen --firmware edk2/Build/IntelTdx/DEBUG_GCC5/FV/OVMF.fd \ 928c737793SSebastien Boeuf --cpus boot=1 \ 938c737793SSebastien Boeuf --memory size=1G \ 948c737793SSebastien Boeuf --disk path=tdx_guest_img \ 952963e5c9SSebastien Boeuf --serial file=/tmp/ch_serial \ 962963e5c9SSebastien Boeuf --console tty 978c737793SSebastien Boeuf``` 98072114d7SSebastien Boeuf 99072114d7SSebastien Boeuf### TDShim 100072114d7SSebastien Boeuf 101bc59ca72SBo Chen> **Note** 102c97b5625SJinank Jain> The latest version of TDShim being tested is [_v0.8.0_](https://github.com/confidential-containers/td-shim/releases/tag/v0.8.0). 103bc59ca72SBo Chen 104072114d7SSebastien BoeufThis is a lightweight version of the TDVF, written in Rust and designed for 105072114d7SSebastien Boeufdirect kernel boot, which is useful for containers use cases. 106072114d7SSebastien Boeuf 107bc59ca72SBo ChenTo build TDShim from source, it is required to install `Rust`, `NASM`, 108bc59ca72SBo Chenand `LLVM` first. The TDshim can be build as follows: 109*abcbf434SRuoqing He 110bc59ca72SBo Chen```bash 111bc59ca72SBo Chengit clone https://github.com/confidential-containers/td-shim 112bc59ca72SBo Chencd td-shim 113c97b5625SJinank Jaingit checkout v0.8.0 114bc59ca72SBo Chencargo install cargo-xbuild 115bc59ca72SBo Chenexport CC=clang 116bc59ca72SBo Chenexport AR=llvm-ar 117bc59ca72SBo Chenexport CC_x86_64_unknown_none=clang 118bc59ca72SBo Chenexport AR_x86_64_unknown_none=llvm-ar 119bc59ca72SBo Chengit submodule update --init --recursive 120bc59ca72SBo Chen./sh_script/preparation.sh 121c97b5625SJinank Jaincargo image --release 122bc59ca72SBo Chen``` 123bc59ca72SBo Chen 124bc59ca72SBo ChenIf debug logs from the TDShim is needed, here are the alternative 125bc59ca72SBo Chencommands: 126*abcbf434SRuoqing He 127bc59ca72SBo Chen```bash 128c97b5625SJinank Jaincargo image 129bc59ca72SBo Chen``` 130072114d7SSebastien Boeuf 131072114d7SSebastien BoeufAnd run a TDX VM by providing the firmware previously built, along with a guest 132bc59ca72SBo Chenkernel built from the [Guest TDX tree](https://github.com/intel/tdx/tree/guest) 133*abcbf434SRuoqing Heor the [TDX Linux](https://github.com/intel/tdx-linux). 134072114d7SSebastien BoeufThe appropriate kernel boot options must be provided through the `--cmdline` 135072114d7SSebastien Boeufoption as well. 136072114d7SSebastien Boeuf 137072114d7SSebastien Boeuf```bash 138072114d7SSebastien Boeuf./cloud-hypervisor \ 1393793ffe8SSebastien Boeuf --platform tdx=on 140bc59ca72SBo Chen --firmware td-shim/target/release/final.bin \ 141bc59ca72SBo Chen --kernel bzImage \ 142bc59ca72SBo Chen --cmdline "root=/dev/vda3 console=hvc0 rw" 143bc59ca72SBo Chen --cpus boot=1 \ 144bc59ca72SBo Chen --memory size=1G \ 145bc59ca72SBo Chen --disk path=tdx_guest_img 146bc59ca72SBo Chen``` 147bc59ca72SBo Chen 148bc59ca72SBo ChenAnd here is the alternative command when looking for debug logs from the 149bc59ca72SBo ChenTDShim: 150bc59ca72SBo Chen 151bc59ca72SBo Chen```bash 152bc59ca72SBo Chen./cloud-hypervisor \ 153bc59ca72SBo Chen --platform tdx=on 154bc59ca72SBo Chen --firmware td-shim/target/debug/final.bin \ 155072114d7SSebastien Boeuf --kernel bzImage \ 1562963e5c9SSebastien Boeuf --cmdline "root=/dev/vda3 console=hvc0 rw" 157072114d7SSebastien Boeuf --cpus boot=1 \ 158072114d7SSebastien Boeuf --memory size=1G \ 159072114d7SSebastien Boeuf --disk path=tdx_guest_img 160072114d7SSebastien Boeuf``` 1612963e5c9SSebastien Boeuf 162f4e21987SSebastien Boeuf### Guest kernel limitations 163f4e21987SSebastien Boeuf 164f4e21987SSebastien Boeuf#### Serial ports disabled 1652963e5c9SSebastien Boeuf 1662963e5c9SSebastien BoeufThe latest guest kernel that can be found in the latest image 1672963e5c9SSebastien Boeuf`td-guest-rhel8.5.raw` disabled the support for serial ports. This means adding 1682963e5c9SSebastien Boeuf`console=ttyS0` will have no effect and will not print any log from the guest. 169f4e21987SSebastien Boeuf 170f4e21987SSebastien Boeuf#### PCI hotplug through ACPI 171f4e21987SSebastien Boeuf 172f4e21987SSebastien BoeufUnless you run the guest kernel with the parameter `tdx_disable_filter`, ACPI 173f4e21987SSebastien Boeufdevices responsible for handling PCI hotplug (PCI hotplug controller, PCI 174f4e21987SSebastien BoeufExpress Bus and Generic Event Device) will not be allowed, therefore the 175f4e21987SSebastien Boeufcorresponding drivers will not be loaded and the PCI hotplug feature will not 176f4e21987SSebastien Boeufbe supported. 177