|
|
b971b8 |
From 026160bc76bab26772c2a80bd50ae55119e3b60b Mon Sep 17 00:00:00 2001
|
|
|
b971b8 |
Message-Id: <026160bc76bab26772c2a80bd50ae55119e3b60b@dist-git>
|
|
|
b971b8 |
From: Viktor Mihajlovski <mihajlov@linux.ibm.com>
|
|
|
b971b8 |
Date: Wed, 24 Jun 2020 13:16:23 +0200
|
|
|
b971b8 |
Subject: [PATCH] docs: Describe protected virtualization guest setup
|
|
|
b971b8 |
MIME-Version: 1.0
|
|
|
b971b8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
b971b8 |
Content-Transfer-Encoding: 8bit
|
|
|
b971b8 |
|
|
|
b971b8 |
Protected virtualization/IBM Secure Execution for Linux protects
|
|
|
b971b8 |
guest memory and state from the host.
|
|
|
b971b8 |
|
|
|
b971b8 |
Add some basic information about technology and a brief guide
|
|
|
b971b8 |
on setting up secure guests with libvirt.
|
|
|
b971b8 |
|
|
|
b971b8 |
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.ibm.com>
|
|
|
b971b8 |
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
b971b8 |
Reviewed-by: Paulo de Rezende Pinatti <ppinatti@linux.ibm.com>
|
|
|
b971b8 |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
|
b971b8 |
(cherry picked from commit f0d0cd6179709461b026f24569a688065e90d766)
|
|
|
b971b8 |
|
|
|
b971b8 |
https://bugzilla.redhat.com/show_bug.cgi?id=1848997
|
|
|
b971b8 |
https://bugzilla.redhat.com/show_bug.cgi?id=1850351
|
|
|
b971b8 |
|
|
|
b971b8 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
b971b8 |
Message-Id: <cf598d01d242bb56e64e14bfc32cece69341d949.1592996194.git.jdenemar@redhat.com>
|
|
|
b971b8 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
b971b8 |
---
|
|
|
b971b8 |
docs/kbase.html.in | 3 +
|
|
|
b971b8 |
docs/kbase/s390_protected_virt.rst | 189 +++++++++++++++++++++++++++++
|
|
|
b971b8 |
2 files changed, 192 insertions(+)
|
|
|
b971b8 |
create mode 100644 docs/kbase/s390_protected_virt.rst
|
|
|
b971b8 |
|
|
|
b971b8 |
diff --git a/docs/kbase.html.in b/docs/kbase.html.in
|
|
|
b971b8 |
index f2975960f6..05773db16d 100644
|
|
|
b971b8 |
--- a/docs/kbase.html.in
|
|
|
b971b8 |
+++ b/docs/kbase.html.in
|
|
|
b971b8 |
@@ -14,6 +14,9 @@
|
|
|
b971b8 |
Secure usage
|
|
|
b971b8 |
Secure usage of the libvirt APIs
|
|
|
b971b8 |
|
|
|
b971b8 |
+ Protected virtualization on s390
|
|
|
b971b8 |
+ Running secure s390 guests with IBM Secure Execution
|
|
|
b971b8 |
+
|
|
|
b971b8 |
Launch security
|
|
|
b971b8 |
Securely launching VMs with AMD SEV
|
|
|
b971b8 |
|
|
|
b971b8 |
diff --git a/docs/kbase/s390_protected_virt.rst b/docs/kbase/s390_protected_virt.rst
|
|
|
b971b8 |
new file mode 100644
|
|
|
b971b8 |
index 0000000000..f38d16d743
|
|
|
b971b8 |
--- /dev/null
|
|
|
b971b8 |
+++ b/docs/kbase/s390_protected_virt.rst
|
|
|
b971b8 |
@@ -0,0 +1,189 @@
|
|
|
b971b8 |
+================================
|
|
|
b971b8 |
+Protected Virtualization on s390
|
|
|
b971b8 |
+================================
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+.. contents::
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Overview
|
|
|
b971b8 |
+========
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Protected virtualization, also known as IBM Secure Execution is a
|
|
|
b971b8 |
+hardware-based privacy protection technology for s390x (IBM Z).
|
|
|
b971b8 |
+It allows to execute virtual machines such that the host system
|
|
|
b971b8 |
+has no access to a VM's state and memory contents.
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Unlike other similar technologies, the memory of a running guest
|
|
|
b971b8 |
+is not encrypted but protected by hardware access controls, which
|
|
|
b971b8 |
+may only be manipulated by trusted system firmware, called
|
|
|
b971b8 |
+ultravisor.
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+For the cases where the host needs access to guest memory (e.g. for
|
|
|
b971b8 |
+paging), it can request pages to be exported to it. The exported page
|
|
|
b971b8 |
+will be encrypted with a unique key for the running guest by the
|
|
|
b971b8 |
+ultravisor. The ultravisor also computes an integrity value for
|
|
|
b971b8 |
+the page, and stores it in a special table, together with the page
|
|
|
b971b8 |
+index and a counter. This way it can verify the integrity of
|
|
|
b971b8 |
+the page content upon re-import into the guest.
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+In other cases it may be necessary for a guest to grant the host access
|
|
|
b971b8 |
+to dedicated memory regions (e.g. for I/O). The guest can request
|
|
|
b971b8 |
+that the ultravisor removes the memory protection from individual
|
|
|
b971b8 |
+pages, so that they can be shared with the host. Likewise, the
|
|
|
b971b8 |
+guest can undo the sharing.
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+A secure guest will initially start in a regular non-protected VM.
|
|
|
b971b8 |
+The start-up is controlled by a small bootstrap program loaded
|
|
|
b971b8 |
+into memory together with encrypted operating system components and
|
|
|
b971b8 |
+a control structure (the PV header).
|
|
|
b971b8 |
+The operating system components (e.g. Linux kernel, initial RAM
|
|
|
b971b8 |
+file system, kernel parameters) are encrypted and integrity
|
|
|
b971b8 |
+protected. The component encryption keys and integrity values are
|
|
|
b971b8 |
+stored in the PV header.
|
|
|
b971b8 |
+The PV header is wrapped with a public key belonging to a specific
|
|
|
b971b8 |
+system (in fact it can be wrapped with multiple such keys). The
|
|
|
b971b8 |
+matching private key is only accessible by trusted hardware and
|
|
|
b971b8 |
+firmware in that specific system.
|
|
|
b971b8 |
+Consequently, such a secure guest boot image can only be run on the
|
|
|
b971b8 |
+systems it has been prepared for. Its contents can't be decrypted
|
|
|
b971b8 |
+without access to the private key and it can't be modified as
|
|
|
b971b8 |
+it is integrity protected.
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Host Requirements
|
|
|
b971b8 |
+=================
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+IBM Secure Execution for Linux has some hardware and firmware
|
|
|
b971b8 |
+requirements. The system hardware must be an IBM z15 (or newer),
|
|
|
b971b8 |
+or an IBM LinuxONE III (or newer).
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+It is also necessary that the IBM Secure Execution feature is
|
|
|
b971b8 |
+enabled for that system. With libvirt >= 6.5.0 you can run
|
|
|
b971b8 |
+``libvirt-host--validate`` or otherwise check for facility '158', e.g.
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+::
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+ $ grep facilities /proc/cpuinfo | grep 158
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+The kernel must include the protected virtualization support
|
|
|
b971b8 |
+which can be verified by checking for the presence of directory
|
|
|
b971b8 |
+``/sys/firmware/uv``. It will only be present when both the
|
|
|
b971b8 |
+hardware and the kernel support are available.
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Finally, the host operating system must donate some memory to
|
|
|
b971b8 |
+the ultravisor needed to store memory security information.
|
|
|
b971b8 |
+This is achieved by specifying the following kernel command
|
|
|
b971b8 |
+line parameter to the host boot configuration
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+::
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+ prot_virt=1
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Guest Requirements
|
|
|
b971b8 |
+==================
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Guest Boot
|
|
|
b971b8 |
+----------
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+To start a guest in protected virtualization secure mode, the
|
|
|
b971b8 |
+boot image must have been prepared first with the program
|
|
|
b971b8 |
+``genprotimg`` using the correct public key for this host.
|
|
|
b971b8 |
+``genprotimg`` is part of the package ``s390-tools``, or
|
|
|
b971b8 |
+``s390-utils``, depending on the Linux distribution being used.
|
|
|
b971b8 |
+It can also be found at
|
|
|
b971b8 |
+`<https://github.com/ibm-s390-tools/s390-tools/tree/master/genprotimg>`_
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+The guests have to be configured to use the host CPU model, which
|
|
|
b971b8 |
+must contain the ``unpack`` facility indicating ultravisor guest support.
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+With the following command it's possible to check whether the host
|
|
|
b971b8 |
+CPU model satisfies the requirement
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+::
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+ $ virsh domcapabilities | grep unpack
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+which should return
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+::
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+ <feature policy='require' name='unpack'/>
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Note that on hosts with libvirt < 6.5.0 if the check fails despite
|
|
|
b971b8 |
+the host system actually supporting protected virtualization guests,
|
|
|
b971b8 |
+this can be caused by a stale libvirt capabilities cache.
|
|
|
b971b8 |
+To recover, run the following commands
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+::
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+ $ systemctl stop libvirtd
|
|
|
b971b8 |
+ $ rm /var/cache/libvirt/qemu/capabilities/*.xml
|
|
|
b971b8 |
+ $ systemctl start libvirtd
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Guest I/O
|
|
|
b971b8 |
+---------
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Protected virtualization guests support I/O using virtio devices.
|
|
|
b971b8 |
+As the virtio data structures of secure guests are not accessible
|
|
|
b971b8 |
+by the host, it is necessary to use shared memory ('bounce buffers').
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+To enable virtio devices to use shared buffers, it is necessary
|
|
|
b971b8 |
+to configure them with platform_iommu enabled. This can done by adding
|
|
|
b971b8 |
+``iommu='on'`` to the driver element of a virtio device definition in the
|
|
|
b971b8 |
+guest's XML, e.g.
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+::
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+ <interface type='network'>
|
|
|
b971b8 |
+ <source network='default'/>
|
|
|
b971b8 |
+ <model type='virtio'/>
|
|
|
b971b8 |
+ <driver name='vhost' iommu='on'/>
|
|
|
b971b8 |
+ </interface>
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+It is mandatory to define all virtio bus devices in this way to
|
|
|
b971b8 |
+prevent the host from attempting to access protected memory.
|
|
|
b971b8 |
+Ballooning will not work and is fenced by QEMU. It should be
|
|
|
b971b8 |
+disabled by specifying
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+::
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+ <memballoon model='none'/>
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Finally, the guest Linux must be instructed to allocate I/O
|
|
|
b971b8 |
+buffers using memory shared between host and guest using SWIOTLB.
|
|
|
b971b8 |
+This is done by adding ``swiotlb=nnn`` to the guest's kernel command
|
|
|
b971b8 |
+line string, where ``nnn`` stands for the number of statically
|
|
|
b971b8 |
+allocated 2K entries. A commonly used value for swiotlb is 262144.
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Example guest definition
|
|
|
b971b8 |
+========================
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+Minimal domain XML for a protected virtualization guest, essentially
|
|
|
b971b8 |
+it's mostly about the ``iommu`` property
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+::
|
|
|
b971b8 |
+
|
|
|
b971b8 |
+ <domain type='kvm'>
|
|
|
b971b8 |
+ <name>protected</name>
|
|
|
b971b8 |
+ <memory unit='KiB'>2048000</memory>
|
|
|
b971b8 |
+ <currentMemory unit='KiB'>2048000</currentMemory>
|
|
|
b971b8 |
+ <vcpu>1</vcpu>
|
|
|
b971b8 |
+ <os>
|
|
|
b971b8 |
+ <type arch='s390x'>hvm</type>
|
|
|
b971b8 |
+ </os>
|
|
|
b971b8 |
+ <cpu mode='host-model'/>
|
|
|
b971b8 |
+ <devices>
|
|
|
b971b8 |
+ <disk type='file' device='disk'>
|
|
|
b971b8 |
+ <driver name='qemu' type='qcow2' cache='none' io='native' iommu='on'>
|
|
|
b971b8 |
+ <source file='/var/lib/libvirt/images/protected.qcow2'/>
|
|
|
b971b8 |
+ <target dev='vda' bus='virtio'/>
|
|
|
b971b8 |
+ </disk>
|
|
|
b971b8 |
+ <interface type='network'>
|
|
|
b971b8 |
+ <driver iommu='on'/>
|
|
|
b971b8 |
+ <source network='default'/>
|
|
|
b971b8 |
+ <model type='virtio'/>
|
|
|
b971b8 |
+ </interface>
|
|
|
b971b8 |
+ <console type='pty'/>
|
|
|
b971b8 |
+ <memballoon model='none'/>
|
|
|
b971b8 |
+ </devices>
|
|
|
b971b8 |
+ </domain>
|
|
|
b971b8 |
--
|
|
|
b971b8 |
2.27.0
|
|
|
b971b8 |
|