s390-pv.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. .. SPDX-License-Identifier: GPL-2.0
  2. =========================================
  3. s390 (IBM Z) Ultravisor and Protected VMs
  4. =========================================
  5. Summary
  6. -------
  7. Protected virtual machines (PVM) are KVM VMs that do not allow KVM to
  8. access VM state like guest memory or guest registers. Instead, the
  9. PVMs are mostly managed by a new entity called Ultravisor (UV). The UV
  10. provides an API that can be used by PVMs and KVM to request management
  11. actions.
  12. Each guest starts in non-protected mode and then may make a request to
  13. transition into protected mode. On transition, KVM registers the guest
  14. and its VCPUs with the Ultravisor and prepares everything for running
  15. it.
  16. The Ultravisor will secure and decrypt the guest's boot memory
  17. (i.e. kernel/initrd). It will safeguard state changes like VCPU
  18. starts/stops and injected interrupts while the guest is running.
  19. As access to the guest's state, such as the SIE state description, is
  20. normally needed to be able to run a VM, some changes have been made in
  21. the behavior of the SIE instruction. A new format 4 state description
  22. has been introduced, where some fields have different meanings for a
  23. PVM. SIE exits are minimized as much as possible to improve speed and
  24. reduce exposed guest state.
  25. Interrupt injection
  26. -------------------
  27. Interrupt injection is safeguarded by the Ultravisor. As KVM doesn't
  28. have access to the VCPUs' lowcores, injection is handled via the
  29. format 4 state description.
  30. Machine check, external, IO and restart interruptions each can be
  31. injected on SIE entry via a bit in the interrupt injection control
  32. field (offset 0x54). If the guest cpu is not enabled for the interrupt
  33. at the time of injection, a validity interception is recognized. The
  34. format 4 state description contains fields in the interception data
  35. block where data associated with the interrupt can be transported.
  36. Program and Service Call exceptions have another layer of
  37. safeguarding; they can only be injected for instructions that have
  38. been intercepted into KVM. The exceptions need to be a valid outcome
  39. of an instruction emulation by KVM, e.g. we can never inject a
  40. addressing exception as they are reported by SIE since KVM has no
  41. access to the guest memory.
  42. Mask notification interceptions
  43. -------------------------------
  44. KVM cannot intercept lctl(g) and lpsw(e) anymore in order to be
  45. notified when a PVM enables a certain class of interrupt. As a
  46. replacement, two new interception codes have been introduced: One
  47. indicating that the contents of CRs 0, 6, or 14 have been changed,
  48. indicating different interruption subclasses; and one indicating that
  49. PSW bit 13 has been changed, indicating that a machine check
  50. intervention was requested and those are now enabled.
  51. Instruction emulation
  52. ---------------------
  53. With the format 4 state description for PVMs, the SIE instruction already
  54. interprets more instructions than it does with format 2. It is not able
  55. to interpret every instruction, but needs to hand some tasks to KVM;
  56. therefore, the SIE and the ultravisor safeguard emulation inputs and outputs.
  57. The control structures associated with SIE provide the Secure
  58. Instruction Data Area (SIDA), the Interception Parameters (IP) and the
  59. Secure Interception General Register Save Area. Guest GRs and most of
  60. the instruction data, such as I/O data structures, are filtered.
  61. Instruction data is copied to and from the SIDA when needed. Guest
  62. GRs are put into / retrieved from the Secure Interception General
  63. Register Save Area.
  64. Only GR values needed to emulate an instruction will be copied into this
  65. save area and the real register numbers will be hidden.
  66. The Interception Parameters state description field still contains
  67. the bytes of the instruction text, but with pre-set register values
  68. instead of the actual ones. I.e. each instruction always uses the same
  69. instruction text, in order not to leak guest instruction text.
  70. This also implies that the register content that a guest had in r<n>
  71. may be in r<m> from the hypervisor's point of view.
  72. The Secure Instruction Data Area contains instruction storage
  73. data. Instruction data, i.e. data being referenced by an instruction
  74. like the SCCB for sclp, is moved via the SIDA. When an instruction is
  75. intercepted, the SIE will only allow data and program interrupts for
  76. this instruction to be moved to the guest via the two data areas
  77. discussed before. Other data is either ignored or results in validity
  78. interceptions.
  79. Instruction emulation interceptions
  80. -----------------------------------
  81. There are two types of SIE secure instruction intercepts: the normal
  82. and the notification type. Normal secure instruction intercepts will
  83. make the guest pending for instruction completion of the intercepted
  84. instruction type, i.e. on SIE entry it is attempted to complete
  85. emulation of the instruction with the data provided by KVM. That might
  86. be a program exception or instruction completion.
  87. The notification type intercepts inform KVM about guest environment
  88. changes due to guest instruction interpretation. Such an interception
  89. is recognized, for example, for the store prefix instruction to provide
  90. the new lowcore location. On SIE reentry, any KVM data in the data areas
  91. is ignored and execution continues as if the guest instruction had
  92. completed. For that reason KVM is not allowed to inject a program
  93. interrupt.
  94. Links
  95. -----
  96. `KVM Forum 2019 presentation <https://static.sched.com/hosted_files/kvmforum2019/3b/ibm_protected_vms_s390x.pdf>`_