brintos

brintos / linux-shallow public Read only

0
0
Text · 5.3 KiB · 8e41a3b Raw
117 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3=========================================4s390 (IBM Z) Ultravisor and Protected VMs5=========================================6 7Summary8-------9Protected virtual machines (PVM) are KVM VMs that do not allow KVM to10access VM state like guest memory or guest registers. Instead, the11PVMs are mostly managed by a new entity called Ultravisor (UV). The UV12provides an API that can be used by PVMs and KVM to request management13actions.14 15Each guest starts in non-protected mode and then may make a request to16transition into protected mode. On transition, KVM registers the guest17and its VCPUs with the Ultravisor and prepares everything for running18it.19 20The Ultravisor will secure and decrypt the guest's boot memory21(i.e. kernel/initrd). It will safeguard state changes like VCPU22starts/stops and injected interrupts while the guest is running.23 24As access to the guest's state, such as the SIE state description, is25normally needed to be able to run a VM, some changes have been made in26the behavior of the SIE instruction. A new format 4 state description27has been introduced, where some fields have different meanings for a28PVM. SIE exits are minimized as much as possible to improve speed and29reduce exposed guest state.30 31 32Interrupt injection33-------------------34Interrupt injection is safeguarded by the Ultravisor. As KVM doesn't35have access to the VCPUs' lowcores, injection is handled via the36format 4 state description.37 38Machine check, external, IO and restart interruptions each can be39injected on SIE entry via a bit in the interrupt injection control40field (offset 0x54). If the guest cpu is not enabled for the interrupt41at the time of injection, a validity interception is recognized. The42format 4 state description contains fields in the interception data43block where data associated with the interrupt can be transported.44 45Program and Service Call exceptions have another layer of46safeguarding; they can only be injected for instructions that have47been intercepted into KVM. The exceptions need to be a valid outcome48of an instruction emulation by KVM, e.g. we can never inject a49addressing exception as they are reported by SIE since KVM has no50access to the guest memory.51 52 53Mask notification interceptions54-------------------------------55KVM cannot intercept lctl(g) and lpsw(e) anymore in order to be56notified when a PVM enables a certain class of interrupt.  As a57replacement, two new interception codes have been introduced: One58indicating that the contents of CRs 0, 6, or 14 have been changed,59indicating different interruption subclasses; and one indicating that60PSW bit 13 has been changed, indicating that a machine check61intervention was requested and those are now enabled.62 63Instruction emulation64---------------------65With the format 4 state description for PVMs, the SIE instruction already66interprets more instructions than it does with format 2. It is not able67to interpret every instruction, but needs to hand some tasks to KVM;68therefore, the SIE and the ultravisor safeguard emulation inputs and outputs.69 70The control structures associated with SIE provide the Secure71Instruction Data Area (SIDA), the Interception Parameters (IP) and the72Secure Interception General Register Save Area.  Guest GRs and most of73the instruction data, such as I/O data structures, are filtered.74Instruction data is copied to and from the SIDA when needed.  Guest75GRs are put into / retrieved from the Secure Interception General76Register Save Area.77 78Only GR values needed to emulate an instruction will be copied into this79save area and the real register numbers will be hidden.80 81The Interception Parameters state description field still contains82the bytes of the instruction text, but with pre-set register values83instead of the actual ones. I.e. each instruction always uses the same84instruction text, in order not to leak guest instruction text.85This also implies that the register content that a guest had in r<n>86may be in r<m> from the hypervisor's point of view.87 88The Secure Instruction Data Area contains instruction storage89data. Instruction data, i.e. data being referenced by an instruction90like the SCCB for sclp, is moved via the SIDA. When an instruction is91intercepted, the SIE will only allow data and program interrupts for92this instruction to be moved to the guest via the two data areas93discussed before. Other data is either ignored or results in validity94interceptions.95 96 97Instruction emulation interceptions98-----------------------------------99There are two types of SIE secure instruction intercepts: the normal100and the notification type. Normal secure instruction intercepts will101make the guest pending for instruction completion of the intercepted102instruction type, i.e. on SIE entry it is attempted to complete103emulation of the instruction with the data provided by KVM. That might104be a program exception or instruction completion.105 106The notification type intercepts inform KVM about guest environment107changes due to guest instruction interpretation. Such an interception108is recognized, for example, for the store prefix instruction to provide109the new lowcore location. On SIE reentry, any KVM data in the data areas110is ignored and execution continues as if the guest instruction had111completed. For that reason KVM is not allowed to inject a program112interrupt.113 114Links115-----116`KVM Forum 2019 presentation <https://static.sched.com/hosted_files/kvmforum2019/3b/ibm_protected_vms_s390x.pdf>`_117