Memory encryption
When a VM is started by the hypervisor, the hypervisor assigns it an ASID (Address Space ID) and passes the ID to the AMD SP in the VMRUN statement. All code and data associated with a confidential VM is tagged with the ASID inside the CPU. This allows the CPU to only allow the actual owner to access the data by matching the ASID's. The AMD-SP generates an encryption key for each VM created using a hardware random number generator, associates it with the ASID, and loads it into a dedicated hardware register. No software is allowed to read these registers. When data leaves the SoC, it must pass through the encryption engine, which encrypts it with the key associated with the VM. In SEV, the encrypted memory for a particular cVM is called its private memory. AMD SEV uses AES-128 for memory encryption and a custom tweak function. AES-XTS, used by Intel SGX, also uses a tweak. This protects against side-channel attacks and move of the ciphertext block into a different memory space. The hypervisor is also assigned an ASID and has it's own encryption key. This encryption key is used for shared memory and all confidential VMs and the hypervisor can use it. This allows memory to be shared with the hypervisor or with other trusted VMs. By setting a special bit, the guest kernel (cVM kernel) can mark memory as either shared or private. DMA's to a cVM's private memory are completely disallowed and are only allowed for shared memory.
Last updated