요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
.. _ultravisor:
============================
Protected Execution Facility
============================
.. contents::
:depth: 3
Introduction
############
Protected Execution Facility (PEF) is an architectural change for
POWER 9 that enables Secure Virtual Machines (SVMs). DD2.3 chips
(PVR=0x004e1203) or greater will be PEF-capable. A new ISA release
will include the PEF RFC02487 changes.
When enabled, PEF adds a new higher privileged mode, called Ultravisor
mode, to POWER architecture. Along with the new mode there is new
firmware called the Protected Execution Ultravisor (or Ultravisor
for short). Ultravisor mode is the highest privileged mode in POWER
architecture.
+------------------+
| Privilege States |
+==================+
| Problem |
+------------------+
| Supervisor |
+------------------+
| Hypervisor |
+------------------+
| Ultravisor |
+------------------+
PEF protects SVMs from the hypervisor, privileged users, and other
VMs in the system. SVMs are protected while at rest and can only be
executed by an authorized machine. All virtual machines utilize
hypervisor services. The Ultravisor filters calls between the SVMs
and the hypervisor to assure that information does not accidentally
leak. All hypercalls except H_RANDOM are reflected to the hypervisor.
H_RANDOM is not reflected to prevent the hypervisor from influencing
random values in the SVM.
To support this there is a refactoring of the ownership of resources
in the CPU. Some of the resources which were previously hypervisor
privileged are now ultravisor privileged.
Hardware
========
The hardware changes include the following:
* There is a new bit in the MSR that determines whether the current
process is running in secure mode, MSR(S) bit 41. MSR(S)=1, process
is in secure mode, MSR(s)=0 process is in normal mode.
* The MSR(S) bit can only be set by the Ultravisor.
* HRFID cannot be used to set the MSR(S) bit. If the hypervisor needs
to return to a SVM it must use an ultracall. It can determine if
the VM it is returning to is secure.
* There is a new Ultravisor privileged register, SMFCTRL, which has an
enable/disable bit SMFCTRL(E).
* The privilege of a process is now determined by three MSR bits,
MSR(S, HV, PR). In each of the tables below the modes are listed
from least privilege to highest privilege. The higher privilege
modes can access all the resources of the lower privilege modes.
**Secure Mode MSR Settings**
+---+---+---+---------------+
| S | HV| PR|Privilege |
+===+===+===+===============+
| 1 | 0 | 1 | Problem |
+---+---+---+---------------+
| 1 | 0 | 0 | Privileged(OS)|
+---+---+---+---------------+
| 1 | 1 | 0 | Ultravisor |
+---+---+---+---------------+
| 1 | 1 | 1 | Reserved |
+---+---+---+---------------+
**Normal Mode MSR Settings**
+---+---+---+---------------+
| S | HV| PR|Privilege |
+===+===+===+===============+
| 0 | 0 | 1 | Problem |
+---+---+---+---------------+
| 0 | 0 | 0 | Privileged(OS)|
+---+---+---+---------------+
| 0 | 1 | 0 | Hypervisor |
+---+---+---+---------------+
| 0 | 1 | 1 | Problem (Host)|
+---+---+---+---------------+
* Memory is partitioned into secure and normal memory. Only processes
that are running in secure mode can access secure memory.
* The hardware does not allow anything that is not running secure to
access secure memory. This means that the Hypervisor cannot access
the memory of the SVM without using an ultracall (asking the
Ultravisor). The Ultravisor will only allow the hypervisor to see
the SVM memory encrypted.
* I/O systems are not allowed to directly address secure memory. This
limits the SVMs to virtual I/O only.
* The architecture allows the SVM to share pages of memory with the
hypervisor that are not protected with encryption. However, this
sharing must be initiated by the SVM.
* When a process is running in secure mode all hypercalls
(syscall lev=1) go to the Ultravisor.
* When a process is in secure mode all interrupts go to the
Ultravisor.
* The following resources have become Ultravisor privileged and
require an Ultravisor interface to manipulate:
* Processor configurations registers (SCOMs).
* Stop state information.
* The debug registers CIABR, DAWR, and DAWRX when SMFCTRL(D) is set.
If SMFCTRL(D) is not set they do not work in secure mode. When set,
reading and writing requires an Ultravisor call, otherwise that
will cause a Hypervisor Emulation Assistance interrupt.
* PTCR and partition table entries (partition table is in secure
memory). An attempt to write to PTCR will cause a Hypervisor
Emulation Assistance interrupt.
* LDBAR (LD Base Address Register) and IMC (In-Memory Collection)
non-architected registers. An attempt to write to them will cause a
Hypervisor Emulation Assistance interrupt.
* Paging for an SVM, sharing of memory with Hypervisor for an SVM.
(Including Virtual Processor Area (VPA) and virtual I/O).
Software/Microcode
==================
The software changes include:
* SVMs are created from normal VM using (open source) tooling supplied
by IBM.
* All SVMs start as normal VMs and utilize an ultracall, UV_ESM
(Enter Secure Mode), to make the transition.
* When the UV_ESM ultracall is made the Ultravisor copies the VM into
secure memory, decrypts the verification information, and checks the
integrity of the SVM. If the integrity check passes the Ultravisor
passes control in secure mode.
* The verification information includes the pass phrase for the
encrypted disk associated with the SVM. This pass phrase is given
to the SVM when requested.
* The Ultravisor is not involved in protecting the encrypted disk of
the SVM while at rest.
* For external interrupts the Ultravisor saves the state of the SVM,
and reflects the interrupt to the hypervisor for processing.
For hypercalls, the Ultravisor inserts neutral state into all
registers not needed for the hypercall then reflects the call to
the hypervisor for processing. The H_RANDOM hypercall is performed
by the Ultravisor and not reflected.
* For virtual I/O to work bounce buffering must be done.
* The Ultravisor uses AES (IAPM) for protection of SVM memory. IAPM
is a mode of AES that provides integrity and secrecy concurrently.
* The movement of data between normal and secure pages is coordinated
with the Ultravisor by a new HMM plug-in in the Hypervisor.
The Ultravisor offers new services to the hypervisor and SVMs. These
are accessed through ultracalls.
Terminology
===========
* Hypercalls: special system calls used to request services from
Hypervisor.
* Normal memory: Memory that is accessible to Hypervisor.
* Normal page: Page backed by normal memory and available to
Hypervisor.
* Shared page: A page backed by normal memory and available to both
the Hypervisor/QEMU and the SVM (i.e page has mappings in SVM and
Hypervisor/QEMU).
* Secure memory: Memory that is accessible only to Ultravisor and
SVMs.
* Secure page: Page backed by secure memory and only available to
Ultravisor and SVM.
* SVM: Secure Virtual Machine.
* Ultracalls: special system calls used to request services from
Ultravisor.
Ultravisor calls API
####################
This section describes Ultravisor calls (ultracalls) needed to
support Secure Virtual Machines (SVM)s and Paravirtualized KVM. The
ultracalls allow the SVMs and Hypervisor to request services from the
Ultravisor such as accessing a register or memory region that can only
be accessed when running in Ultravisor-privileged mode.
The specific service needed from an ultracall is specified in register
R3 (the first parameter to the ultracall). Other parameters to the
ultracall, if any, are specified in registers R4 through R12.
Return value of all ultracalls is in register R3. Other output values
from the ultracall, if any, are returned in registers R4 through R12.
The only exception to this register usage is the ``UV_RETURN``
ultracall described below.
Each ultracall returns specific error codes, applicable in the context
of the ultracall. However, like with the PowerPC Architecture Platform
Reference (PAPR), if no specific error code is defined for a
particular situation, then the ultracall will fallback to an erroneous
parameter-position based code. i.e U_PARAMETER, U_P2, U_P3 etc
depending on the ultracall parameter that may have caused the error.
Some ultracalls involve transferring a page of data between Ultravisor
and Hypervisor. Secure pages that are transferred from secure memory
to normal memory may be encrypted using dynamically generated keys.
When the secure pages are transferred back to secure memory, they may
be decrypted using the same dynamically generated keys. Generation and
management of these keys will be covered in a separate document.
For now this only covers ultracalls currently implemented and being
used by Hypervisor and SVMs but others can be added here when it
makes sense.
The full specification for all hypercalls/ultracalls will eventually
be made available in the public/OpenPower version of the PAPR
specification.
.. note::
If PEF is not enabled, the ultracalls will be redirected to the
Hypervisor which must handle/fail the calls.
Ultracalls used by Hypervisor
=============================
This section describes the virtual memory management ultracalls used
by the Hypervisor to manage SVMs.
UV_PAGE_OUT
-----------
Encrypt and move the contents of a page from secure memory to normal
memory.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_PAGE_OUT,
uint16_t lpid, /* LPAR ID */
uint64_t dest_ra, /* real address of destination page */
uint64_t src_gpa, /* source guest-physical-address */
uint8_t flags, /* flags */
uint64_t order) /* page size order */
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success.
* U_PARAMETER if ``lpid`` is invalid.
* U_P2 if ``dest_ra`` is invalid.
* U_P3 if the ``src_gpa`` address is invalid.
* U_P4 if any bit in the ``flags`` is unrecognized
* U_P5 if the ``order`` parameter is unsupported.
* U_FUNCTION if functionality is not supported.
* U_BUSY if page cannot be currently paged-out.
Description
~~~~~~~~~~~
Encrypt the contents of a secure-page and make it available to
Hypervisor in a normal page.
By default, the source page is unmapped from the SVM's partition-
scoped page table. But the Hypervisor can provide a hint to the
Ultravisor to retain the page mapping by setting the ``UV_SNAPSHOT``
flag in ``flags`` parameter.
If the source page is already a shared page the call returns
U_SUCCESS, without doing anything.
Use cases
~~~~~~~~~
#. QEMU attempts to access an address belonging to the SVM but the
page frame for that address is not mapped into QEMU's address
space. In this case, the Hypervisor will allocate a page frame,
map it into QEMU's address space and issue the ``UV_PAGE_OUT``
call to retrieve the encrypted contents of the page.
#. When Ultravisor runs low on secure memory and it needs to page-out
an LRU page. In this case, Ultravisor will issue the
``H_SVM_PAGE_OUT`` hypercall to the Hypervisor. The Hypervisor will
then allocate a normal page and issue the ``UV_PAGE_OUT`` ultracall
and the Ultravisor will encrypt and move the contents of the secure
page into the normal page.
#. When Hypervisor accesses SVM data, the Hypervisor requests the
Ultravisor to transfer the corresponding page into a insecure page,
which the Hypervisor can access. The data in the normal page will
be encrypted though.
UV_PAGE_IN
----------
Move the contents of a page from normal memory to secure memory.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_PAGE_IN,
uint16_t lpid, /* the LPAR ID */
uint64_t src_ra, /* source real address of page */
uint64_t dest_gpa, /* destination guest physical address */
uint64_t flags, /* flags */
uint64_t order) /* page size order */
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success.
* U_BUSY if page cannot be currently paged-in.
* U_FUNCTION if functionality is not supported
* U_PARAMETER if ``lpid`` is invalid.
* U_P2 if ``src_ra`` is invalid.
* U_P3 if the ``dest_gpa`` address is invalid.
* U_P4 if any bit in the ``flags`` is unrecognized
* U_P5 if the ``order`` parameter is unsupported.
Description
~~~~~~~~~~~
Move the contents of the page identified by ``src_ra`` from normal
memory to secure memory and map it to the guest physical address
``dest_gpa``.
If `dest_gpa` refers to a shared address, map the page into the
partition-scoped page-table of the SVM. If `dest_gpa` is not shared,
copy the contents of the page into the corresponding secure page.
Depending on the context, decrypt the page before being copied.
The caller provides the attributes of the page through the ``flags``
parameter. Valid values for ``flags`` are:
* CACHE_INHIBITED
* CACHE_ENABLED
* WRITE_PROTECTION
The Hypervisor must pin the page in memory before making
``UV_PAGE_IN`` ultracall.
Use cases
~~~~~~~~~
#. When a normal VM switches to secure mode, all its pages residing
in normal memory, are moved into secure memory.
#. When an SVM requests to share a page with Hypervisor the Hypervisor
allocates a page and informs the Ultravisor.
#. When an SVM accesses a secure page that has been paged-out,
Ultravisor invokes the Hypervisor to locate the page. After
locating the page, the Hypervisor uses UV_PAGE_IN to make the
page available to Ultravisor.
UV_PAGE_INVAL
-------------
Invalidate the Ultravisor mapping of a page.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_PAGE_INVAL,
uint16_t lpid, /* the LPAR ID */
uint64_t guest_pa, /* destination guest-physical-address */
uint64_t order) /* page size order */
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success.
* U_PARAMETER if ``lpid`` is invalid.
* U_P2 if ``guest_pa`` is invalid (or corresponds to a secure
page mapping).
* U_P3 if the ``order`` is invalid.
* U_FUNCTION if functionality is not supported.
* U_BUSY if page cannot be currently invalidated.
Description
~~~~~~~~~~~
This ultracall informs Ultravisor that the page mapping in Hypervisor
corresponding to the given guest physical address has been invalidated
and that the Ultravisor should not access the page. If the specified
``guest_pa`` corresponds to a secure page, Ultravisor will ignore the
attempt to invalidate the page and return U_P2.
Use cases
~~~~~~~~~
#. When a shared page is unmapped from the QEMU's page table, possibly
because it is paged-out to disk, Ultravisor needs to know that the
page should not be accessed from its side too.
UV_WRITE_PATE
-------------
Validate and write the partition table entry (PATE) for a given
partition.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_WRITE_PATE,
uint32_t lpid, /* the LPAR ID */
uint64_t dw0 /* the first double word to write */
uint64_t dw1) /* the second double word to write */
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success.
* U_BUSY if PATE cannot be currently written to.
* U_FUNCTION if functionality is not supported.
* U_PARAMETER if ``lpid`` is invalid.
* U_P2 if ``dw0`` is invalid.
* U_P3 if the ``dw1`` address is invalid.
* U_PERMISSION if the Hypervisor is attempting to change the PATE
of a secure virtual machine or if called from a
context other than Hypervisor.
Description
~~~~~~~~~~~
Validate and write a LPID and its partition-table-entry for the given
LPID. If the LPID is already allocated and initialized, this call
results in changing the partition table entry.
Use cases
~~~~~~~~~
#. The Partition table resides in Secure memory and its entries,
called PATE (Partition Table Entries), point to the partition-
scoped page tables for the Hypervisor as well as each of the
virtual machines (both secure and normal). The Hypervisor
operates in partition 0 and its partition-scoped page tables
reside in normal memory.
#. This ultracall allows the Hypervisor to register the partition-
scoped and process-scoped page table entries for the Hypervisor
and other partitions (virtual machines) with the Ultravisor.
#. If the value of the PATE for an existing partition (VM) changes,
the TLB cache for the partition is flushed.
#. The Hypervisor is responsible for allocating LPID. The LPID and
its PATE entry are registered together. The Hypervisor manages
the PATE entries for a normal VM and can change the PATE entry
anytime. Ultravisor manages the PATE entries for an SVM and
Hypervisor is not allowed to modify them.
UV_RETURN
---------
Return control from the Hypervisor back to the Ultravisor after
processing an hypercall or interrupt that was forwarded (aka
*reflected*) to the Hypervisor.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_RETURN)
Return values
~~~~~~~~~~~~~
This call never returns to Hypervisor on success. It returns
U_INVALID if ultracall is not made from a Hypervisor context.
Description
~~~~~~~~~~~
When an SVM makes an hypercall or incurs some other exception, the
Ultravisor usually forwards (aka *reflects*) the exceptions to the
Hypervisor. After processing the exception, Hypervisor uses the
``UV_RETURN`` ultracall to return control back to the SVM.
The expected register state on entry to this ultracall is:
* Non-volatile registers are restored to their original values.
* If returning from an hypercall, register R0 contains the return
value (**unlike other ultracalls**) and, registers R4 through R12
contain any output values of the hypercall.
* R3 contains the ultracall number, i.e UV_RETURN.
* If returning with a synthesized interrupt, R2 contains the
synthesized interrupt number.
Use cases
~~~~~~~~~
#. Ultravisor relies on the Hypervisor to provide several services to
the SVM such as processing hypercall and other exceptions. After
processing the exception, Hypervisor uses UV_RETURN to return
control back to the Ultravisor.
#. Hypervisor has to use this ultracall to return control to the SVM.
UV_REGISTER_MEM_SLOT
--------------------
Register an SVM address-range with specified properties.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_REGISTER_MEM_SLOT,
uint64_t lpid, /* LPAR ID of the SVM */
uint64_t start_gpa, /* start guest physical address */
uint64_t size, /* size of address range in bytes */
uint64_t flags /* reserved for future expansion */
uint16_t slotid) /* slot identifier */
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success.
* U_PARAMETER if ``lpid`` is invalid.
* U_P2 if ``start_gpa`` is invalid.
* U_P3 if ``size`` is invalid.
* U_P4 if any bit in the ``flags`` is unrecognized.
* U_P5 if the ``slotid`` parameter is unsupported.
* U_PERMISSION if called from context other than Hypervisor.
* U_FUNCTION if functionality is not supported.
Description
~~~~~~~~~~~
Register a memory range for an SVM. The memory range starts at the
guest physical address ``start_gpa`` and is ``size`` bytes long.
Use cases
~~~~~~~~~
#. When a virtual machine goes secure, all the memory slots managed by
the Hypervisor move into secure memory. The Hypervisor iterates
through each of memory slots, and registers the slot with
Ultravisor. Hypervisor may discard some slots such as those used
for firmware (SLOF).
#. When new memory is hot-plugged, a new memory slot gets registered.
UV_UNREGISTER_MEM_SLOT
----------------------
Unregister an SVM address-range that was previously registered using
UV_REGISTER_MEM_SLOT.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_UNREGISTER_MEM_SLOT,
uint64_t lpid, /* LPAR ID of the SVM */
uint64_t slotid) /* reservation slotid */
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success.
* U_FUNCTION if functionality is not supported.
* U_PARAMETER if ``lpid`` is invalid.
* U_P2 if ``slotid`` is invalid.
* U_PERMISSION if called from context other than Hypervisor.
Description
~~~~~~~~~~~
Release the memory slot identified by ``slotid`` and free any
resources allocated towards the reservation.
Use cases
~~~~~~~~~
#. Memory hot-remove.
UV_SVM_TERMINATE
----------------
Terminate an SVM and release its resources.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_SVM_TERMINATE,
uint64_t lpid, /* LPAR ID of the SVM */)
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success.
* U_FUNCTION if functionality is not supported.
* U_PARAMETER if ``lpid`` is invalid.
* U_INVALID if VM is not secure.
* U_PERMISSION if not called from a Hypervisor context.
Description
~~~~~~~~~~~
Terminate an SVM and release all its resources.
Use cases
~~~~~~~~~
#. Called by Hypervisor when terminating an SVM.
Ultracalls used by SVM
======================
UV_SHARE_PAGE
-------------
Share a set of guest physical pages with the Hypervisor.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_SHARE_PAGE,
uint64_t gfn, /* guest page frame number */
uint64_t num) /* number of pages of size PAGE_SIZE */
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success.
* U_FUNCTION if functionality is not supported.
* U_INVALID if the VM is not secure.
* U_PARAMETER if ``gfn`` is invalid.
* U_P2 if ``num`` is invalid.
Description
~~~~~~~~~~~
Share the ``num`` pages starting at guest physical frame number ``gfn``
with the Hypervisor. Assume page size is PAGE_SIZE bytes. Zero the
pages before returning.
If the address is already backed by a secure page, unmap the page and
back it with an insecure page, with the help of the Hypervisor. If it
is not backed by any page yet, mark the PTE as insecure and back it
with an insecure page when the address is accessed. If it is already
backed by an insecure page, zero the page and return.
Use cases
~~~~~~~~~
#. The Hypervisor cannot access the SVM pages since they are backed by
secure pages. Hence an SVM must explicitly request Ultravisor for
pages it can share with Hypervisor.
#. Shared pages are needed to support virtio and Virtual Processor Area
(VPA) in SVMs.
UV_UNSHARE_PAGE
---------------
Restore a shared SVM page to its initial state.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_UNSHARE_PAGE,
uint64_t gfn, /* guest page frame number */
uint73 num) /* number of pages of size PAGE_SIZE*/
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success.
* U_FUNCTION if functionality is not supported.
* U_INVALID if VM is not secure.
* U_PARAMETER if ``gfn`` is invalid.
* U_P2 if ``num`` is invalid.
Description
~~~~~~~~~~~
Stop sharing ``num`` pages starting at ``gfn`` with the Hypervisor.
Assume that the page size is PAGE_SIZE. Zero the pages before
returning.
If the address is already backed by an insecure page, unmap the page
and back it with a secure page. Inform the Hypervisor to release
reference to its shared page. If the address is not backed by a page
yet, mark the PTE as secure and back it with a secure page when that
address is accessed. If it is already backed by an secure page zero
the page and return.
Use cases
~~~~~~~~~
#. The SVM may decide to unshare a page from the Hypervisor.
UV_UNSHARE_ALL_PAGES
--------------------
Unshare all pages the SVM has shared with Hypervisor.
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_UNSHARE_ALL_PAGES)
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success.
* U_FUNCTION if functionality is not supported.
* U_INVAL if VM is not secure.
Description
~~~~~~~~~~~
Unshare all shared pages from the Hypervisor. All unshared pages are
zeroed on return. Only pages explicitly shared by the SVM with the
Hypervisor (using UV_SHARE_PAGE ultracall) are unshared. Ultravisor
may internally share some pages with the Hypervisor without explicit
request from the SVM. These pages will not be unshared by this
ultracall.
Use cases
~~~~~~~~~
#. This call is needed when ``kexec`` is used to boot a different
kernel. It may also be needed during SVM reset.
UV_ESM
------
Secure the virtual machine (*enter secure mode*).
Syntax
~~~~~~
.. code-block:: c
uint64_t ultracall(const uint64_t UV_ESM,
uint64_t esm_blob_addr, /* location of the ESM blob */
unint64_t fdt) /* Flattened device tree */
Return values
~~~~~~~~~~~~~
One of the following values:
* U_SUCCESS on success (including if VM is already secure).
* U_FUNCTION if functionality is not supported.
* U_INVALID if VM is not secure.
* U_PARAMETER if ``esm_blob_addr`` is invalid.
* U_P2 if ``fdt`` is invalid.
* U_PERMISSION if any integrity checks fail.
* U_RETRY insufficient memory to create SVM.
* U_NO_KEY symmetric key unavailable.
Description
~~~~~~~~~~~
Secure the virtual machine. On successful completion, return
control to the virtual machine at the address specified in the
ESM blob.
Use cases
~~~~~~~~~
#. A normal virtual machine can choose to switch to a secure mode.
Hypervisor Calls API
####################
This document describes the Hypervisor calls (hypercalls) that are
needed to support the Ultravisor. Hypercalls are services provided by
the Hypervisor to virtual machines and Ultravisor.
Register usage for these hypercalls is identical to that of the other
hypercalls defined in the Power Architecture Platform Reference (PAPR)
document. i.e on input, register R3 identifies the specific service
that is being requested and registers R4 through R11 contain
additional parameters to the hypercall, if any. On output, register
R3 contains the return value and registers R4 through R9 contain any
other output values from the hypercall.
This document only covers hypercalls currently implemented/planned
for Ultravisor usage but others can be added here when it makes sense.
The full specification for all hypercalls/ultracalls will eventually
be made available in the public/OpenPower version of the PAPR
specification.
Hypervisor calls to support Ultravisor
======================================
Following are the set of hypercalls needed to support Ultravisor.
H_SVM_INIT_START
----------------
Begin the process of converting a normal virtual machine into an SVM.
Syntax
~~~~~~
.. code-block:: c
uint64_t hypercall(const uint64_t H_SVM_INIT_START)
Return values
~~~~~~~~~~~~~
One of the following values:
* H_SUCCESS on success.
* H_STATE if the VM is not in a position to switch to secure.
Description
~~~~~~~~~~~
Initiate the process of securing a virtual machine. This involves
coordinating with the Ultravisor, using ultracalls, to allocate
resources in the Ultravisor for the new SVM, transferring the VM's
pages from normal to secure memory etc. When the process is
completed, Ultravisor issues the H_SVM_INIT_DONE hypercall.
Use cases
~~~~~~~~~
#. Ultravisor uses this hypercall to inform Hypervisor that a VM
has initiated the process of switching to secure mode.
H_SVM_INIT_DONE
---------------
Complete the process of securing an SVM.
Syntax
~~~~~~
.. code-block:: c
uint64_t hypercall(const uint64_t H_SVM_INIT_DONE)
Return values
~~~~~~~~~~~~~
One of the following values:
* H_SUCCESS on success.
* H_UNSUPPORTED if called from the wrong context (e.g.
from an SVM or before an H_SVM_INIT_START
hypercall).
* H_STATE if the hypervisor could not successfully
transition the VM to Secure VM.
Description
~~~~~~~~~~~
Complete the process of securing a virtual machine. This call must
be made after a prior call to ``H_SVM_INIT_START`` hypercall.
Use cases
~~~~~~~~~
On successfully securing a virtual machine, the Ultravisor informs
Hypervisor about it. Hypervisor can use this call to finish setting
up its internal state for this virtual machine.
H_SVM_INIT_ABORT
----------------
Abort the process of securing an SVM.
Syntax
~~~~~~
.. code-block:: c
uint64_t hypercall(const uint64_t H_SVM_INIT_ABORT)
Return values
~~~~~~~~~~~~~
One of the following values:
* H_PARAMETER on successfully cleaning up the state,
Hypervisor will return this value to the
**guest**, to indicate that the underlying
UV_ESM ultracall failed.
* H_STATE if called after a VM has gone secure (i.e
H_SVM_INIT_DONE hypercall was successful).
* H_UNSUPPORTED if called from a wrong context (e.g. from a
normal VM).
Description
~~~~~~~~~~~
Abort the process of securing a virtual machine. This call must
be made after a prior call to ``H_SVM_INIT_START`` hypercall and
before a call to ``H_SVM_INIT_DONE``.
On entry into this hypercall the non-volatile GPRs and FPRs are
expected to contain the values they had at the time the VM issued
the UV_ESM ultracall. Further ``SRR0`` is expected to contain the
address of the instruction after the ``UV_ESM`` ultracall and ``SRR1``
the MSR value with which to return to the VM.
This hypercall will cleanup any partial state that was established for
the VM since the prior ``H_SVM_INIT_START`` hypercall, including paging
out pages that were paged-into secure memory, and issue the
``UV_SVM_TERMINATE`` ultracall to terminate the VM.
After the partial state is cleaned up, control returns to the VM
(**not Ultravisor**), at the address specified in ``SRR0`` with the
MSR values set to the value in ``SRR1``.
Use cases
~~~~~~~~~
If after a successful call to ``H_SVM_INIT_START``, the Ultravisor
encounters an error while securing a virtual machine, either due
to lack of resources or because the VM's security information could
not be validated, Ultravisor informs the Hypervisor about it.
Hypervisor should use this call to clean up any internal state for
this virtual machine and return to the VM.
H_SVM_PAGE_IN
-------------
Move the contents of a page from normal memory to secure memory.
Syntax
~~~~~~
.. code-block:: c
uint64_t hypercall(const uint64_t H_SVM_PAGE_IN,
uint64_t guest_pa, /* guest-physical-address */
uint64_t flags, /* flags */
uint64_t order) /* page size order */
Return values
~~~~~~~~~~~~~
One of the following values:
* H_SUCCESS on success.
* H_PARAMETER if ``guest_pa`` is invalid.
* H_P2 if ``flags`` is invalid.
* H_P3 if ``order`` of page is invalid.
Description
~~~~~~~~~~~
Retrieve the content of the page, belonging to the VM at the specified
guest physical address.
Only valid value(s) in ``flags`` are:
* H_PAGE_IN_SHARED which indicates that the page is to be shared
with the Ultravisor.
* H_PAGE_IN_NONSHARED indicates that the UV is not anymore
interested in the page. Applicable if the page is a shared page.
The ``order`` parameter must correspond to the configured page size.
Use cases
~~~~~~~~~
#. When a normal VM becomes a secure VM (using the UV_ESM ultracall),
the Ultravisor uses this hypercall to move contents of each page of
the VM from normal memory to secure memory.
#. Ultravisor uses this hypercall to ask Hypervisor to provide a page
in normal memory that can be shared between the SVM and Hypervisor.
#. Ultravisor uses this hypercall to page-in a paged-out page. This
can happen when the SVM touches a paged-out page.
#. If SVM wants to disable sharing of pages with Hypervisor, it can
inform Ultravisor to do so. Ultravisor will then use this hypercall
and inform Hypervisor that it has released access to the normal
page.
H_SVM_PAGE_OUT
---------------
Move the contents of the page to normal memory.
Syntax
~~~~~~
.. code-block:: c
uint64_t hypercall(const uint64_t H_SVM_PAGE_OUT,
uint64_t guest_pa, /* guest-physical-address */
uint64_t flags, /* flags (currently none) */
uint64_t order) /* page size order */
Return values
~~~~~~~~~~~~~
One of the following values:
* H_SUCCESS on success.
* H_PARAMETER if ``guest_pa`` is invalid.
* H_P2 if ``flags`` is invalid.
* H_P3 if ``order`` is invalid.
Description
~~~~~~~~~~~
Move the contents of the page identified by ``guest_pa`` to normal
memory.
Currently ``flags`` is unused and must be set to 0. The ``order``
parameter must correspond to the configured page size.
Use cases
~~~~~~~~~
#. If Ultravisor is running low on secure pages, it can move the
contents of some secure pages, into normal pages using this
hypercall. The content will be encrypted.
References
##########
- `Supporting Protected Computing on IBM Power Architecture <https://developer.ibm.com/articles/l-support-protected-computing/>`_
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Protected Execution Facility
1-10이 문서는 POWER9 Protected Execution Facility(PEF)의 hardware/software model과 Secure Virtual Machine(SVM)을 위한 Ultravisor 및 Hypervisor call API를 설명합니다.
PEF와 Ultravisor 소개
11-49PEF는 SVM을 가능하게 하는 POWER9 architecture 변경입니다. DD2.3 chip(`PVR=0x004e1203`) 이상이 PEF capable이며 새 ISA release에 PEF RFC02487 변경이 포함됩니다.
PEF를 enable하면 POWER architecture에 Hypervisor보다 높은 Ultravisor mode가 추가되고 Protected Execution Ultravisor firmware가 실행됩니다. Ultravisor mode는 가장 높은 privilege mode입니다.
원문의 privilege-state 표를 낮은 privilege에서 높은 privilege 순서로 재구성했습니다.
PEF는 Hypervisor, privileged user와 다른 VM으로부터 SVM을 보호합니다. SVM은 at-rest 상태에서도 보호되고 authorized machine에서만 실행할 수 있습니다.
모든 VM은 Hypervisor service를 사용합니다. Ultravisor는 SVM과 Hypervisor 사이 call을 filter하여 정보가 실수로 leak되지 않게 합니다. `H_RANDOM`을 제외한 모든 hypercall은 Hypervisor로 reflect됩니다. `H_RANDOM`은 Hypervisor가 SVM의 random value에 영향을 주지 못하도록 Ultravisor가 직접 처리합니다.
이를 지원하기 위해 CPU resource ownership을 재구성했습니다. 이전에 Hypervisor privileged였던 일부 resource는 이제 Ultravisor privileged입니다.
PEF hardware 변경
50-146새 MSR bit 41인 `MSR(S)`가 현재 process의 secure mode를 나타냅니다. `MSR(S)=1`이면 secure, `MSR(S)=0`이면 normal mode이며 이 bit는 Ultravisor만 set할 수 있습니다.
`HRFID`로 `MSR(S)`를 set할 수 없습니다. Hypervisor가 SVM으로 return하려면 ultracall을 사용해야 하며, return 대상 VM이 secure인지 판별할 수 있습니다.
새 Ultravisor-privileged register `SMFCTRL`에는 enable/disable bit `SMFCTRL(E)`가 있습니다. Process privilege는 이제 `MSR(S, HV, PR)` 세 bit로 결정되며 높은 privilege mode는 낮은 mode의 모든 resource에 접근할 수 있습니다.
`S=1`일 때의 MSR bit 조합과 privilege를 보존했습니다.
`S=0`일 때의 MSR bit 조합과 privilege를 보존했습니다.
Memory는 secure와 normal memory로 partition됩니다. Secure mode process만 secure memory에 접근할 수 있고 hardware가 non-secure access를 차단합니다. 따라서 Hypervisor는 ultracall로 Ultravisor에 요청하지 않고 SVM memory를 읽을 수 없으며, Ultravisor도 Hypervisor에는 encrypted SVM memory만 보여 줍니다.
I/O system은 secure memory를 직접 address할 수 없어 SVM은 virtual I/O만 사용할 수 있습니다. SVM이 먼저 요청하면 encryption으로 보호하지 않는 page를 Hypervisor와 share할 수 있습니다.
Secure mode의 모든 hypercall(`syscall lev=1`)과 interrupt는 Ultravisor로 전달됩니다.
- Processor configuration register(SCOM)
- Stop-state information
- `SMFCTRL(D)`가 set된 경우 debug register `CIABR`, `DAWR`, `DAWRX`
- `PTCR`와 secure memory의 partition-table entry
- `LDBAR`와 IMC(In-Memory Collection) non-architected register
- SVM paging과 Hypervisor memory sharing, VPA 및 virtual I/O
`SMFCTRL(D)`가 clear이면 debug register는 secure mode에서 작동하지 않습니다. Set되어 있으면 read/write에 Ultravisor call이 필요하며 그렇지 않으면 Hypervisor Emulation Assistance interrupt가 발생합니다. `PTCR`, `LDBAR`, IMC register의 금지된 write도 같은 interrupt를 일으킵니다.
SVM과 Ultravisor만 secure page를 직접 다루며 Hypervisor와 I/O는 controlled interface를 사용합니다.
Software와 microcode 동작
147-187IBM의 open-source tooling으로 normal VM에서 SVM을 만듭니다. 모든 SVM은 normal VM으로 시작하고 `UV_ESM`(Enter Secure Mode) ultracall로 전환합니다.
`UV_ESM` 시 Ultravisor는 VM을 secure memory로 copy하고 verification information을 decrypt한 뒤 SVM integrity를 검사합니다. 통과하면 secure mode로 control을 넘깁니다.
Verification information에는 SVM의 encrypted disk pass phrase가 포함되며 SVM이 요청하면 제공합니다. Ultravisor는 at-rest SVM disk encryption 자체를 담당하지 않습니다.
External interrupt에서는 Ultravisor가 SVM state를 저장하고 Hypervisor에 interrupt를 reflect합니다. Hypercall에서는 필요한 register 외에는 neutral state를 넣고 reflect합니다. `H_RANDOM`만 Ultravisor가 직접 처리합니다.
Virtual I/O는 bounce buffering이 필요합니다. Ultravisor는 SVM memory의 integrity와 secrecy를 동시에 제공하는 AES mode인 IAPM을 사용합니다.
Normal page와 secure page 사이 data 이동은 Hypervisor의 새 HMM plug-in이 Ultravisor와 조정합니다. Hypervisor와 SVM은 새 service를 ultracall로 이용합니다.
UV_ESM이 memory 이동, verification과 secure execution 진입을 조정합니다.
용어
188-214| Term | 정의 |
|---|---|
| Hypercall | Hypervisor service를 요청하는 special system call |
| Normal memory | Hypervisor가 접근할 수 있는 memory |
| Normal page | Normal memory가 backing하며 Hypervisor가 사용할 수 있는 page |
| Shared page | Normal memory가 backing하고 Hypervisor/QEMU와 SVM 양쪽에 mapping되는 page |
| Secure memory | Ultravisor와 SVM만 접근할 수 있는 memory |
| Secure page | Secure memory가 backing하고 Ultravisor와 SVM만 사용하는 page |
| SVM | Secure Virtual Machine |
| Ultracall | Ultravisor service를 요청하는 special system call |
Ultravisor call ABI
215-259Ultracall은 SVM과 paravirtualized KVM이 Ultravisor-privileged register 또는 memory region 같은 service를 요청하는 interface입니다.
원문 register 범위 표현은 input/output parameter에 `R4 through R12`를 사용하며, 아래 표에서는 이를 `R4-R12`로 함께 나타냅니다.
| Direction | Register | 의미 |
|---|---|---|
| Input service number | `R3` | 요청할 ultracall |
| Input parameters | `R4-R12` | 추가 argument |
| Return status | `R3` | Ultracall return value |
| Output values | `R4-R12` | 추가 결과 |
| `UV_RETURN` exception | `R0`, `R2`, `R3`, `R4-R12` | 별도 register 규칙 |
각 call은 상황에 맞는 error code를 반환합니다. 특정 code가 정의되지 않은 경우 PAPR처럼 문제를 일으킨 parameter 위치에 따라 `U_PARAMETER`, `U_P2`, `U_P3` 등을 사용합니다.
일부 ultracall은 Ultravisor와 Hypervisor 사이에서 page를 이동합니다. Secure memory에서 normal memory로 나오는 page는 dynamically generated key로 encrypt할 수 있고 다시 secure memory로 들어갈 때 같은 key로 decrypt할 수 있습니다. Key generation과 management는 별도 문서 범위입니다.
현재 구현되어 Hypervisor와 SVM이 사용하는 call만 다루며 필요하면 추가할 수 있습니다. 전체 hypercall/ultracall specification은 향후 public/OpenPower PAPR에 제공될 예정입니다.
PEF가 enable되지 않으면 ultracall은 Hypervisor로 redirect되며 Hypervisor가 처리하거나 실패시켜야 합니다.
Ultravisor가 secure page와 normal page 사이 encryption/decryption 경계를 관리합니다.
Hypervisor가 사용하는 ultracall
260-265다음 virtual-memory-management ultracall은 Hypervisor가 SVM을 관리할 때 사용합니다.
UV_PAGE_OUT
266-332Secure memory의 page content를 encrypt하여 normal memory로 이동합니다.
uint64_t ultracall(const uint64_t UV_PAGE_OUT,
uint16_t lpid, /* LPAR ID */
uint64_t dest_ra, /* real address of destination page */
uint64_t src_gpa, /* source guest-physical-address */
uint8_t flags, /* flags */
uint64_t order) /* page size order */
| Return value | 조건 |
|---|---|
| `U_SUCCESS` | 성공 |
| `U_PARAMETER` | `lpid`가 invalid |
| `U_P2` | `dest_ra`가 invalid |
| `U_P3` | `src_gpa`가 invalid |
| `U_P4` | `flags`에 알 수 없는 bit가 있음 |
| `U_P5` | `order`가 지원되지 않음 |
| `U_FUNCTION` / `U_BUSY` | 기능 미지원 / 현재 page-out 불가 |
Secure page content를 encrypt해 Hypervisor가 normal page에서 사용할 수 있게 합니다. 기본적으로 source page를 SVM partition-scoped page table에서 unmap하지만 `flags`에 `UV_SNAPSHOT`을 set하면 mapping 유지 hint를 줄 수 있습니다.
Source가 이미 shared page이면 아무 작업 없이 `U_SUCCESS`를 반환합니다.
- QEMU가 SVM address에 접근했지만 page frame이 QEMU address space에 없을 때 Hypervisor가 normal page를 allocate/map하고 encrypted content를 요청합니다.
- Ultravisor secure memory가 부족해 LRU page를 내보낼 때 `H_SVM_PAGE_OUT`으로 Hypervisor에 normal page를 요청한 뒤 `UV_PAGE_OUT`으로 encrypt/move합니다.
- Hypervisor가 SVM data에 접근할 때 accessible normal page로 옮기되 content는 encrypted 상태입니다.
Secure page를 encrypted normal page로 바꾸고 필요에 따라 SVM mapping을 유지합니다.
UV_PAGE_IN
333-399Normal memory의 page content를 secure memory로 이동합니다.
uint64_t ultracall(const uint64_t UV_PAGE_IN,
uint16_t lpid, /* the LPAR ID */
uint64_t src_ra, /* source real address of page */
uint64_t dest_gpa, /* destination guest physical address */
uint64_t flags, /* flags */
uint64_t order) /* page size order */
| Return value | 조건 |
|---|---|
| `U_SUCCESS` | 성공 |
| `U_BUSY` | 현재 page-in 불가 |
| `U_FUNCTION` | 기능 미지원 |
| `U_PARAMETER` | `lpid`가 invalid |
| `U_P2` | `src_ra`가 invalid |
| `U_P3` | `dest_gpa`가 invalid |
| `U_P4` | `flags`에 알 수 없는 bit가 있음 |
| `U_P5` | `order`가 지원되지 않음 |
`src_ra`의 normal page content를 secure memory로 옮기고 `dest_gpa`에 map합니다. `dest_gpa`가 shared address이면 SVM partition-scoped page table에 normal page를 map합니다. Shared가 아니면 대응 secure page로 copy하며 context에 따라 먼저 decrypt합니다.
- `CACHE_INHIBITED`
- `CACHE_ENABLED`
- `WRITE_PROTECTION`
Caller인 Hypervisor는 `UV_PAGE_IN` 전에 source page를 memory에 pin해야 합니다.
- Normal VM이 secure mode로 바뀔 때 모든 normal-memory page를 secure memory로 이동
- SVM이 Hypervisor와 page sharing을 요청할 때 Hypervisor가 normal page를 allocate하고 Ultravisor에 알림
- SVM이 paged-out secure page에 접근할 때 Hypervisor가 page를 찾아 `UV_PAGE_IN`으로 Ultravisor에 제공
Destination 공유 속성에 따라 mapping 또는 secure copy/decrypt 경로로 나뉩니다.
UV_PAGE_INVAL
400-444Page에 대한 Ultravisor mapping을 invalidate합니다.
uint64_t ultracall(const uint64_t UV_PAGE_INVAL,
uint16_t lpid, /* the LPAR ID */
uint64_t guest_pa, /* destination guest-physical-address */
uint64_t order) /* page size order */
| Return value | 조건 |
|---|---|
| `U_SUCCESS` | 성공 |
| `U_PARAMETER` | `lpid`가 invalid |
| `U_P2` | `guest_pa`가 invalid이거나 secure page mapping |
| `U_P3` | `order`가 invalid |
| `U_FUNCTION` | 기능 미지원 |
| `U_BUSY` | 현재 invalidate 불가 |
주어진 guest physical address에 대응하는 Hypervisor page mapping이 invalidate되었고 Ultravisor도 page에 접근하면 안 된다는 사실을 알립니다. `guest_pa`가 secure page이면 invalidate를 무시하고 `U_P2`를 반환합니다.
- Shared page가 disk page-out 등으로 QEMU page table에서 unmap될 때 Ultravisor 측 access도 중단
UV_WRITE_PATE
445-505주어진 partition의 partition table entry(PATE)를 validate하고 씁니다.
uint64_t ultracall(const uint64_t UV_WRITE_PATE,
uint32_t lpid, /* the LPAR ID */
uint64_t dw0 /* the first double word to write */
uint64_t dw1) /* the second double word to write */
| Return value | 조건 |
|---|---|
| `U_SUCCESS` | 성공 |
| `U_BUSY` | 현재 PATE를 쓸 수 없음 |
| `U_FUNCTION` | 기능 미지원 |
| `U_PARAMETER` | `lpid`가 invalid |
| `U_P2` | `dw0`가 invalid |
| `U_P3` | `dw1` address가 invalid |
| `U_PERMISSION` | Hypervisor가 SVM PATE 변경을 시도하거나 Hypervisor가 아닌 context에서 호출 |
LPID와 해당 PATE를 validate하여 기록합니다. LPID가 이미 allocate/initialize되어 있으면 기존 partition-table entry를 변경합니다.
- Secure memory의 partition table은 Hypervisor partition 0과 secure/normal VM의 partition-scoped page table을 가리킵니다. Hypervisor의 page table은 normal memory에 있습니다.
- Hypervisor가 자신과 다른 partition의 partition-scoped/process-scoped page-table entry를 Ultravisor에 등록합니다.
- 기존 VM의 PATE 값이 바뀌면 해당 partition TLB cache를 flush합니다.
- Hypervisor가 LPID를 allocate하고 normal VM PATE를 관리합니다. SVM PATE는 Ultravisor가 관리하며 Hypervisor가 수정할 수 없습니다.
UV_RETURN
506-554Reflect된 hypercall 또는 interrupt를 Hypervisor가 처리한 뒤 control을 Ultravisor로 돌려보냅니다.
uint64_t ultracall(const uint64_t UV_RETURN)
| Return value | 조건 |
|---|---|
| Success | Hypervisor로 돌아오지 않고 control을 Ultravisor/SVM으로 전달 |
| `U_INVALID` | Hypervisor context가 아닌 곳에서 호출 |
SVM hypercall이나 exception은 보통 Ultravisor가 Hypervisor에 reflect합니다. 처리가 끝나면 Hypervisor는 반드시 `UV_RETURN`으로 SVM에 돌아갑니다.
- Non-volatile register를 original value로 restore
- Hypercall return이면 다른 ultracall과 달리 `R0`에 return value, 원문 표현 `R4 through R12`(`R4-R12`)에 output value
- `R3`에는 ultracall number `UV_RETURN`
- Synthesized interrupt return이면 `R2`에 interrupt number
- Hypervisor가 SVM hypercall과 exception service를 처리한 뒤 Ultravisor로 control 반환
- Hypervisor가 SVM으로 return할 때 반드시 사용
Ultravisor가 민감하지 않은 state만 Hypervisor에 넘기고 처리 후 SVM context를 복원합니다.
UV_REGISTER_MEM_SLOT
555-605지정 property를 가진 SVM address range를 등록합니다.
uint64_t ultracall(const uint64_t UV_REGISTER_MEM_SLOT,
uint64_t lpid, /* LPAR ID of the SVM */
uint64_t start_gpa, /* start guest physical address */
uint64_t size, /* size of address range in bytes */
uint64_t flags /* reserved for future expansion */
uint16_t slotid) /* slot identifier */
| Return value | 조건 |
|---|---|
| `U_SUCCESS` | 성공 |
| `U_PARAMETER` | `lpid`가 invalid |
| `U_P2` | `start_gpa`가 invalid |
| `U_P3` | `size`가 invalid |
| `U_P4` | `flags`에 알 수 없는 bit가 있음 |
| `U_P5` | `slotid`가 지원되지 않음 |
| `U_PERMISSION` | Hypervisor가 아닌 context에서 호출 |
| `U_FUNCTION` | 기능 미지원 |
`start_gpa`에서 시작하고 `size` bytes인 SVM memory range를 `slotid`로 등록합니다.
- VM이 secure해질 때 Hypervisor가 관리하던 memory slot을 순회해 Ultravisor에 등록하며 SLOF firmware용 slot 등은 버릴 수 있음
- Memory hot-plug 시 새 memory slot 등록
UV_UNREGISTER_MEM_SLOT
606-643`UV_REGISTER_MEM_SLOT`으로 등록한 SVM address range를 해제합니다.
uint64_t ultracall(const uint64_t UV_UNREGISTER_MEM_SLOT,
uint64_t lpid, /* LPAR ID of the SVM */
uint64_t slotid) /* reservation slotid */
| Return value | 조건 |
|---|---|
| `U_SUCCESS` | 성공 |
| `U_FUNCTION` | 기능 미지원 |
| `U_PARAMETER` | `lpid`가 invalid |
| `U_P2` | `slotid`가 invalid |
| `U_PERMISSION` | Hypervisor가 아닌 context에서 호출 |
`slotid`로 memory slot을 release하고 reservation에 할당된 resource를 free합니다.
- Memory hot-remove
UV_SVM_TERMINATE
644-678SVM을 terminate하고 모든 resource를 release합니다.
uint64_t ultracall(const uint64_t UV_SVM_TERMINATE,
uint64_t lpid, /* LPAR ID of the SVM */)
| Return value | 조건 |
|---|---|
| `U_SUCCESS` | 성공 |
| `U_FUNCTION` | 기능 미지원 |
| `U_PARAMETER` | `lpid`가 invalid |
| `U_INVALID` | VM이 secure하지 않음 |
| `U_PERMISSION` | Hypervisor context가 아닌 곳에서 호출 |
Hypervisor가 SVM을 종료할 때 호출합니다.
SVM이 사용하는 ultracall
679-681다음 ultracall은 SVM이 Hypervisor와 page를 share/unshare하거나 secure mode에 진입할 때 사용합니다.
UV_ESM
813-852Normal virtual machine을 secure mode의 SVM으로 전환합니다.
uint64_t ultracall(const uint64_t UV_ESM,
uint64_t esm_blob_addr, /* location of the ESM blob */
unint64_t fdt) /* Flattened device tree */
| Return value | 조건 |
|---|---|
| `U_SUCCESS` | 성공 또는 VM이 이미 secure |
| `U_FUNCTION` | 기능 미지원 |
| `U_INVALID` | VM이 secure하지 않음 |
| `U_PARAMETER` | `esm_blob_addr`가 invalid |
| `U_P2` | `fdt`가 invalid |
| `U_PERMISSION` | Integrity check 실패 |
| `U_RETRY` | SVM 생성용 memory 부족 |
| `U_NO_KEY` | Symmetric key를 사용할 수 없음 |
VM을 secure하고 성공하면 ESM blob이 지정한 address에서 virtual machine으로 control을 반환합니다. Normal VM이 스스로 secure mode 전환을 선택할 때 사용합니다.
Syntax의 `unint64_t fdt` spelling은 원문을 그대로 보존했습니다.
Ultravisor 지원 Hypervisor call ABI
853-874Hypercall은 Hypervisor가 VM과 Ultravisor에 제공하는 service입니다. Register 사용은 PAPR hypercall과 같습니다.
Input에서 `R3`가 service를 식별하고 원문 표현 `R4 through R11`(`R4-R11`)이 추가 parameter입니다. Output에서 `R3`가 return value이고 `R4 through R9`(`R4-R9`)가 추가 output입니다.
현재 구현 또는 계획된 Ultravisor용 hypercall만 다루며 전체 specification은 향후 public/OpenPower PAPR에 포함될 예정입니다.
Ultravisor 지원 hypercall 목록
875-879다음 hypercall은 SVM secure 전환과 secure/normal page 이동을 Hypervisor가 지원하도록 합니다.
H_SVM_INIT_START
880-915Normal VM을 SVM으로 바꾸는 과정을 시작합니다.
uint64_t hypercall(const uint64_t H_SVM_INIT_START)
| Return value | 조건 |
|---|---|
| `H_SUCCESS` | 성공 |
| `H_STATE` | VM이 secure mode로 전환할 수 있는 상태가 아님 |
Ultravisor resource allocation과 VM page의 normal-to-secure 이동을 ultracall로 조정합니다. 완료되면 Ultravisor가 `H_SVM_INIT_DONE`을 호출합니다.
- Ultravisor가 VM의 secure-mode 전환 시작 사실을 Hypervisor에 알림
H_SVM_INIT_DONE
916-953SVM secure 전환 과정을 완료합니다.
uint64_t hypercall(const uint64_t H_SVM_INIT_DONE)
| Return value | 조건 |
|---|---|
| `H_SUCCESS` | 성공 |
| `H_UNSUPPORTED` | SVM에서 호출하거나 `H_SVM_INIT_START` 이전처럼 잘못된 context |
| `H_STATE` | Hypervisor가 VM을 SVM으로 전환하지 못함 |
반드시 앞선 `H_SVM_INIT_START` 뒤에 호출해야 합니다. VM securing에 성공한 Ultravisor가 Hypervisor에 알리면 Hypervisor는 해당 VM의 internal state 설정을 마칩니다.
H_SVM_INIT_ABORT
954-1013진행 중인 SVM secure 전환을 abort합니다.
uint64_t hypercall(const uint64_t H_SVM_INIT_ABORT)
| Return value | 조건 |
|---|---|
| `H_PARAMETER` | Cleanup 성공 후 underlying `UV_ESM` 실패를 알리기 위해 guest에 반환 |
| `H_STATE` | `H_SVM_INIT_DONE` 성공 뒤 호출 |
| `H_UNSUPPORTED` | Normal VM 등 잘못된 context에서 호출 |
`H_SVM_INIT_START` 뒤, `H_SVM_INIT_DONE` 전에만 호출해야 합니다. Entry에서 non-volatile GPR/FPR은 VM이 `UV_ESM`을 호출한 시점 값을 가져야 합니다. `SRR0`는 `UV_ESM` 다음 instruction address, `SRR1`은 VM으로 return할 MSR 값입니다.
이 call은 secure memory로 page-in된 page를 다시 page-out하는 등 partial state를 cleanup하고 `UV_SVM_TERMINATE`로 VM을 terminate합니다. Cleanup 뒤 `SRR0` address와 `SRR1` MSR로 Ultravisor가 아니라 VM에 직접 return합니다.
Resource 부족이나 security information validation 실패로 securing 중 오류가 나면 Ultravisor가 Hypervisor에 알리고, Hypervisor가 internal VM state를 cleanup한 뒤 VM으로 돌아갈 때 사용합니다.
START 뒤 성공하면 DONE, 실패하면 ABORT cleanup과 VM return으로 갈라집니다.
H_SVM_PAGE_IN
1014-1072Normal memory의 page content를 secure memory 쪽으로 제공합니다.
uint64_t hypercall(const uint64_t H_SVM_PAGE_IN,
uint64_t guest_pa, /* guest-physical-address */
uint64_t flags, /* flags */
uint64_t order) /* page size order */
| Return value | 조건 |
|---|---|
| `H_SUCCESS` | 성공 |
| `H_PARAMETER` | `guest_pa`가 invalid |
| `H_P2` | `flags`가 invalid |
| `H_P3` | Page `order`가 invalid |
지정 `guest_pa`에 속한 VM page content를 retrieve합니다. `order`는 configured page size와 일치해야 합니다.
- `H_PAGE_IN_SHARED`: Ultravisor와 share할 page
- `H_PAGE_IN_NONSHARED`: shared page에서 Ultravisor가 더 이상 관심 없음을 표시
- `UV_ESM`으로 normal VM이 SVM이 될 때 각 page를 normal에서 secure memory로 이동
- Ultravisor가 SVM-Hypervisor shared normal page를 Hypervisor에 요청
- SVM이 paged-out page를 touch했을 때 page-in
- SVM이 sharing을 disable하면 Ultravisor가 normal-page access release를 Hypervisor에 알림
H_SVM_PAGE_OUT
1073-1113지정 page content를 normal memory로 이동합니다.
uint64_t hypercall(const uint64_t H_SVM_PAGE_OUT,
uint64_t guest_pa, /* guest-physical-address */
uint64_t flags, /* flags (currently none) */
uint64_t order) /* page size order */
| Return value | 조건 |
|---|---|
| `H_SUCCESS` | 성공 |
| `H_PARAMETER` | `guest_pa`가 invalid |
| `H_P2` | `flags`가 invalid |
| `H_P3` | `order`가 invalid |
`guest_pa`가 식별하는 page content를 normal memory로 옮깁니다. `flags`는 현재 사용하지 않으므로 0이어야 하며 `order`는 configured page size와 일치해야 합니다.
- Ultravisor의 secure page가 부족할 때 일부 secure page content를 encrypted normal page로 이동
References
1114-1117IBM Power Architecture의 protected computing 배경과 구현 개요는 다음 자료를 참고합니다.
요약과 해설
ultravisor.rst:1-1117PEF는 Hypervisor보다 높은 Ultravisor privilege로 SVM memory와 execution state를 보호합니다. Hypervisor는 encrypted page와 sanitized reflected call만 다루며, 12개 ultracall과 5개 hypercall이 secure 전환, paging, sharing, PATE 및 exception return을 조정합니다.