1250c6c31SSukadev Bhattiprolu.. SPDX-License-Identifier: GPL-2.0 2ad9b48c5SAdam Zerella.. _ultravisor: 3250c6c31SSukadev Bhattiprolu 4250c6c31SSukadev Bhattiprolu============================ 5250c6c31SSukadev BhattiproluProtected Execution Facility 6250c6c31SSukadev Bhattiprolu============================ 7250c6c31SSukadev Bhattiprolu 8250c6c31SSukadev Bhattiprolu.. contents:: 9250c6c31SSukadev Bhattiprolu :depth: 3 10250c6c31SSukadev Bhattiprolu 11c44166feSMauro Carvalho ChehabIntroduction 12c44166feSMauro Carvalho Chehab############ 13250c6c31SSukadev Bhattiprolu 14250c6c31SSukadev Bhattiprolu Protected Execution Facility (PEF) is an architectural change for 15250c6c31SSukadev Bhattiprolu POWER 9 that enables Secure Virtual Machines (SVMs). DD2.3 chips 16250c6c31SSukadev Bhattiprolu (PVR=0x004e1203) or greater will be PEF-capable. A new ISA release 17250c6c31SSukadev Bhattiprolu will include the PEF RFC02487 changes. 18250c6c31SSukadev Bhattiprolu 19250c6c31SSukadev Bhattiprolu When enabled, PEF adds a new higher privileged mode, called Ultravisor 20250c6c31SSukadev Bhattiprolu mode, to POWER architecture. Along with the new mode there is new 21250c6c31SSukadev Bhattiprolu firmware called the Protected Execution Ultravisor (or Ultravisor 22250c6c31SSukadev Bhattiprolu for short). Ultravisor mode is the highest privileged mode in POWER 23250c6c31SSukadev Bhattiprolu architecture. 24250c6c31SSukadev Bhattiprolu 25250c6c31SSukadev Bhattiprolu +------------------+ 26250c6c31SSukadev Bhattiprolu | Privilege States | 27250c6c31SSukadev Bhattiprolu +==================+ 28250c6c31SSukadev Bhattiprolu | Problem | 29250c6c31SSukadev Bhattiprolu +------------------+ 30250c6c31SSukadev Bhattiprolu | Supervisor | 31250c6c31SSukadev Bhattiprolu +------------------+ 32250c6c31SSukadev Bhattiprolu | Hypervisor | 33250c6c31SSukadev Bhattiprolu +------------------+ 34250c6c31SSukadev Bhattiprolu | Ultravisor | 35250c6c31SSukadev Bhattiprolu +------------------+ 36250c6c31SSukadev Bhattiprolu 37250c6c31SSukadev Bhattiprolu PEF protects SVMs from the hypervisor, privileged users, and other 38250c6c31SSukadev Bhattiprolu VMs in the system. SVMs are protected while at rest and can only be 39250c6c31SSukadev Bhattiprolu executed by an authorized machine. All virtual machines utilize 40250c6c31SSukadev Bhattiprolu hypervisor services. The Ultravisor filters calls between the SVMs 41250c6c31SSukadev Bhattiprolu and the hypervisor to assure that information does not accidentally 42250c6c31SSukadev Bhattiprolu leak. All hypercalls except H_RANDOM are reflected to the hypervisor. 43250c6c31SSukadev Bhattiprolu H_RANDOM is not reflected to prevent the hypervisor from influencing 44250c6c31SSukadev Bhattiprolu random values in the SVM. 45250c6c31SSukadev Bhattiprolu 46250c6c31SSukadev Bhattiprolu To support this there is a refactoring of the ownership of resources 47250c6c31SSukadev Bhattiprolu in the CPU. Some of the resources which were previously hypervisor 48250c6c31SSukadev Bhattiprolu privileged are now ultravisor privileged. 49250c6c31SSukadev Bhattiprolu 50250c6c31SSukadev BhattiproluHardware 51250c6c31SSukadev Bhattiprolu======== 52250c6c31SSukadev Bhattiprolu 53250c6c31SSukadev Bhattiprolu The hardware changes include the following: 54250c6c31SSukadev Bhattiprolu 55250c6c31SSukadev Bhattiprolu * There is a new bit in the MSR that determines whether the current 56250c6c31SSukadev Bhattiprolu process is running in secure mode, MSR(S) bit 41. MSR(S)=1, process 57250c6c31SSukadev Bhattiprolu is in secure mode, MSR(s)=0 process is in normal mode. 58250c6c31SSukadev Bhattiprolu 59250c6c31SSukadev Bhattiprolu * The MSR(S) bit can only be set by the Ultravisor. 60250c6c31SSukadev Bhattiprolu 61250c6c31SSukadev Bhattiprolu * HRFID cannot be used to set the MSR(S) bit. If the hypervisor needs 62250c6c31SSukadev Bhattiprolu to return to a SVM it must use an ultracall. It can determine if 63250c6c31SSukadev Bhattiprolu the VM it is returning to is secure. 64250c6c31SSukadev Bhattiprolu 65250c6c31SSukadev Bhattiprolu * There is a new Ultravisor privileged register, SMFCTRL, which has an 66250c6c31SSukadev Bhattiprolu enable/disable bit SMFCTRL(E). 67250c6c31SSukadev Bhattiprolu 68250c6c31SSukadev Bhattiprolu * The privilege of a process is now determined by three MSR bits, 69250c6c31SSukadev Bhattiprolu MSR(S, HV, PR). In each of the tables below the modes are listed 70250c6c31SSukadev Bhattiprolu from least privilege to highest privilege. The higher privilege 71250c6c31SSukadev Bhattiprolu modes can access all the resources of the lower privilege modes. 72250c6c31SSukadev Bhattiprolu 73250c6c31SSukadev Bhattiprolu **Secure Mode MSR Settings** 74250c6c31SSukadev Bhattiprolu 75250c6c31SSukadev Bhattiprolu +---+---+---+---------------+ 76250c6c31SSukadev Bhattiprolu | S | HV| PR|Privilege | 77250c6c31SSukadev Bhattiprolu +===+===+===+===============+ 78250c6c31SSukadev Bhattiprolu | 1 | 0 | 1 | Problem | 79250c6c31SSukadev Bhattiprolu +---+---+---+---------------+ 80250c6c31SSukadev Bhattiprolu | 1 | 0 | 0 | Privileged(OS)| 81250c6c31SSukadev Bhattiprolu +---+---+---+---------------+ 82250c6c31SSukadev Bhattiprolu | 1 | 1 | 0 | Ultravisor | 83250c6c31SSukadev Bhattiprolu +---+---+---+---------------+ 84250c6c31SSukadev Bhattiprolu | 1 | 1 | 1 | Reserved | 85250c6c31SSukadev Bhattiprolu +---+---+---+---------------+ 86250c6c31SSukadev Bhattiprolu 87250c6c31SSukadev Bhattiprolu **Normal Mode MSR Settings** 88250c6c31SSukadev Bhattiprolu 89250c6c31SSukadev Bhattiprolu +---+---+---+---------------+ 90250c6c31SSukadev Bhattiprolu | S | HV| PR|Privilege | 91250c6c31SSukadev Bhattiprolu +===+===+===+===============+ 92250c6c31SSukadev Bhattiprolu | 0 | 0 | 1 | Problem | 93250c6c31SSukadev Bhattiprolu +---+---+---+---------------+ 94250c6c31SSukadev Bhattiprolu | 0 | 0 | 0 | Privileged(OS)| 95250c6c31SSukadev Bhattiprolu +---+---+---+---------------+ 96250c6c31SSukadev Bhattiprolu | 0 | 1 | 0 | Hypervisor | 97250c6c31SSukadev Bhattiprolu +---+---+---+---------------+ 98250c6c31SSukadev Bhattiprolu | 0 | 1 | 1 | Problem (Host)| 99250c6c31SSukadev Bhattiprolu +---+---+---+---------------+ 100250c6c31SSukadev Bhattiprolu 101250c6c31SSukadev Bhattiprolu * Memory is partitioned into secure and normal memory. Only processes 102250c6c31SSukadev Bhattiprolu that are running in secure mode can access secure memory. 103250c6c31SSukadev Bhattiprolu 104250c6c31SSukadev Bhattiprolu * The hardware does not allow anything that is not running secure to 105250c6c31SSukadev Bhattiprolu access secure memory. This means that the Hypervisor cannot access 106250c6c31SSukadev Bhattiprolu the memory of the SVM without using an ultracall (asking the 107250c6c31SSukadev Bhattiprolu Ultravisor). The Ultravisor will only allow the hypervisor to see 108250c6c31SSukadev Bhattiprolu the SVM memory encrypted. 109250c6c31SSukadev Bhattiprolu 110250c6c31SSukadev Bhattiprolu * I/O systems are not allowed to directly address secure memory. This 111250c6c31SSukadev Bhattiprolu limits the SVMs to virtual I/O only. 112250c6c31SSukadev Bhattiprolu 113250c6c31SSukadev Bhattiprolu * The architecture allows the SVM to share pages of memory with the 114250c6c31SSukadev Bhattiprolu hypervisor that are not protected with encryption. However, this 115250c6c31SSukadev Bhattiprolu sharing must be initiated by the SVM. 116250c6c31SSukadev Bhattiprolu 117250c6c31SSukadev Bhattiprolu * When a process is running in secure mode all hypercalls 118250c6c31SSukadev Bhattiprolu (syscall lev=1) go to the Ultravisor. 119250c6c31SSukadev Bhattiprolu 120250c6c31SSukadev Bhattiprolu * When a process is in secure mode all interrupts go to the 121250c6c31SSukadev Bhattiprolu Ultravisor. 122250c6c31SSukadev Bhattiprolu 123250c6c31SSukadev Bhattiprolu * The following resources have become Ultravisor privileged and 124250c6c31SSukadev Bhattiprolu require an Ultravisor interface to manipulate: 125250c6c31SSukadev Bhattiprolu 126250c6c31SSukadev Bhattiprolu * Processor configurations registers (SCOMs). 127250c6c31SSukadev Bhattiprolu 128250c6c31SSukadev Bhattiprolu * Stop state information. 129250c6c31SSukadev Bhattiprolu 130250c6c31SSukadev Bhattiprolu * The debug registers CIABR, DAWR, and DAWRX when SMFCTRL(D) is set. 131250c6c31SSukadev Bhattiprolu If SMFCTRL(D) is not set they do not work in secure mode. When set, 132250c6c31SSukadev Bhattiprolu reading and writing requires an Ultravisor call, otherwise that 133250c6c31SSukadev Bhattiprolu will cause a Hypervisor Emulation Assistance interrupt. 134250c6c31SSukadev Bhattiprolu 135250c6c31SSukadev Bhattiprolu * PTCR and partition table entries (partition table is in secure 136250c6c31SSukadev Bhattiprolu memory). An attempt to write to PTCR will cause a Hypervisor 137250c6c31SSukadev Bhattiprolu Emulation Assitance interrupt. 138250c6c31SSukadev Bhattiprolu 139250c6c31SSukadev Bhattiprolu * LDBAR (LD Base Address Register) and IMC (In-Memory Collection) 140250c6c31SSukadev Bhattiprolu non-architected registers. An attempt to write to them will cause a 141250c6c31SSukadev Bhattiprolu Hypervisor Emulation Assistance interrupt. 142250c6c31SSukadev Bhattiprolu 143250c6c31SSukadev Bhattiprolu * Paging for an SVM, sharing of memory with Hypervisor for an SVM. 144250c6c31SSukadev Bhattiprolu (Including Virtual Processor Area (VPA) and virtual I/O). 145250c6c31SSukadev Bhattiprolu 146250c6c31SSukadev Bhattiprolu 147250c6c31SSukadev BhattiproluSoftware/Microcode 148250c6c31SSukadev Bhattiprolu================== 149250c6c31SSukadev Bhattiprolu 150250c6c31SSukadev Bhattiprolu The software changes include: 151250c6c31SSukadev Bhattiprolu 152250c6c31SSukadev Bhattiprolu * SVMs are created from normal VM using (open source) tooling supplied 153250c6c31SSukadev Bhattiprolu by IBM. 154250c6c31SSukadev Bhattiprolu 155250c6c31SSukadev Bhattiprolu * All SVMs start as normal VMs and utilize an ultracall, UV_ESM 156250c6c31SSukadev Bhattiprolu (Enter Secure Mode), to make the transition. 157250c6c31SSukadev Bhattiprolu 158250c6c31SSukadev Bhattiprolu * When the UV_ESM ultracall is made the Ultravisor copies the VM into 159250c6c31SSukadev Bhattiprolu secure memory, decrypts the verification information, and checks the 160250c6c31SSukadev Bhattiprolu integrity of the SVM. If the integrity check passes the Ultravisor 161250c6c31SSukadev Bhattiprolu passes control in secure mode. 162250c6c31SSukadev Bhattiprolu 163250c6c31SSukadev Bhattiprolu * The verification information includes the pass phrase for the 164250c6c31SSukadev Bhattiprolu encrypted disk associated with the SVM. This pass phrase is given 165250c6c31SSukadev Bhattiprolu to the SVM when requested. 166250c6c31SSukadev Bhattiprolu 167250c6c31SSukadev Bhattiprolu * The Ultravisor is not involved in protecting the encrypted disk of 168250c6c31SSukadev Bhattiprolu the SVM while at rest. 169250c6c31SSukadev Bhattiprolu 170250c6c31SSukadev Bhattiprolu * For external interrupts the Ultravisor saves the state of the SVM, 171250c6c31SSukadev Bhattiprolu and reflects the interrupt to the hypervisor for processing. 172250c6c31SSukadev Bhattiprolu For hypercalls, the Ultravisor inserts neutral state into all 173250c6c31SSukadev Bhattiprolu registers not needed for the hypercall then reflects the call to 174250c6c31SSukadev Bhattiprolu the hypervisor for processing. The H_RANDOM hypercall is performed 175250c6c31SSukadev Bhattiprolu by the Ultravisor and not reflected. 176250c6c31SSukadev Bhattiprolu 177250c6c31SSukadev Bhattiprolu * For virtual I/O to work bounce buffering must be done. 178250c6c31SSukadev Bhattiprolu 179250c6c31SSukadev Bhattiprolu * The Ultravisor uses AES (IAPM) for protection of SVM memory. IAPM 180250c6c31SSukadev Bhattiprolu is a mode of AES that provides integrity and secrecy concurrently. 181250c6c31SSukadev Bhattiprolu 182250c6c31SSukadev Bhattiprolu * The movement of data between normal and secure pages is coordinated 183250c6c31SSukadev Bhattiprolu with the Ultravisor by a new HMM plug-in in the Hypervisor. 184250c6c31SSukadev Bhattiprolu 185250c6c31SSukadev Bhattiprolu The Ultravisor offers new services to the hypervisor and SVMs. These 186250c6c31SSukadev Bhattiprolu are accessed through ultracalls. 187250c6c31SSukadev Bhattiprolu 188250c6c31SSukadev BhattiproluTerminology 189250c6c31SSukadev Bhattiprolu=========== 190250c6c31SSukadev Bhattiprolu 191250c6c31SSukadev Bhattiprolu * Hypercalls: special system calls used to request services from 192250c6c31SSukadev Bhattiprolu Hypervisor. 193250c6c31SSukadev Bhattiprolu 194250c6c31SSukadev Bhattiprolu * Normal memory: Memory that is accessible to Hypervisor. 195250c6c31SSukadev Bhattiprolu 196250c6c31SSukadev Bhattiprolu * Normal page: Page backed by normal memory and available to 197250c6c31SSukadev Bhattiprolu Hypervisor. 198250c6c31SSukadev Bhattiprolu 199250c6c31SSukadev Bhattiprolu * Shared page: A page backed by normal memory and available to both 200250c6c31SSukadev Bhattiprolu the Hypervisor/QEMU and the SVM (i.e page has mappings in SVM and 201250c6c31SSukadev Bhattiprolu Hypervisor/QEMU). 202250c6c31SSukadev Bhattiprolu 203250c6c31SSukadev Bhattiprolu * Secure memory: Memory that is accessible only to Ultravisor and 204250c6c31SSukadev Bhattiprolu SVMs. 205250c6c31SSukadev Bhattiprolu 206250c6c31SSukadev Bhattiprolu * Secure page: Page backed by secure memory and only available to 207250c6c31SSukadev Bhattiprolu Ultravisor and SVM. 208250c6c31SSukadev Bhattiprolu 209250c6c31SSukadev Bhattiprolu * SVM: Secure Virtual Machine. 210250c6c31SSukadev Bhattiprolu 211250c6c31SSukadev Bhattiprolu * Ultracalls: special system calls used to request services from 212250c6c31SSukadev Bhattiprolu Ultravisor. 213250c6c31SSukadev Bhattiprolu 214250c6c31SSukadev Bhattiprolu 215250c6c31SSukadev BhattiproluUltravisor calls API 216250c6c31SSukadev Bhattiprolu#################### 217250c6c31SSukadev Bhattiprolu 218250c6c31SSukadev Bhattiprolu This section describes Ultravisor calls (ultracalls) needed to 219250c6c31SSukadev Bhattiprolu support Secure Virtual Machines (SVM)s and Paravirtualized KVM. The 220250c6c31SSukadev Bhattiprolu ultracalls allow the SVMs and Hypervisor to request services from the 221250c6c31SSukadev Bhattiprolu Ultravisor such as accessing a register or memory region that can only 222250c6c31SSukadev Bhattiprolu be accessed when running in Ultravisor-privileged mode. 223250c6c31SSukadev Bhattiprolu 224250c6c31SSukadev Bhattiprolu The specific service needed from an ultracall is specified in register 225250c6c31SSukadev Bhattiprolu R3 (the first parameter to the ultracall). Other parameters to the 226250c6c31SSukadev Bhattiprolu ultracall, if any, are specified in registers R4 through R12. 227250c6c31SSukadev Bhattiprolu 228250c6c31SSukadev Bhattiprolu Return value of all ultracalls is in register R3. Other output values 229250c6c31SSukadev Bhattiprolu from the ultracall, if any, are returned in registers R4 through R12. 230250c6c31SSukadev Bhattiprolu The only exception to this register usage is the ``UV_RETURN`` 231250c6c31SSukadev Bhattiprolu ultracall described below. 232250c6c31SSukadev Bhattiprolu 233250c6c31SSukadev Bhattiprolu Each ultracall returns specific error codes, applicable in the context 234250c6c31SSukadev Bhattiprolu of the ultracall. However, like with the PowerPC Architecture Platform 235250c6c31SSukadev Bhattiprolu Reference (PAPR), if no specific error code is defined for a 236250c6c31SSukadev Bhattiprolu particular situation, then the ultracall will fallback to an erroneous 237250c6c31SSukadev Bhattiprolu parameter-position based code. i.e U_PARAMETER, U_P2, U_P3 etc 238250c6c31SSukadev Bhattiprolu depending on the ultracall parameter that may have caused the error. 239250c6c31SSukadev Bhattiprolu 240250c6c31SSukadev Bhattiprolu Some ultracalls involve transferring a page of data between Ultravisor 241250c6c31SSukadev Bhattiprolu and Hypervisor. Secure pages that are transferred from secure memory 242250c6c31SSukadev Bhattiprolu to normal memory may be encrypted using dynamically generated keys. 243250c6c31SSukadev Bhattiprolu When the secure pages are transferred back to secure memory, they may 244250c6c31SSukadev Bhattiprolu be decrypted using the same dynamically generated keys. Generation and 245250c6c31SSukadev Bhattiprolu management of these keys will be covered in a separate document. 246250c6c31SSukadev Bhattiprolu 247250c6c31SSukadev Bhattiprolu For now this only covers ultracalls currently implemented and being 248250c6c31SSukadev Bhattiprolu used by Hypervisor and SVMs but others can be added here when it 249250c6c31SSukadev Bhattiprolu makes sense. 250250c6c31SSukadev Bhattiprolu 251250c6c31SSukadev Bhattiprolu The full specification for all hypercalls/ultracalls will eventually 252250c6c31SSukadev Bhattiprolu be made available in the public/OpenPower version of the PAPR 253250c6c31SSukadev Bhattiprolu specification. 254250c6c31SSukadev Bhattiprolu 255ad9b48c5SAdam Zerella .. note:: 256250c6c31SSukadev Bhattiprolu 257250c6c31SSukadev Bhattiprolu If PEF is not enabled, the ultracalls will be redirected to the 258250c6c31SSukadev Bhattiprolu Hypervisor which must handle/fail the calls. 259250c6c31SSukadev Bhattiprolu 260250c6c31SSukadev BhattiproluUltracalls used by Hypervisor 261250c6c31SSukadev Bhattiprolu============================= 262250c6c31SSukadev Bhattiprolu 263250c6c31SSukadev Bhattiprolu This section describes the virtual memory management ultracalls used 264250c6c31SSukadev Bhattiprolu by the Hypervisor to manage SVMs. 265250c6c31SSukadev Bhattiprolu 266250c6c31SSukadev BhattiproluUV_PAGE_OUT 267250c6c31SSukadev Bhattiprolu----------- 268250c6c31SSukadev Bhattiprolu 269250c6c31SSukadev Bhattiprolu Encrypt and move the contents of a page from secure memory to normal 270250c6c31SSukadev Bhattiprolu memory. 271250c6c31SSukadev Bhattiprolu 272250c6c31SSukadev BhattiproluSyntax 273250c6c31SSukadev Bhattiprolu~~~~~~ 274250c6c31SSukadev Bhattiprolu 275250c6c31SSukadev Bhattiprolu.. code-block:: c 276250c6c31SSukadev Bhattiprolu 277250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_PAGE_OUT, 278250c6c31SSukadev Bhattiprolu uint16_t lpid, /* LPAR ID */ 279250c6c31SSukadev Bhattiprolu uint64_t dest_ra, /* real address of destination page */ 280250c6c31SSukadev Bhattiprolu uint64_t src_gpa, /* source guest-physical-address */ 281250c6c31SSukadev Bhattiprolu uint8_t flags, /* flags */ 282250c6c31SSukadev Bhattiprolu uint64_t order) /* page size order */ 283250c6c31SSukadev Bhattiprolu 284250c6c31SSukadev BhattiproluReturn values 285250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 286250c6c31SSukadev Bhattiprolu 287250c6c31SSukadev Bhattiprolu One of the following values: 288250c6c31SSukadev Bhattiprolu 289250c6c31SSukadev Bhattiprolu * U_SUCCESS on success. 290250c6c31SSukadev Bhattiprolu * U_PARAMETER if ``lpid`` is invalid. 291250c6c31SSukadev Bhattiprolu * U_P2 if ``dest_ra`` is invalid. 292250c6c31SSukadev Bhattiprolu * U_P3 if the ``src_gpa`` address is invalid. 293250c6c31SSukadev Bhattiprolu * U_P4 if any bit in the ``flags`` is unrecognized 294250c6c31SSukadev Bhattiprolu * U_P5 if the ``order`` parameter is unsupported. 295250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported. 296250c6c31SSukadev Bhattiprolu * U_BUSY if page cannot be currently paged-out. 297250c6c31SSukadev Bhattiprolu 298250c6c31SSukadev BhattiproluDescription 299250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 300250c6c31SSukadev Bhattiprolu 301250c6c31SSukadev Bhattiprolu Encrypt the contents of a secure-page and make it available to 302250c6c31SSukadev Bhattiprolu Hypervisor in a normal page. 303250c6c31SSukadev Bhattiprolu 304250c6c31SSukadev Bhattiprolu By default, the source page is unmapped from the SVM's partition- 305250c6c31SSukadev Bhattiprolu scoped page table. But the Hypervisor can provide a hint to the 306250c6c31SSukadev Bhattiprolu Ultravisor to retain the page mapping by setting the ``UV_SNAPSHOT`` 307250c6c31SSukadev Bhattiprolu flag in ``flags`` parameter. 308250c6c31SSukadev Bhattiprolu 309250c6c31SSukadev Bhattiprolu If the source page is already a shared page the call returns 310250c6c31SSukadev Bhattiprolu U_SUCCESS, without doing anything. 311250c6c31SSukadev Bhattiprolu 312250c6c31SSukadev BhattiproluUse cases 313250c6c31SSukadev Bhattiprolu~~~~~~~~~ 314250c6c31SSukadev Bhattiprolu 315250c6c31SSukadev Bhattiprolu #. QEMU attempts to access an address belonging to the SVM but the 316250c6c31SSukadev Bhattiprolu page frame for that address is not mapped into QEMU's address 317250c6c31SSukadev Bhattiprolu space. In this case, the Hypervisor will allocate a page frame, 318250c6c31SSukadev Bhattiprolu map it into QEMU's address space and issue the ``UV_PAGE_OUT`` 319250c6c31SSukadev Bhattiprolu call to retrieve the encrypted contents of the page. 320250c6c31SSukadev Bhattiprolu 321250c6c31SSukadev Bhattiprolu #. When Ultravisor runs low on secure memory and it needs to page-out 322250c6c31SSukadev Bhattiprolu an LRU page. In this case, Ultravisor will issue the 323250c6c31SSukadev Bhattiprolu ``H_SVM_PAGE_OUT`` hypercall to the Hypervisor. The Hypervisor will 324250c6c31SSukadev Bhattiprolu then allocate a normal page and issue the ``UV_PAGE_OUT`` ultracall 325250c6c31SSukadev Bhattiprolu and the Ultravisor will encrypt and move the contents of the secure 326250c6c31SSukadev Bhattiprolu page into the normal page. 327250c6c31SSukadev Bhattiprolu 328250c6c31SSukadev Bhattiprolu #. When Hypervisor accesses SVM data, the Hypervisor requests the 329250c6c31SSukadev Bhattiprolu Ultravisor to transfer the corresponding page into a insecure page, 330250c6c31SSukadev Bhattiprolu which the Hypervisor can access. The data in the normal page will 331250c6c31SSukadev Bhattiprolu be encrypted though. 332250c6c31SSukadev Bhattiprolu 333250c6c31SSukadev BhattiproluUV_PAGE_IN 334250c6c31SSukadev Bhattiprolu---------- 335250c6c31SSukadev Bhattiprolu 336250c6c31SSukadev Bhattiprolu Move the contents of a page from normal memory to secure memory. 337250c6c31SSukadev Bhattiprolu 338250c6c31SSukadev BhattiproluSyntax 339250c6c31SSukadev Bhattiprolu~~~~~~ 340250c6c31SSukadev Bhattiprolu 341250c6c31SSukadev Bhattiprolu.. code-block:: c 342250c6c31SSukadev Bhattiprolu 343250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_PAGE_IN, 344250c6c31SSukadev Bhattiprolu uint16_t lpid, /* the LPAR ID */ 345250c6c31SSukadev Bhattiprolu uint64_t src_ra, /* source real address of page */ 346250c6c31SSukadev Bhattiprolu uint64_t dest_gpa, /* destination guest physical address */ 347250c6c31SSukadev Bhattiprolu uint64_t flags, /* flags */ 348250c6c31SSukadev Bhattiprolu uint64_t order) /* page size order */ 349250c6c31SSukadev Bhattiprolu 350250c6c31SSukadev BhattiproluReturn values 351250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 352250c6c31SSukadev Bhattiprolu 353250c6c31SSukadev Bhattiprolu One of the following values: 354250c6c31SSukadev Bhattiprolu 355250c6c31SSukadev Bhattiprolu * U_SUCCESS on success. 356250c6c31SSukadev Bhattiprolu * U_BUSY if page cannot be currently paged-in. 357250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported 358250c6c31SSukadev Bhattiprolu * U_PARAMETER if ``lpid`` is invalid. 359250c6c31SSukadev Bhattiprolu * U_P2 if ``src_ra`` is invalid. 360250c6c31SSukadev Bhattiprolu * U_P3 if the ``dest_gpa`` address is invalid. 361250c6c31SSukadev Bhattiprolu * U_P4 if any bit in the ``flags`` is unrecognized 362250c6c31SSukadev Bhattiprolu * U_P5 if the ``order`` parameter is unsupported. 363250c6c31SSukadev Bhattiprolu 364250c6c31SSukadev BhattiproluDescription 365250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 366250c6c31SSukadev Bhattiprolu 367250c6c31SSukadev Bhattiprolu Move the contents of the page identified by ``src_ra`` from normal 368250c6c31SSukadev Bhattiprolu memory to secure memory and map it to the guest physical address 369250c6c31SSukadev Bhattiprolu ``dest_gpa``. 370250c6c31SSukadev Bhattiprolu 371250c6c31SSukadev Bhattiprolu If `dest_gpa` refers to a shared address, map the page into the 372250c6c31SSukadev Bhattiprolu partition-scoped page-table of the SVM. If `dest_gpa` is not shared, 373250c6c31SSukadev Bhattiprolu copy the contents of the page into the corresponding secure page. 374250c6c31SSukadev Bhattiprolu Depending on the context, decrypt the page before being copied. 375250c6c31SSukadev Bhattiprolu 376250c6c31SSukadev Bhattiprolu The caller provides the attributes of the page through the ``flags`` 377250c6c31SSukadev Bhattiprolu parameter. Valid values for ``flags`` are: 378250c6c31SSukadev Bhattiprolu 379250c6c31SSukadev Bhattiprolu * CACHE_INHIBITED 380250c6c31SSukadev Bhattiprolu * CACHE_ENABLED 381250c6c31SSukadev Bhattiprolu * WRITE_PROTECTION 382250c6c31SSukadev Bhattiprolu 383250c6c31SSukadev Bhattiprolu The Hypervisor must pin the page in memory before making 384250c6c31SSukadev Bhattiprolu ``UV_PAGE_IN`` ultracall. 385250c6c31SSukadev Bhattiprolu 386250c6c31SSukadev BhattiproluUse cases 387250c6c31SSukadev Bhattiprolu~~~~~~~~~ 388250c6c31SSukadev Bhattiprolu 389250c6c31SSukadev Bhattiprolu #. When a normal VM switches to secure mode, all its pages residing 390250c6c31SSukadev Bhattiprolu in normal memory, are moved into secure memory. 391250c6c31SSukadev Bhattiprolu 392250c6c31SSukadev Bhattiprolu #. When an SVM requests to share a page with Hypervisor the Hypervisor 393250c6c31SSukadev Bhattiprolu allocates a page and informs the Ultravisor. 394250c6c31SSukadev Bhattiprolu 395250c6c31SSukadev Bhattiprolu #. When an SVM accesses a secure page that has been paged-out, 396250c6c31SSukadev Bhattiprolu Ultravisor invokes the Hypervisor to locate the page. After 397250c6c31SSukadev Bhattiprolu locating the page, the Hypervisor uses UV_PAGE_IN to make the 398250c6c31SSukadev Bhattiprolu page available to Ultravisor. 399250c6c31SSukadev Bhattiprolu 400250c6c31SSukadev BhattiproluUV_PAGE_INVAL 401250c6c31SSukadev Bhattiprolu------------- 402250c6c31SSukadev Bhattiprolu 403250c6c31SSukadev Bhattiprolu Invalidate the Ultravisor mapping of a page. 404250c6c31SSukadev Bhattiprolu 405250c6c31SSukadev BhattiproluSyntax 406250c6c31SSukadev Bhattiprolu~~~~~~ 407250c6c31SSukadev Bhattiprolu 408250c6c31SSukadev Bhattiprolu.. code-block:: c 409250c6c31SSukadev Bhattiprolu 410250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_PAGE_INVAL, 411250c6c31SSukadev Bhattiprolu uint16_t lpid, /* the LPAR ID */ 412250c6c31SSukadev Bhattiprolu uint64_t guest_pa, /* destination guest-physical-address */ 413250c6c31SSukadev Bhattiprolu uint64_t order) /* page size order */ 414250c6c31SSukadev Bhattiprolu 415250c6c31SSukadev BhattiproluReturn values 416250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 417250c6c31SSukadev Bhattiprolu 418250c6c31SSukadev Bhattiprolu One of the following values: 419250c6c31SSukadev Bhattiprolu 420250c6c31SSukadev Bhattiprolu * U_SUCCESS on success. 421250c6c31SSukadev Bhattiprolu * U_PARAMETER if ``lpid`` is invalid. 422250c6c31SSukadev Bhattiprolu * U_P2 if ``guest_pa`` is invalid (or corresponds to a secure 423250c6c31SSukadev Bhattiprolu page mapping). 424250c6c31SSukadev Bhattiprolu * U_P3 if the ``order`` is invalid. 425250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported. 426250c6c31SSukadev Bhattiprolu * U_BUSY if page cannot be currently invalidated. 427250c6c31SSukadev Bhattiprolu 428250c6c31SSukadev BhattiproluDescription 429250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 430250c6c31SSukadev Bhattiprolu 431250c6c31SSukadev Bhattiprolu This ultracall informs Ultravisor that the page mapping in Hypervisor 432250c6c31SSukadev Bhattiprolu corresponding to the given guest physical address has been invalidated 433250c6c31SSukadev Bhattiprolu and that the Ultravisor should not access the page. If the specified 434250c6c31SSukadev Bhattiprolu ``guest_pa`` corresponds to a secure page, Ultravisor will ignore the 435250c6c31SSukadev Bhattiprolu attempt to invalidate the page and return U_P2. 436250c6c31SSukadev Bhattiprolu 437250c6c31SSukadev BhattiproluUse cases 438250c6c31SSukadev Bhattiprolu~~~~~~~~~ 439250c6c31SSukadev Bhattiprolu 440250c6c31SSukadev Bhattiprolu #. When a shared page is unmapped from the QEMU's page table, possibly 441250c6c31SSukadev Bhattiprolu because it is paged-out to disk, Ultravisor needs to know that the 442250c6c31SSukadev Bhattiprolu page should not be accessed from its side too. 443250c6c31SSukadev Bhattiprolu 444250c6c31SSukadev Bhattiprolu 445250c6c31SSukadev BhattiproluUV_WRITE_PATE 446250c6c31SSukadev Bhattiprolu------------- 447250c6c31SSukadev Bhattiprolu 448250c6c31SSukadev Bhattiprolu Validate and write the partition table entry (PATE) for a given 449250c6c31SSukadev Bhattiprolu partition. 450250c6c31SSukadev Bhattiprolu 451250c6c31SSukadev BhattiproluSyntax 452250c6c31SSukadev Bhattiprolu~~~~~~ 453250c6c31SSukadev Bhattiprolu 454250c6c31SSukadev Bhattiprolu.. code-block:: c 455250c6c31SSukadev Bhattiprolu 456250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_WRITE_PATE, 457250c6c31SSukadev Bhattiprolu uint32_t lpid, /* the LPAR ID */ 458250c6c31SSukadev Bhattiprolu uint64_t dw0 /* the first double word to write */ 459250c6c31SSukadev Bhattiprolu uint64_t dw1) /* the second double word to write */ 460250c6c31SSukadev Bhattiprolu 461250c6c31SSukadev BhattiproluReturn values 462250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 463250c6c31SSukadev Bhattiprolu 464250c6c31SSukadev Bhattiprolu One of the following values: 465250c6c31SSukadev Bhattiprolu 466250c6c31SSukadev Bhattiprolu * U_SUCCESS on success. 467250c6c31SSukadev Bhattiprolu * U_BUSY if PATE cannot be currently written to. 468250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported. 469250c6c31SSukadev Bhattiprolu * U_PARAMETER if ``lpid`` is invalid. 470250c6c31SSukadev Bhattiprolu * U_P2 if ``dw0`` is invalid. 471250c6c31SSukadev Bhattiprolu * U_P3 if the ``dw1`` address is invalid. 472250c6c31SSukadev Bhattiprolu * U_PERMISSION if the Hypervisor is attempting to change the PATE 473250c6c31SSukadev Bhattiprolu of a secure virtual machine or if called from a 474250c6c31SSukadev Bhattiprolu context other than Hypervisor. 475250c6c31SSukadev Bhattiprolu 476250c6c31SSukadev BhattiproluDescription 477250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 478250c6c31SSukadev Bhattiprolu 479250c6c31SSukadev Bhattiprolu Validate and write a LPID and its partition-table-entry for the given 480250c6c31SSukadev Bhattiprolu LPID. If the LPID is already allocated and initialized, this call 481250c6c31SSukadev Bhattiprolu results in changing the partition table entry. 482250c6c31SSukadev Bhattiprolu 483250c6c31SSukadev BhattiproluUse cases 484250c6c31SSukadev Bhattiprolu~~~~~~~~~ 485250c6c31SSukadev Bhattiprolu 486250c6c31SSukadev Bhattiprolu #. The Partition table resides in Secure memory and its entries, 487250c6c31SSukadev Bhattiprolu called PATE (Partition Table Entries), point to the partition- 488250c6c31SSukadev Bhattiprolu scoped page tables for the Hypervisor as well as each of the 489250c6c31SSukadev Bhattiprolu virtual machines (both secure and normal). The Hypervisor 490250c6c31SSukadev Bhattiprolu operates in partition 0 and its partition-scoped page tables 491250c6c31SSukadev Bhattiprolu reside in normal memory. 492250c6c31SSukadev Bhattiprolu 493250c6c31SSukadev Bhattiprolu #. This ultracall allows the Hypervisor to register the partition- 494250c6c31SSukadev Bhattiprolu scoped and process-scoped page table entries for the Hypervisor 495250c6c31SSukadev Bhattiprolu and other partitions (virtual machines) with the Ultravisor. 496250c6c31SSukadev Bhattiprolu 497250c6c31SSukadev Bhattiprolu #. If the value of the PATE for an existing partition (VM) changes, 498250c6c31SSukadev Bhattiprolu the TLB cache for the partition is flushed. 499250c6c31SSukadev Bhattiprolu 500250c6c31SSukadev Bhattiprolu #. The Hypervisor is responsible for allocating LPID. The LPID and 501250c6c31SSukadev Bhattiprolu its PATE entry are registered together. The Hypervisor manages 502250c6c31SSukadev Bhattiprolu the PATE entries for a normal VM and can change the PATE entry 503250c6c31SSukadev Bhattiprolu anytime. Ultravisor manages the PATE entries for an SVM and 504250c6c31SSukadev Bhattiprolu Hypervisor is not allowed to modify them. 505250c6c31SSukadev Bhattiprolu 506250c6c31SSukadev BhattiproluUV_RETURN 507250c6c31SSukadev Bhattiprolu--------- 508250c6c31SSukadev Bhattiprolu 509250c6c31SSukadev Bhattiprolu Return control from the Hypervisor back to the Ultravisor after 510250c6c31SSukadev Bhattiprolu processing an hypercall or interrupt that was forwarded (aka 511250c6c31SSukadev Bhattiprolu *reflected*) to the Hypervisor. 512250c6c31SSukadev Bhattiprolu 513250c6c31SSukadev BhattiproluSyntax 514250c6c31SSukadev Bhattiprolu~~~~~~ 515250c6c31SSukadev Bhattiprolu 516250c6c31SSukadev Bhattiprolu.. code-block:: c 517250c6c31SSukadev Bhattiprolu 518250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_RETURN) 519250c6c31SSukadev Bhattiprolu 520250c6c31SSukadev BhattiproluReturn values 521250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 522250c6c31SSukadev Bhattiprolu 523250c6c31SSukadev Bhattiprolu This call never returns to Hypervisor on success. It returns 524250c6c31SSukadev Bhattiprolu U_INVALID if ultracall is not made from a Hypervisor context. 525250c6c31SSukadev Bhattiprolu 526250c6c31SSukadev BhattiproluDescription 527250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 528250c6c31SSukadev Bhattiprolu 529250c6c31SSukadev Bhattiprolu When an SVM makes an hypercall or incurs some other exception, the 530250c6c31SSukadev Bhattiprolu Ultravisor usually forwards (aka *reflects*) the exceptions to the 531250c6c31SSukadev Bhattiprolu Hypervisor. After processing the exception, Hypervisor uses the 532250c6c31SSukadev Bhattiprolu ``UV_RETURN`` ultracall to return control back to the SVM. 533250c6c31SSukadev Bhattiprolu 534250c6c31SSukadev Bhattiprolu The expected register state on entry to this ultracall is: 535250c6c31SSukadev Bhattiprolu 536250c6c31SSukadev Bhattiprolu * Non-volatile registers are restored to their original values. 537250c6c31SSukadev Bhattiprolu * If returning from an hypercall, register R0 contains the return 538250c6c31SSukadev Bhattiprolu value (**unlike other ultracalls**) and, registers R4 through R12 539250c6c31SSukadev Bhattiprolu contain any output values of the hypercall. 540250c6c31SSukadev Bhattiprolu * R3 contains the ultracall number, i.e UV_RETURN. 541250c6c31SSukadev Bhattiprolu * If returning with a synthesized interrupt, R2 contains the 542250c6c31SSukadev Bhattiprolu synthesized interrupt number. 543250c6c31SSukadev Bhattiprolu 544250c6c31SSukadev BhattiproluUse cases 545250c6c31SSukadev Bhattiprolu~~~~~~~~~ 546250c6c31SSukadev Bhattiprolu 547250c6c31SSukadev Bhattiprolu #. Ultravisor relies on the Hypervisor to provide several services to 548250c6c31SSukadev Bhattiprolu the SVM such as processing hypercall and other exceptions. After 549250c6c31SSukadev Bhattiprolu processing the exception, Hypervisor uses UV_RETURN to return 550250c6c31SSukadev Bhattiprolu control back to the Ultravisor. 551250c6c31SSukadev Bhattiprolu 552250c6c31SSukadev Bhattiprolu #. Hypervisor has to use this ultracall to return control to the SVM. 553250c6c31SSukadev Bhattiprolu 554250c6c31SSukadev Bhattiprolu 555250c6c31SSukadev BhattiproluUV_REGISTER_MEM_SLOT 556250c6c31SSukadev Bhattiprolu-------------------- 557250c6c31SSukadev Bhattiprolu 558250c6c31SSukadev Bhattiprolu Register an SVM address-range with specified properties. 559250c6c31SSukadev Bhattiprolu 560250c6c31SSukadev BhattiproluSyntax 561250c6c31SSukadev Bhattiprolu~~~~~~ 562250c6c31SSukadev Bhattiprolu 563250c6c31SSukadev Bhattiprolu.. code-block:: c 564250c6c31SSukadev Bhattiprolu 565250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_REGISTER_MEM_SLOT, 566250c6c31SSukadev Bhattiprolu uint64_t lpid, /* LPAR ID of the SVM */ 567250c6c31SSukadev Bhattiprolu uint64_t start_gpa, /* start guest physical address */ 568250c6c31SSukadev Bhattiprolu uint64_t size, /* size of address range in bytes */ 569250c6c31SSukadev Bhattiprolu uint64_t flags /* reserved for future expansion */ 570250c6c31SSukadev Bhattiprolu uint16_t slotid) /* slot identifier */ 571250c6c31SSukadev Bhattiprolu 572250c6c31SSukadev BhattiproluReturn values 573250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 574250c6c31SSukadev Bhattiprolu 575250c6c31SSukadev Bhattiprolu One of the following values: 576250c6c31SSukadev Bhattiprolu 577250c6c31SSukadev Bhattiprolu * U_SUCCESS on success. 578250c6c31SSukadev Bhattiprolu * U_PARAMETER if ``lpid`` is invalid. 579250c6c31SSukadev Bhattiprolu * U_P2 if ``start_gpa`` is invalid. 580250c6c31SSukadev Bhattiprolu * U_P3 if ``size`` is invalid. 581250c6c31SSukadev Bhattiprolu * U_P4 if any bit in the ``flags`` is unrecognized. 582250c6c31SSukadev Bhattiprolu * U_P5 if the ``slotid`` parameter is unsupported. 583250c6c31SSukadev Bhattiprolu * U_PERMISSION if called from context other than Hypervisor. 584250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported. 585250c6c31SSukadev Bhattiprolu 586250c6c31SSukadev Bhattiprolu 587250c6c31SSukadev BhattiproluDescription 588250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 589250c6c31SSukadev Bhattiprolu 590250c6c31SSukadev Bhattiprolu Register a memory range for an SVM. The memory range starts at the 591250c6c31SSukadev Bhattiprolu guest physical address ``start_gpa`` and is ``size`` bytes long. 592250c6c31SSukadev Bhattiprolu 593250c6c31SSukadev BhattiproluUse cases 594250c6c31SSukadev Bhattiprolu~~~~~~~~~ 595250c6c31SSukadev Bhattiprolu 596250c6c31SSukadev Bhattiprolu 597250c6c31SSukadev Bhattiprolu #. When a virtual machine goes secure, all the memory slots managed by 598250c6c31SSukadev Bhattiprolu the Hypervisor move into secure memory. The Hypervisor iterates 599250c6c31SSukadev Bhattiprolu through each of memory slots, and registers the slot with 600250c6c31SSukadev Bhattiprolu Ultravisor. Hypervisor may discard some slots such as those used 601250c6c31SSukadev Bhattiprolu for firmware (SLOF). 602250c6c31SSukadev Bhattiprolu 603250c6c31SSukadev Bhattiprolu #. When new memory is hot-plugged, a new memory slot gets registered. 604250c6c31SSukadev Bhattiprolu 605250c6c31SSukadev Bhattiprolu 606250c6c31SSukadev BhattiproluUV_UNREGISTER_MEM_SLOT 607250c6c31SSukadev Bhattiprolu---------------------- 608250c6c31SSukadev Bhattiprolu 609250c6c31SSukadev Bhattiprolu Unregister an SVM address-range that was previously registered using 610250c6c31SSukadev Bhattiprolu UV_REGISTER_MEM_SLOT. 611250c6c31SSukadev Bhattiprolu 612250c6c31SSukadev BhattiproluSyntax 613250c6c31SSukadev Bhattiprolu~~~~~~ 614250c6c31SSukadev Bhattiprolu 615250c6c31SSukadev Bhattiprolu.. code-block:: c 616250c6c31SSukadev Bhattiprolu 617250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_UNREGISTER_MEM_SLOT, 618250c6c31SSukadev Bhattiprolu uint64_t lpid, /* LPAR ID of the SVM */ 619250c6c31SSukadev Bhattiprolu uint64_t slotid) /* reservation slotid */ 620250c6c31SSukadev Bhattiprolu 621250c6c31SSukadev BhattiproluReturn values 622250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 623250c6c31SSukadev Bhattiprolu 624250c6c31SSukadev Bhattiprolu One of the following values: 625250c6c31SSukadev Bhattiprolu 626250c6c31SSukadev Bhattiprolu * U_SUCCESS on success. 627250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported. 628250c6c31SSukadev Bhattiprolu * U_PARAMETER if ``lpid`` is invalid. 629250c6c31SSukadev Bhattiprolu * U_P2 if ``slotid`` is invalid. 630250c6c31SSukadev Bhattiprolu * U_PERMISSION if called from context other than Hypervisor. 631250c6c31SSukadev Bhattiprolu 632250c6c31SSukadev BhattiproluDescription 633250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 634250c6c31SSukadev Bhattiprolu 635250c6c31SSukadev Bhattiprolu Release the memory slot identified by ``slotid`` and free any 636250c6c31SSukadev Bhattiprolu resources allocated towards the reservation. 637250c6c31SSukadev Bhattiprolu 638250c6c31SSukadev BhattiproluUse cases 639250c6c31SSukadev Bhattiprolu~~~~~~~~~ 640250c6c31SSukadev Bhattiprolu 641250c6c31SSukadev Bhattiprolu #. Memory hot-remove. 642250c6c31SSukadev Bhattiprolu 643250c6c31SSukadev Bhattiprolu 644250c6c31SSukadev BhattiproluUV_SVM_TERMINATE 645250c6c31SSukadev Bhattiprolu---------------- 646250c6c31SSukadev Bhattiprolu 647250c6c31SSukadev Bhattiprolu Terminate an SVM and release its resources. 648250c6c31SSukadev Bhattiprolu 649250c6c31SSukadev BhattiproluSyntax 650250c6c31SSukadev Bhattiprolu~~~~~~ 651250c6c31SSukadev Bhattiprolu 652250c6c31SSukadev Bhattiprolu.. code-block:: c 653250c6c31SSukadev Bhattiprolu 654250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_SVM_TERMINATE, 655250c6c31SSukadev Bhattiprolu uint64_t lpid, /* LPAR ID of the SVM */) 656250c6c31SSukadev Bhattiprolu 657250c6c31SSukadev BhattiproluReturn values 658250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 659250c6c31SSukadev Bhattiprolu 660250c6c31SSukadev Bhattiprolu One of the following values: 661250c6c31SSukadev Bhattiprolu 662250c6c31SSukadev Bhattiprolu * U_SUCCESS on success. 663250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported. 664250c6c31SSukadev Bhattiprolu * U_PARAMETER if ``lpid`` is invalid. 665250c6c31SSukadev Bhattiprolu * U_INVALID if VM is not secure. 666250c6c31SSukadev Bhattiprolu * U_PERMISSION if not called from a Hypervisor context. 667250c6c31SSukadev Bhattiprolu 668250c6c31SSukadev BhattiproluDescription 669250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 670250c6c31SSukadev Bhattiprolu 671250c6c31SSukadev Bhattiprolu Terminate an SVM and release all its resources. 672250c6c31SSukadev Bhattiprolu 673250c6c31SSukadev BhattiproluUse cases 674250c6c31SSukadev Bhattiprolu~~~~~~~~~ 675250c6c31SSukadev Bhattiprolu 676250c6c31SSukadev Bhattiprolu #. Called by Hypervisor when terminating an SVM. 677250c6c31SSukadev Bhattiprolu 678250c6c31SSukadev Bhattiprolu 679250c6c31SSukadev BhattiproluUltracalls used by SVM 680250c6c31SSukadev Bhattiprolu====================== 681250c6c31SSukadev Bhattiprolu 682250c6c31SSukadev BhattiproluUV_SHARE_PAGE 683250c6c31SSukadev Bhattiprolu------------- 684250c6c31SSukadev Bhattiprolu 685250c6c31SSukadev Bhattiprolu Share a set of guest physical pages with the Hypervisor. 686250c6c31SSukadev Bhattiprolu 687250c6c31SSukadev BhattiproluSyntax 688250c6c31SSukadev Bhattiprolu~~~~~~ 689250c6c31SSukadev Bhattiprolu 690250c6c31SSukadev Bhattiprolu.. code-block:: c 691250c6c31SSukadev Bhattiprolu 692250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_SHARE_PAGE, 693250c6c31SSukadev Bhattiprolu uint64_t gfn, /* guest page frame number */ 694250c6c31SSukadev Bhattiprolu uint64_t num) /* number of pages of size PAGE_SIZE */ 695250c6c31SSukadev Bhattiprolu 696250c6c31SSukadev BhattiproluReturn values 697250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 698250c6c31SSukadev Bhattiprolu 699250c6c31SSukadev Bhattiprolu One of the following values: 700250c6c31SSukadev Bhattiprolu 701250c6c31SSukadev Bhattiprolu * U_SUCCESS on success. 702250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported. 703250c6c31SSukadev Bhattiprolu * U_INVALID if the VM is not secure. 704250c6c31SSukadev Bhattiprolu * U_PARAMETER if ``gfn`` is invalid. 705250c6c31SSukadev Bhattiprolu * U_P2 if ``num`` is invalid. 706250c6c31SSukadev Bhattiprolu 707250c6c31SSukadev BhattiproluDescription 708250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 709250c6c31SSukadev Bhattiprolu 710250c6c31SSukadev Bhattiprolu Share the ``num`` pages starting at guest physical frame number ``gfn`` 711250c6c31SSukadev Bhattiprolu with the Hypervisor. Assume page size is PAGE_SIZE bytes. Zero the 712250c6c31SSukadev Bhattiprolu pages before returning. 713250c6c31SSukadev Bhattiprolu 714250c6c31SSukadev Bhattiprolu If the address is already backed by a secure page, unmap the page and 715250c6c31SSukadev Bhattiprolu back it with an insecure page, with the help of the Hypervisor. If it 716250c6c31SSukadev Bhattiprolu is not backed by any page yet, mark the PTE as insecure and back it 717250c6c31SSukadev Bhattiprolu with an insecure page when the address is accessed. If it is already 718250c6c31SSukadev Bhattiprolu backed by an insecure page, zero the page and return. 719250c6c31SSukadev Bhattiprolu 720250c6c31SSukadev BhattiproluUse cases 721250c6c31SSukadev Bhattiprolu~~~~~~~~~ 722250c6c31SSukadev Bhattiprolu 723250c6c31SSukadev Bhattiprolu #. The Hypervisor cannot access the SVM pages since they are backed by 724250c6c31SSukadev Bhattiprolu secure pages. Hence an SVM must explicitly request Ultravisor for 725250c6c31SSukadev Bhattiprolu pages it can share with Hypervisor. 726250c6c31SSukadev Bhattiprolu 727250c6c31SSukadev Bhattiprolu #. Shared pages are needed to support virtio and Virtual Processor Area 728250c6c31SSukadev Bhattiprolu (VPA) in SVMs. 729250c6c31SSukadev Bhattiprolu 730250c6c31SSukadev Bhattiprolu 731250c6c31SSukadev BhattiproluUV_UNSHARE_PAGE 732250c6c31SSukadev Bhattiprolu--------------- 733250c6c31SSukadev Bhattiprolu 734250c6c31SSukadev Bhattiprolu Restore a shared SVM page to its initial state. 735250c6c31SSukadev Bhattiprolu 736250c6c31SSukadev BhattiproluSyntax 737250c6c31SSukadev Bhattiprolu~~~~~~ 738250c6c31SSukadev Bhattiprolu 739250c6c31SSukadev Bhattiprolu.. code-block:: c 740250c6c31SSukadev Bhattiprolu 741250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_UNSHARE_PAGE, 742250c6c31SSukadev Bhattiprolu uint64_t gfn, /* guest page frame number */ 743250c6c31SSukadev Bhattiprolu uint73 num) /* number of pages of size PAGE_SIZE*/ 744250c6c31SSukadev Bhattiprolu 745250c6c31SSukadev BhattiproluReturn values 746250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 747250c6c31SSukadev Bhattiprolu 748250c6c31SSukadev Bhattiprolu One of the following values: 749250c6c31SSukadev Bhattiprolu 750250c6c31SSukadev Bhattiprolu * U_SUCCESS on success. 751250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported. 752250c6c31SSukadev Bhattiprolu * U_INVALID if VM is not secure. 753250c6c31SSukadev Bhattiprolu * U_PARAMETER if ``gfn`` is invalid. 754250c6c31SSukadev Bhattiprolu * U_P2 if ``num`` is invalid. 755250c6c31SSukadev Bhattiprolu 756250c6c31SSukadev BhattiproluDescription 757250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 758250c6c31SSukadev Bhattiprolu 759250c6c31SSukadev Bhattiprolu Stop sharing ``num`` pages starting at ``gfn`` with the Hypervisor. 760250c6c31SSukadev Bhattiprolu Assume that the page size is PAGE_SIZE. Zero the pages before 761250c6c31SSukadev Bhattiprolu returning. 762250c6c31SSukadev Bhattiprolu 763250c6c31SSukadev Bhattiprolu If the address is already backed by an insecure page, unmap the page 764250c6c31SSukadev Bhattiprolu and back it with a secure page. Inform the Hypervisor to release 765250c6c31SSukadev Bhattiprolu reference to its shared page. If the address is not backed by a page 766250c6c31SSukadev Bhattiprolu yet, mark the PTE as secure and back it with a secure page when that 767250c6c31SSukadev Bhattiprolu address is accessed. If it is already backed by an secure page zero 768250c6c31SSukadev Bhattiprolu the page and return. 769250c6c31SSukadev Bhattiprolu 770250c6c31SSukadev BhattiproluUse cases 771250c6c31SSukadev Bhattiprolu~~~~~~~~~ 772250c6c31SSukadev Bhattiprolu 773250c6c31SSukadev Bhattiprolu #. The SVM may decide to unshare a page from the Hypervisor. 774250c6c31SSukadev Bhattiprolu 775250c6c31SSukadev Bhattiprolu 776250c6c31SSukadev BhattiproluUV_UNSHARE_ALL_PAGES 777250c6c31SSukadev Bhattiprolu-------------------- 778250c6c31SSukadev Bhattiprolu 779250c6c31SSukadev Bhattiprolu Unshare all pages the SVM has shared with Hypervisor. 780250c6c31SSukadev Bhattiprolu 781250c6c31SSukadev BhattiproluSyntax 782250c6c31SSukadev Bhattiprolu~~~~~~ 783250c6c31SSukadev Bhattiprolu 784250c6c31SSukadev Bhattiprolu.. code-block:: c 785250c6c31SSukadev Bhattiprolu 786250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_UNSHARE_ALL_PAGES) 787250c6c31SSukadev Bhattiprolu 788250c6c31SSukadev BhattiproluReturn values 789250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 790250c6c31SSukadev Bhattiprolu 791250c6c31SSukadev Bhattiprolu One of the following values: 792250c6c31SSukadev Bhattiprolu 793250c6c31SSukadev Bhattiprolu * U_SUCCESS on success. 794250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported. 795250c6c31SSukadev Bhattiprolu * U_INVAL if VM is not secure. 796250c6c31SSukadev Bhattiprolu 797250c6c31SSukadev BhattiproluDescription 798250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 799250c6c31SSukadev Bhattiprolu 800250c6c31SSukadev Bhattiprolu Unshare all shared pages from the Hypervisor. All unshared pages are 801250c6c31SSukadev Bhattiprolu zeroed on return. Only pages explicitly shared by the SVM with the 802250c6c31SSukadev Bhattiprolu Hypervisor (using UV_SHARE_PAGE ultracall) are unshared. Ultravisor 803250c6c31SSukadev Bhattiprolu may internally share some pages with the Hypervisor without explicit 804250c6c31SSukadev Bhattiprolu request from the SVM. These pages will not be unshared by this 805250c6c31SSukadev Bhattiprolu ultracall. 806250c6c31SSukadev Bhattiprolu 807250c6c31SSukadev BhattiproluUse cases 808250c6c31SSukadev Bhattiprolu~~~~~~~~~ 809250c6c31SSukadev Bhattiprolu 810250c6c31SSukadev Bhattiprolu #. This call is needed when ``kexec`` is used to boot a different 811250c6c31SSukadev Bhattiprolu kernel. It may also be needed during SVM reset. 812250c6c31SSukadev Bhattiprolu 813250c6c31SSukadev BhattiproluUV_ESM 814250c6c31SSukadev Bhattiprolu------ 815250c6c31SSukadev Bhattiprolu 816250c6c31SSukadev Bhattiprolu Secure the virtual machine (*enter secure mode*). 817250c6c31SSukadev Bhattiprolu 818250c6c31SSukadev BhattiproluSyntax 819250c6c31SSukadev Bhattiprolu~~~~~~ 820250c6c31SSukadev Bhattiprolu 821250c6c31SSukadev Bhattiprolu.. code-block:: c 822250c6c31SSukadev Bhattiprolu 823250c6c31SSukadev Bhattiprolu uint64_t ultracall(const uint64_t UV_ESM, 824250c6c31SSukadev Bhattiprolu uint64_t esm_blob_addr, /* location of the ESM blob */ 825250c6c31SSukadev Bhattiprolu unint64_t fdt) /* Flattened device tree */ 826250c6c31SSukadev Bhattiprolu 827250c6c31SSukadev BhattiproluReturn values 828250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 829250c6c31SSukadev Bhattiprolu 830250c6c31SSukadev Bhattiprolu One of the following values: 831250c6c31SSukadev Bhattiprolu 832250c6c31SSukadev Bhattiprolu * U_SUCCESS on success (including if VM is already secure). 833250c6c31SSukadev Bhattiprolu * U_FUNCTION if functionality is not supported. 834250c6c31SSukadev Bhattiprolu * U_INVALID if VM is not secure. 835250c6c31SSukadev Bhattiprolu * U_PARAMETER if ``esm_blob_addr`` is invalid. 836250c6c31SSukadev Bhattiprolu * U_P2 if ``fdt`` is invalid. 837250c6c31SSukadev Bhattiprolu * U_PERMISSION if any integrity checks fail. 838250c6c31SSukadev Bhattiprolu * U_RETRY insufficient memory to create SVM. 839250c6c31SSukadev Bhattiprolu * U_NO_KEY symmetric key unavailable. 840250c6c31SSukadev Bhattiprolu 841250c6c31SSukadev BhattiproluDescription 842250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 843250c6c31SSukadev Bhattiprolu 844250c6c31SSukadev Bhattiprolu Secure the virtual machine. On successful completion, return 845250c6c31SSukadev Bhattiprolu control to the virtual machine at the address specified in the 846250c6c31SSukadev Bhattiprolu ESM blob. 847250c6c31SSukadev Bhattiprolu 848250c6c31SSukadev BhattiproluUse cases 849250c6c31SSukadev Bhattiprolu~~~~~~~~~ 850250c6c31SSukadev Bhattiprolu 851250c6c31SSukadev Bhattiprolu #. A normal virtual machine can choose to switch to a secure mode. 852250c6c31SSukadev Bhattiprolu 853250c6c31SSukadev BhattiproluHypervisor Calls API 854250c6c31SSukadev Bhattiprolu#################### 855250c6c31SSukadev Bhattiprolu 856250c6c31SSukadev Bhattiprolu This document describes the Hypervisor calls (hypercalls) that are 857250c6c31SSukadev Bhattiprolu needed to support the Ultravisor. Hypercalls are services provided by 858250c6c31SSukadev Bhattiprolu the Hypervisor to virtual machines and Ultravisor. 859250c6c31SSukadev Bhattiprolu 860250c6c31SSukadev Bhattiprolu Register usage for these hypercalls is identical to that of the other 861250c6c31SSukadev Bhattiprolu hypercalls defined in the Power Architecture Platform Reference (PAPR) 862250c6c31SSukadev Bhattiprolu document. i.e on input, register R3 identifies the specific service 863250c6c31SSukadev Bhattiprolu that is being requested and registers R4 through R11 contain 864250c6c31SSukadev Bhattiprolu additional parameters to the hypercall, if any. On output, register 865250c6c31SSukadev Bhattiprolu R3 contains the return value and registers R4 through R9 contain any 866250c6c31SSukadev Bhattiprolu other output values from the hypercall. 867250c6c31SSukadev Bhattiprolu 868250c6c31SSukadev Bhattiprolu This document only covers hypercalls currently implemented/planned 869250c6c31SSukadev Bhattiprolu for Ultravisor usage but others can be added here when it makes sense. 870250c6c31SSukadev Bhattiprolu 871250c6c31SSukadev Bhattiprolu The full specification for all hypercalls/ultracalls will eventually 872250c6c31SSukadev Bhattiprolu be made available in the public/OpenPower version of the PAPR 873250c6c31SSukadev Bhattiprolu specification. 874250c6c31SSukadev Bhattiprolu 875250c6c31SSukadev BhattiproluHypervisor calls to support Ultravisor 876250c6c31SSukadev Bhattiprolu====================================== 877250c6c31SSukadev Bhattiprolu 878250c6c31SSukadev Bhattiprolu Following are the set of hypercalls needed to support Ultravisor. 879250c6c31SSukadev Bhattiprolu 880250c6c31SSukadev BhattiproluH_SVM_INIT_START 881250c6c31SSukadev Bhattiprolu---------------- 882250c6c31SSukadev Bhattiprolu 883250c6c31SSukadev Bhattiprolu Begin the process of converting a normal virtual machine into an SVM. 884250c6c31SSukadev Bhattiprolu 885250c6c31SSukadev BhattiproluSyntax 886250c6c31SSukadev Bhattiprolu~~~~~~ 887250c6c31SSukadev Bhattiprolu 888250c6c31SSukadev Bhattiprolu.. code-block:: c 889250c6c31SSukadev Bhattiprolu 890250c6c31SSukadev Bhattiprolu uint64_t hypercall(const uint64_t H_SVM_INIT_START) 891250c6c31SSukadev Bhattiprolu 892250c6c31SSukadev BhattiproluReturn values 893250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 894250c6c31SSukadev Bhattiprolu 895250c6c31SSukadev Bhattiprolu One of the following values: 896250c6c31SSukadev Bhattiprolu 897250c6c31SSukadev Bhattiprolu * H_SUCCESS on success. 8982027a24aSRam Pai * H_STATE if the VM is not in a position to switch to secure. 899250c6c31SSukadev Bhattiprolu 900250c6c31SSukadev BhattiproluDescription 901250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 902250c6c31SSukadev Bhattiprolu 903250c6c31SSukadev Bhattiprolu Initiate the process of securing a virtual machine. This involves 904250c6c31SSukadev Bhattiprolu coordinating with the Ultravisor, using ultracalls, to allocate 905250c6c31SSukadev Bhattiprolu resources in the Ultravisor for the new SVM, transferring the VM's 906250c6c31SSukadev Bhattiprolu pages from normal to secure memory etc. When the process is 907250c6c31SSukadev Bhattiprolu completed, Ultravisor issues the H_SVM_INIT_DONE hypercall. 908250c6c31SSukadev Bhattiprolu 909250c6c31SSukadev BhattiproluUse cases 910250c6c31SSukadev Bhattiprolu~~~~~~~~~ 911250c6c31SSukadev Bhattiprolu 912250c6c31SSukadev Bhattiprolu #. Ultravisor uses this hypercall to inform Hypervisor that a VM 913250c6c31SSukadev Bhattiprolu has initiated the process of switching to secure mode. 914250c6c31SSukadev Bhattiprolu 915250c6c31SSukadev Bhattiprolu 916250c6c31SSukadev BhattiproluH_SVM_INIT_DONE 917250c6c31SSukadev Bhattiprolu--------------- 918250c6c31SSukadev Bhattiprolu 919250c6c31SSukadev Bhattiprolu Complete the process of securing an SVM. 920250c6c31SSukadev Bhattiprolu 921250c6c31SSukadev BhattiproluSyntax 922250c6c31SSukadev Bhattiprolu~~~~~~ 923250c6c31SSukadev Bhattiprolu 924250c6c31SSukadev Bhattiprolu.. code-block:: c 925250c6c31SSukadev Bhattiprolu 926250c6c31SSukadev Bhattiprolu uint64_t hypercall(const uint64_t H_SVM_INIT_DONE) 927250c6c31SSukadev Bhattiprolu 928250c6c31SSukadev BhattiproluReturn values 929250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 930250c6c31SSukadev Bhattiprolu 931250c6c31SSukadev Bhattiprolu One of the following values: 932250c6c31SSukadev Bhattiprolu 933250c6c31SSukadev Bhattiprolu * H_SUCCESS on success. 934250c6c31SSukadev Bhattiprolu * H_UNSUPPORTED if called from the wrong context (e.g. 935250c6c31SSukadev Bhattiprolu from an SVM or before an H_SVM_INIT_START 936250c6c31SSukadev Bhattiprolu hypercall). 937*dfaa973aSRam Pai * H_STATE if the hypervisor could not successfully 938*dfaa973aSRam Pai transition the VM to Secure VM. 939250c6c31SSukadev Bhattiprolu 940250c6c31SSukadev BhattiproluDescription 941250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 942250c6c31SSukadev Bhattiprolu 943250c6c31SSukadev Bhattiprolu Complete the process of securing a virtual machine. This call must 944250c6c31SSukadev Bhattiprolu be made after a prior call to ``H_SVM_INIT_START`` hypercall. 945250c6c31SSukadev Bhattiprolu 946250c6c31SSukadev BhattiproluUse cases 947250c6c31SSukadev Bhattiprolu~~~~~~~~~ 948250c6c31SSukadev Bhattiprolu 949250c6c31SSukadev Bhattiprolu On successfully securing a virtual machine, the Ultravisor informs 950250c6c31SSukadev Bhattiprolu Hypervisor about it. Hypervisor can use this call to finish setting 951250c6c31SSukadev Bhattiprolu up its internal state for this virtual machine. 952250c6c31SSukadev Bhattiprolu 953250c6c31SSukadev Bhattiprolu 9543a43970dSSukadev BhattiproluH_SVM_INIT_ABORT 9553a43970dSSukadev Bhattiprolu---------------- 9563a43970dSSukadev Bhattiprolu 9573a43970dSSukadev Bhattiprolu Abort the process of securing an SVM. 9583a43970dSSukadev Bhattiprolu 9593a43970dSSukadev BhattiproluSyntax 9603a43970dSSukadev Bhattiprolu~~~~~~ 9613a43970dSSukadev Bhattiprolu 9623a43970dSSukadev Bhattiprolu.. code-block:: c 9633a43970dSSukadev Bhattiprolu 9643a43970dSSukadev Bhattiprolu uint64_t hypercall(const uint64_t H_SVM_INIT_ABORT) 9653a43970dSSukadev Bhattiprolu 9663a43970dSSukadev BhattiproluReturn values 9673a43970dSSukadev Bhattiprolu~~~~~~~~~~~~~ 9683a43970dSSukadev Bhattiprolu 9693a43970dSSukadev Bhattiprolu One of the following values: 9703a43970dSSukadev Bhattiprolu 9713a43970dSSukadev Bhattiprolu * H_PARAMETER on successfully cleaning up the state, 9723a43970dSSukadev Bhattiprolu Hypervisor will return this value to the 9733a43970dSSukadev Bhattiprolu **guest**, to indicate that the underlying 9743a43970dSSukadev Bhattiprolu UV_ESM ultracall failed. 9753a43970dSSukadev Bhattiprolu 9763a43970dSSukadev Bhattiprolu * H_STATE if called after a VM has gone secure (i.e 9773a43970dSSukadev Bhattiprolu H_SVM_INIT_DONE hypercall was successful). 9783a43970dSSukadev Bhattiprolu 9793a43970dSSukadev Bhattiprolu * H_UNSUPPORTED if called from a wrong context (e.g. from a 9803a43970dSSukadev Bhattiprolu normal VM). 9813a43970dSSukadev Bhattiprolu 9823a43970dSSukadev BhattiproluDescription 9833a43970dSSukadev Bhattiprolu~~~~~~~~~~~ 9843a43970dSSukadev Bhattiprolu 9853a43970dSSukadev Bhattiprolu Abort the process of securing a virtual machine. This call must 9863a43970dSSukadev Bhattiprolu be made after a prior call to ``H_SVM_INIT_START`` hypercall and 9873a43970dSSukadev Bhattiprolu before a call to ``H_SVM_INIT_DONE``. 9883a43970dSSukadev Bhattiprolu 9893a43970dSSukadev Bhattiprolu On entry into this hypercall the non-volatile GPRs and FPRs are 9903a43970dSSukadev Bhattiprolu expected to contain the values they had at the time the VM issued 9913a43970dSSukadev Bhattiprolu the UV_ESM ultracall. Further ``SRR0`` is expected to contain the 9923a43970dSSukadev Bhattiprolu address of the instruction after the ``UV_ESM`` ultracall and ``SRR1`` 9933a43970dSSukadev Bhattiprolu the MSR value with which to return to the VM. 9943a43970dSSukadev Bhattiprolu 9953a43970dSSukadev Bhattiprolu This hypercall will cleanup any partial state that was established for 9963a43970dSSukadev Bhattiprolu the VM since the prior ``H_SVM_INIT_START`` hypercall, including paging 9973a43970dSSukadev Bhattiprolu out pages that were paged-into secure memory, and issue the 9983a43970dSSukadev Bhattiprolu ``UV_SVM_TERMINATE`` ultracall to terminate the VM. 9993a43970dSSukadev Bhattiprolu 10003a43970dSSukadev Bhattiprolu After the partial state is cleaned up, control returns to the VM 10013a43970dSSukadev Bhattiprolu (**not Ultravisor**), at the address specified in ``SRR0`` with the 10023a43970dSSukadev Bhattiprolu MSR values set to the value in ``SRR1``. 10033a43970dSSukadev Bhattiprolu 10043a43970dSSukadev BhattiproluUse cases 10053a43970dSSukadev Bhattiprolu~~~~~~~~~ 10063a43970dSSukadev Bhattiprolu 10073a43970dSSukadev Bhattiprolu If after a successful call to ``H_SVM_INIT_START``, the Ultravisor 10083a43970dSSukadev Bhattiprolu encounters an error while securing a virtual machine, either due 10093a43970dSSukadev Bhattiprolu to lack of resources or because the VM's security information could 10103a43970dSSukadev Bhattiprolu not be validated, Ultravisor informs the Hypervisor about it. 10113a43970dSSukadev Bhattiprolu Hypervisor should use this call to clean up any internal state for 10123a43970dSSukadev Bhattiprolu this virtual machine and return to the VM. 10133a43970dSSukadev Bhattiprolu 1014250c6c31SSukadev BhattiproluH_SVM_PAGE_IN 1015250c6c31SSukadev Bhattiprolu------------- 1016250c6c31SSukadev Bhattiprolu 1017250c6c31SSukadev Bhattiprolu Move the contents of a page from normal memory to secure memory. 1018250c6c31SSukadev Bhattiprolu 1019250c6c31SSukadev BhattiproluSyntax 1020250c6c31SSukadev Bhattiprolu~~~~~~ 1021250c6c31SSukadev Bhattiprolu 1022250c6c31SSukadev Bhattiprolu.. code-block:: c 1023250c6c31SSukadev Bhattiprolu 1024250c6c31SSukadev Bhattiprolu uint64_t hypercall(const uint64_t H_SVM_PAGE_IN, 1025250c6c31SSukadev Bhattiprolu uint64_t guest_pa, /* guest-physical-address */ 1026250c6c31SSukadev Bhattiprolu uint64_t flags, /* flags */ 1027250c6c31SSukadev Bhattiprolu uint64_t order) /* page size order */ 1028250c6c31SSukadev Bhattiprolu 1029250c6c31SSukadev BhattiproluReturn values 1030250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 1031250c6c31SSukadev Bhattiprolu 1032250c6c31SSukadev Bhattiprolu One of the following values: 1033250c6c31SSukadev Bhattiprolu 1034250c6c31SSukadev Bhattiprolu * H_SUCCESS on success. 1035250c6c31SSukadev Bhattiprolu * H_PARAMETER if ``guest_pa`` is invalid. 1036250c6c31SSukadev Bhattiprolu * H_P2 if ``flags`` is invalid. 1037250c6c31SSukadev Bhattiprolu * H_P3 if ``order`` of page is invalid. 1038250c6c31SSukadev Bhattiprolu 1039250c6c31SSukadev BhattiproluDescription 1040250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 1041250c6c31SSukadev Bhattiprolu 1042250c6c31SSukadev Bhattiprolu Retrieve the content of the page, belonging to the VM at the specified 1043250c6c31SSukadev Bhattiprolu guest physical address. 1044250c6c31SSukadev Bhattiprolu 1045250c6c31SSukadev Bhattiprolu Only valid value(s) in ``flags`` are: 1046250c6c31SSukadev Bhattiprolu 1047250c6c31SSukadev Bhattiprolu * H_PAGE_IN_SHARED which indicates that the page is to be shared 1048250c6c31SSukadev Bhattiprolu with the Ultravisor. 1049250c6c31SSukadev Bhattiprolu 1050250c6c31SSukadev Bhattiprolu * H_PAGE_IN_NONSHARED indicates that the UV is not anymore 1051250c6c31SSukadev Bhattiprolu interested in the page. Applicable if the page is a shared page. 1052250c6c31SSukadev Bhattiprolu 1053250c6c31SSukadev Bhattiprolu The ``order`` parameter must correspond to the configured page size. 1054250c6c31SSukadev Bhattiprolu 1055250c6c31SSukadev BhattiproluUse cases 1056250c6c31SSukadev Bhattiprolu~~~~~~~~~ 1057250c6c31SSukadev Bhattiprolu 1058250c6c31SSukadev Bhattiprolu #. When a normal VM becomes a secure VM (using the UV_ESM ultracall), 1059250c6c31SSukadev Bhattiprolu the Ultravisor uses this hypercall to move contents of each page of 1060250c6c31SSukadev Bhattiprolu the VM from normal memory to secure memory. 1061250c6c31SSukadev Bhattiprolu 1062250c6c31SSukadev Bhattiprolu #. Ultravisor uses this hypercall to ask Hypervisor to provide a page 1063250c6c31SSukadev Bhattiprolu in normal memory that can be shared between the SVM and Hypervisor. 1064250c6c31SSukadev Bhattiprolu 1065250c6c31SSukadev Bhattiprolu #. Ultravisor uses this hypercall to page-in a paged-out page. This 1066250c6c31SSukadev Bhattiprolu can happen when the SVM touches a paged-out page. 1067250c6c31SSukadev Bhattiprolu 1068250c6c31SSukadev Bhattiprolu #. If SVM wants to disable sharing of pages with Hypervisor, it can 1069250c6c31SSukadev Bhattiprolu inform Ultravisor to do so. Ultravisor will then use this hypercall 1070250c6c31SSukadev Bhattiprolu and inform Hypervisor that it has released access to the normal 1071250c6c31SSukadev Bhattiprolu page. 1072250c6c31SSukadev Bhattiprolu 1073250c6c31SSukadev BhattiproluH_SVM_PAGE_OUT 1074250c6c31SSukadev Bhattiprolu--------------- 1075250c6c31SSukadev Bhattiprolu 1076250c6c31SSukadev Bhattiprolu Move the contents of the page to normal memory. 1077250c6c31SSukadev Bhattiprolu 1078250c6c31SSukadev BhattiproluSyntax 1079250c6c31SSukadev Bhattiprolu~~~~~~ 1080250c6c31SSukadev Bhattiprolu 1081250c6c31SSukadev Bhattiprolu.. code-block:: c 1082250c6c31SSukadev Bhattiprolu 1083250c6c31SSukadev Bhattiprolu uint64_t hypercall(const uint64_t H_SVM_PAGE_OUT, 1084250c6c31SSukadev Bhattiprolu uint64_t guest_pa, /* guest-physical-address */ 1085250c6c31SSukadev Bhattiprolu uint64_t flags, /* flags (currently none) */ 1086250c6c31SSukadev Bhattiprolu uint64_t order) /* page size order */ 1087250c6c31SSukadev Bhattiprolu 1088250c6c31SSukadev BhattiproluReturn values 1089250c6c31SSukadev Bhattiprolu~~~~~~~~~~~~~ 1090250c6c31SSukadev Bhattiprolu 1091250c6c31SSukadev Bhattiprolu One of the following values: 1092250c6c31SSukadev Bhattiprolu 1093250c6c31SSukadev Bhattiprolu * H_SUCCESS on success. 1094250c6c31SSukadev Bhattiprolu * H_PARAMETER if ``guest_pa`` is invalid. 1095250c6c31SSukadev Bhattiprolu * H_P2 if ``flags`` is invalid. 1096250c6c31SSukadev Bhattiprolu * H_P3 if ``order`` is invalid. 1097250c6c31SSukadev Bhattiprolu 1098250c6c31SSukadev BhattiproluDescription 1099250c6c31SSukadev Bhattiprolu~~~~~~~~~~~ 1100250c6c31SSukadev Bhattiprolu 1101250c6c31SSukadev Bhattiprolu Move the contents of the page identified by ``guest_pa`` to normal 1102250c6c31SSukadev Bhattiprolu memory. 1103250c6c31SSukadev Bhattiprolu 1104250c6c31SSukadev Bhattiprolu Currently ``flags`` is unused and must be set to 0. The ``order`` 1105250c6c31SSukadev Bhattiprolu parameter must correspond to the configured page size. 1106250c6c31SSukadev Bhattiprolu 1107250c6c31SSukadev BhattiproluUse cases 1108250c6c31SSukadev Bhattiprolu~~~~~~~~~ 1109250c6c31SSukadev Bhattiprolu 1110250c6c31SSukadev Bhattiprolu #. If Ultravisor is running low on secure pages, it can move the 1111250c6c31SSukadev Bhattiprolu contents of some secure pages, into normal pages using this 1112250c6c31SSukadev Bhattiprolu hypercall. The content will be encrypted. 1113250c6c31SSukadev Bhattiprolu 1114250c6c31SSukadev BhattiproluReferences 1115250c6c31SSukadev Bhattiprolu########## 1116250c6c31SSukadev Bhattiprolu 1117ad9b48c5SAdam Zerella- `Supporting Protected Computing on IBM Power Architecture <https://developer.ibm.com/articles/l-support-protected-computing/>`_ 1118