1*565d591fSRoy HopkinsIndependent Guest Virtual Machine (IGVM) support 2*565d591fSRoy Hopkins================================================ 3*565d591fSRoy Hopkins 4*565d591fSRoy HopkinsIGVM files are designed to encapsulate all the information required to launch a 5*565d591fSRoy Hopkinsvirtual machine on any given virtualization stack in a deterministic way. This 6*565d591fSRoy Hopkinsallows the cryptographic measurement of initial guest state for Confidential 7*565d591fSRoy HopkinsGuests to be calculated when the IGVM file is built, allowing a relying party to 8*565d591fSRoy Hopkinsverify the initial state of a guest via a remote attestation. 9*565d591fSRoy Hopkins 10*565d591fSRoy HopkinsAlthough IGVM files are designed with Confidential Computing in mind, they can 11*565d591fSRoy Hopkinsalso be used to configure non-confidential guests. Multiple platforms can be 12*565d591fSRoy Hopkinsdefined by a single IGVM file, allowing a single IGVM file to configure a 13*565d591fSRoy Hopkinsvirtual machine that can run on, for example, TDX, SEV and non-confidential 14*565d591fSRoy Hopkinshosts. 15*565d591fSRoy Hopkins 16*565d591fSRoy HopkinsQEMU supports IGVM files through the user-creatable ``igvm-cfg`` object. This 17*565d591fSRoy Hopkinsobject is used to define the filename of the IGVM file to process. A reference 18*565d591fSRoy Hopkinsto the object is added to the ``-machine`` to configure the virtual machine 19*565d591fSRoy Hopkinsto use the IGVM file for configuration. 20*565d591fSRoy Hopkins 21*565d591fSRoy HopkinsConfidential platform support is provided through the use of 22*565d591fSRoy Hopkinsthe ``ConfidentialGuestSupport`` object. If the virtual machine provides an 23*565d591fSRoy Hopkinsinstance of this object then this is used by the IGVM loader to configure the 24*565d591fSRoy Hopkinsisolation properties of the directives within the file. 25*565d591fSRoy Hopkins 26*565d591fSRoy HopkinsFurther Information on IGVM 27*565d591fSRoy Hopkins--------------------------- 28*565d591fSRoy Hopkins 29*565d591fSRoy HopkinsInformation about the IGVM format, including links to the format specification 30*565d591fSRoy Hopkinsand documentation for the Rust and C libraries can be found at the project 31*565d591fSRoy Hopkinsrepository: 32*565d591fSRoy Hopkins 33*565d591fSRoy Hopkinshttps://github.com/microsoft/igvm 34*565d591fSRoy Hopkins 35*565d591fSRoy Hopkins 36*565d591fSRoy HopkinsSupported Platforms 37*565d591fSRoy Hopkins------------------- 38*565d591fSRoy Hopkins 39*565d591fSRoy HopkinsCurrently, IGVM files can be provided for Confidential Guests on host systems 40*565d591fSRoy Hopkinsthat support AMD SEV, SEV-ES and SEV-SNP with KVM. IGVM files can also be 41*565d591fSRoy Hopkinsprovided for non-confidential guests. 42*565d591fSRoy Hopkins 43*565d591fSRoy Hopkins 44*565d591fSRoy HopkinsLimitations when using IGVM with AMD SEV, SEV-ES and SEV-SNP 45*565d591fSRoy Hopkins------------------------------------------------------------ 46*565d591fSRoy Hopkins 47*565d591fSRoy HopkinsIGVM files configure the initial state of the guest using a set of directives. 48*565d591fSRoy HopkinsNot every directive is supported by every Confidential Guest type. For example, 49*565d591fSRoy HopkinsAMD SEV does not support encrypted save state regions, therefore setting the 50*565d591fSRoy Hopkinsinitial CPU state using IGVM for SEV is not possible. When an IGVM file contains 51*565d591fSRoy Hopkinsdirectives that are not supported for the active platform, an error is generated 52*565d591fSRoy Hopkinsand the guest launch is aborted. 53*565d591fSRoy Hopkins 54*565d591fSRoy HopkinsThe table below describes the list of directives that are supported for SEV, 55*565d591fSRoy HopkinsSEV-ES, SEV-SNP and non-confidential platforms. 56*565d591fSRoy Hopkins 57*565d591fSRoy Hopkins.. list-table:: SEV, SEV-ES, SEV-SNP & non-confidential Supported Directives 58*565d591fSRoy Hopkins :widths: 35 65 59*565d591fSRoy Hopkins :header-rows: 1 60*565d591fSRoy Hopkins 61*565d591fSRoy Hopkins * - IGVM directive 62*565d591fSRoy Hopkins - Notes 63*565d591fSRoy Hopkins * - IGVM_VHT_PAGE_DATA 64*565d591fSRoy Hopkins - ``NORMAL`` zero, measured and unmeasured page types are supported. Other 65*565d591fSRoy Hopkins page types result in an error. 66*565d591fSRoy Hopkins * - IGVM_VHT_PARAMETER_AREA 67*565d591fSRoy Hopkins - 68*565d591fSRoy Hopkins * - IGVM_VHT_PARAMETER_INSERT 69*565d591fSRoy Hopkins - 70*565d591fSRoy Hopkins * - IGVM_VHT_VP_COUNT_PARAMETER 71*565d591fSRoy Hopkins - The guest parameter page is populated with the CPU count. 72*565d591fSRoy Hopkins * - IGVM_VHT_ENVIRONMENT_INFO_PARAMETER 73*565d591fSRoy Hopkins - The ``memory_is_shared`` parameter is set to 1 in the guest parameter 74*565d591fSRoy Hopkins page. 75*565d591fSRoy Hopkins 76*565d591fSRoy Hopkins.. list-table:: Additional SEV, SEV-ES & SEV_SNP Supported Directives 77*565d591fSRoy Hopkins :widths: 25 75 78*565d591fSRoy Hopkins :header-rows: 1 79*565d591fSRoy Hopkins 80*565d591fSRoy Hopkins * - IGVM directive 81*565d591fSRoy Hopkins - Notes 82*565d591fSRoy Hopkins * - IGVM_VHT_MEMORY_MAP 83*565d591fSRoy Hopkins - The memory map page is populated using entries from the E820 table. 84*565d591fSRoy Hopkins * - IGVM_VHT_REQUIRED_MEMORY 85*565d591fSRoy Hopkins - Ensures memory is available in the guest at the specified range. 86*565d591fSRoy Hopkins 87*565d591fSRoy Hopkins.. list-table:: Additional SEV-ES & SEV-SNP Supported Directives 88*565d591fSRoy Hopkins :widths: 25 75 89*565d591fSRoy Hopkins :header-rows: 1 90*565d591fSRoy Hopkins 91*565d591fSRoy Hopkins * - IGVM directive 92*565d591fSRoy Hopkins - Notes 93*565d591fSRoy Hopkins * - IGVM_VHT_VP_CONTEXT 94*565d591fSRoy Hopkins - Setting of the initial CPU state for the boot CPU and additional CPUs is 95*565d591fSRoy Hopkins supported with limitations on the fields that can be provided in the 96*565d591fSRoy Hopkins VMSA. See below for details on which fields are supported. 97*565d591fSRoy Hopkins 98*565d591fSRoy HopkinsInitial CPU state with VMSA 99*565d591fSRoy Hopkins--------------------------- 100*565d591fSRoy Hopkins 101*565d591fSRoy HopkinsThe initial state of guest CPUs can be defined in the IGVM file for AMD SEV-ES 102*565d591fSRoy Hopkinsand SEV-SNP. The state data is provided as a VMSA structure as defined in Table 103*565d591fSRoy HopkinsB-4 in the AMD64 Architecture Programmer's Manual, Volume 2 [1]. 104*565d591fSRoy Hopkins 105*565d591fSRoy HopkinsThe IGVM VMSA is translated to CPU state in QEMU which is then synchronized 106*565d591fSRoy Hopkinsby KVM to the guest VMSA during the launch process where it contributes to the 107*565d591fSRoy Hopkinslaunch measurement. See :ref:`amd-sev` for details on the launch process and 108*565d591fSRoy Hopkinsguest launch measurement. 109*565d591fSRoy Hopkins 110*565d591fSRoy HopkinsIt is important that no information is lost or changed when translating the 111*565d591fSRoy HopkinsVMSA provided by the IGVM file into the VSMA that is used to launch the guest. 112*565d591fSRoy HopkinsTherefore, QEMU restricts the VMSA fields that can be provided in the IGVM 113*565d591fSRoy HopkinsVMSA structure to the following registers: 114*565d591fSRoy Hopkins 115*565d591fSRoy HopkinsRAX, RCX, RDX, RBX, RBP, RSI, RDI, R8-R15, RSP, RIP, CS, DS, ES, FS, GS, SS, 116*565d591fSRoy HopkinsCR0, CR3, CR4, XCR0, EFER, PAT, GDT, IDT, LDTR, TR, DR6, DR7, RFLAGS, X87_FCW, 117*565d591fSRoy HopkinsMXCSR. 118*565d591fSRoy Hopkins 119*565d591fSRoy HopkinsWhen processing the IGVM file, QEMU will check if any fields other than the 120*565d591fSRoy Hopkinsabove are non-zero and generate an error if this is the case. 121*565d591fSRoy Hopkins 122*565d591fSRoy HopkinsKVM uses a hardcoded GPA of 0xFFFFFFFFF000 for the VMSA. When an IGVM file 123*565d591fSRoy Hopkinsdefines initial CPU state, the GPA for each VMSA must match this hardcoded 124*565d591fSRoy Hopkinsvalue. 125*565d591fSRoy Hopkins 126*565d591fSRoy HopkinsFirmware Images with IGVM 127*565d591fSRoy Hopkins------------------------- 128*565d591fSRoy Hopkins 129*565d591fSRoy HopkinsWhen an IGVM filename is specified for a Confidential Guest Support object it 130*565d591fSRoy Hopkinsoverrides the default handling of system firmware: the firmware image, such as 131*565d591fSRoy Hopkinsan OVMF binary should be contained as a payload of the IGVM file and not 132*565d591fSRoy Hopkinsprovided as a flash drive or via the ``-bios`` parameter. The default QEMU 133*565d591fSRoy Hopkinsfirmware is not automatically populated into the guest memory space. 134*565d591fSRoy Hopkins 135*565d591fSRoy HopkinsIf an IGVM file is provided along with either the ``-bios`` parameter or pflash 136*565d591fSRoy Hopkinsdevices then an error is displayed and the guest startup is aborted. 137*565d591fSRoy Hopkins 138*565d591fSRoy HopkinsRunning a guest configured using IGVM 139*565d591fSRoy Hopkins------------------------------------- 140*565d591fSRoy Hopkins 141*565d591fSRoy HopkinsTo run a guest configured with IGVM you firstly need to generate an IGVM file 142*565d591fSRoy Hopkinsthat contains a guest configuration compatible with the platform you are 143*565d591fSRoy Hopkinstargeting. 144*565d591fSRoy Hopkins 145*565d591fSRoy HopkinsThe ``buildigvm`` tool [2] is an example of a tool that can be used to generate 146*565d591fSRoy HopkinsIGVM files for non-confidential X86 platforms as well as for SEV, SEV-ES and 147*565d591fSRoy HopkinsSEV-SNP confidential platforms. 148*565d591fSRoy Hopkins 149*565d591fSRoy HopkinsExample using this tool to generate an IGVM file for AMD SEV-SNP:: 150*565d591fSRoy Hopkins 151*565d591fSRoy Hopkins buildigvm --firmware /path/to/OVMF.fd --output sev-snp.igvm \ 152*565d591fSRoy Hopkins --cpucount 4 sev-snp 153*565d591fSRoy Hopkins 154*565d591fSRoy HopkinsTo run a guest configured with the generated IGVM you need to add an 155*565d591fSRoy Hopkins``igvm-cfg`` object and refer to it from the ``-machine`` parameter: 156*565d591fSRoy Hopkins 157*565d591fSRoy HopkinsExample (for AMD SEV):: 158*565d591fSRoy Hopkins 159*565d591fSRoy Hopkins qemu-system-x86_64 \ 160*565d591fSRoy Hopkins <other parameters> \ 161*565d591fSRoy Hopkins -machine ...,confidential-guest-support=sev0,igvm-cfg=igvm0 \ 162*565d591fSRoy Hopkins -object sev-guest,id=sev0,cbitpos=47,reduced-phys-bits=1 \ 163*565d591fSRoy Hopkins -object igvm-cfg,id=igvm0,file=/path/to/sev-snp.igvm 164*565d591fSRoy Hopkins 165*565d591fSRoy HopkinsReferences 166*565d591fSRoy Hopkins---------- 167*565d591fSRoy Hopkins 168*565d591fSRoy Hopkins[1] AMD64 Architecture Programmer's Manual, Volume 2: System Programming 169*565d591fSRoy Hopkins Rev 3.41 170*565d591fSRoy Hopkins https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf 171*565d591fSRoy Hopkins 172*565d591fSRoy Hopkins[2] ``buildigvm`` - A tool to build example IGVM files containing OVMF firmware 173*565d591fSRoy Hopkins https://github.com/roy-hopkins/buildigvm