s390-diag.rst 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. .. SPDX-License-Identifier: GPL-2.0
  2. =============================
  3. The s390 DIAGNOSE call on KVM
  4. =============================
  5. KVM on s390 supports the DIAGNOSE call for making hypercalls, both for
  6. native hypercalls and for selected hypercalls found on other s390
  7. hypervisors.
  8. Note that bits are numbered as by the usual s390 convention (most significant
  9. bit on the left).
  10. General remarks
  11. ---------------
  12. DIAGNOSE calls by the guest cause a mandatory intercept. This implies
  13. all supported DIAGNOSE calls need to be handled by either KVM or its
  14. userspace.
  15. All DIAGNOSE calls supported by KVM use the RS-a format::
  16. --------------------------------------
  17. | '83' | R1 | R3 | B2 | D2 |
  18. --------------------------------------
  19. 0 8 12 16 20 31
  20. The second-operand address (obtained by the base/displacement calculation)
  21. is not used to address data. Instead, bits 48-63 of this address specify
  22. the function code, and bits 0-47 are ignored.
  23. The supported DIAGNOSE function codes vary by the userspace used. For
  24. DIAGNOSE function codes not specific to KVM, please refer to the
  25. documentation for the s390 hypervisors defining them.
  26. DIAGNOSE function code 'X'500' - KVM virtio functions
  27. -----------------------------------------------------
  28. If the function code specifies 0x500, various virtio-related functions
  29. are performed.
  30. General register 1 contains the virtio subfunction code. Supported
  31. virtio subfunctions depend on KVM's userspace. Generally, userspace
  32. provides either s390-virtio (subcodes 0-2) or virtio-ccw (subcode 3).
  33. Upon completion of the DIAGNOSE instruction, general register 2 contains
  34. the function's return code, which is either a return code or a subcode
  35. specific value.
  36. Subcode 0 - s390-virtio notification and early console printk
  37. Handled by userspace.
  38. Subcode 1 - s390-virtio reset
  39. Handled by userspace.
  40. Subcode 2 - s390-virtio set status
  41. Handled by userspace.
  42. Subcode 3 - virtio-ccw notification
  43. Handled by either userspace or KVM (ioeventfd case).
  44. General register 2 contains a subchannel-identification word denoting
  45. the subchannel of the virtio-ccw proxy device to be notified.
  46. General register 3 contains the number of the virtqueue to be notified.
  47. General register 4 contains a 64bit identifier for KVM usage (the
  48. kvm_io_bus cookie). If general register 4 does not contain a valid
  49. identifier, it is ignored.
  50. After completion of the DIAGNOSE call, general register 2 may contain
  51. a 64bit identifier (in the kvm_io_bus cookie case), or a negative
  52. error value, if an internal error occurred.
  53. See also the virtio standard for a discussion of this hypercall.
  54. DIAGNOSE function code 'X'501 - KVM breakpoint
  55. ----------------------------------------------
  56. If the function code specifies 0x501, breakpoint functions may be performed.
  57. This function code is handled by userspace.
  58. This diagnose function code has no subfunctions and uses no parameters.
  59. DIAGNOSE function code 'X'9C - Voluntary Time Slice Yield
  60. ---------------------------------------------------------
  61. General register 1 contains the target CPU address.
  62. In a guest of a hypervisor like LPAR, KVM or z/VM using shared host CPUs,
  63. DIAGNOSE with function code 0x9c may improve system performance by
  64. yielding the host CPU on which the guest CPU is running to be assigned
  65. to another guest CPU, preferably the logical CPU containing the specified
  66. target CPU.
  67. DIAG 'X'9C forwarding
  68. +++++++++++++++++++++
  69. The guest may send a DIAGNOSE 0x9c in order to yield to a certain
  70. other vcpu. An example is a Linux guest that tries to yield to the vcpu
  71. that is currently holding a spinlock, but not running.
  72. However, on the host the real cpu backing the vcpu may itself not be
  73. running.
  74. Forwarding the DIAGNOSE 0x9c initially sent by the guest to yield to
  75. the backing cpu will hopefully cause that cpu, and thus subsequently
  76. the guest's vcpu, to be scheduled.
  77. diag9c_forwarding_hz
  78. KVM kernel parameter allowing to specify the maximum number of DIAGNOSE
  79. 0x9c forwarding per second in the purpose of avoiding a DIAGNOSE 0x9c
  80. forwarding storm.
  81. A value of 0 turns the forwarding off.