hypercalls.rst 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===============================================
  3. KVM/arm64-specific hypercalls exposed to guests
  4. ===============================================
  5. This file documents the KVM/arm64-specific hypercalls which may be
  6. exposed by KVM/arm64 to guest operating systems. These hypercalls are
  7. issued using the HVC instruction according to version 1.1 of the Arm SMC
  8. Calling Convention (DEN0028/C):
  9. https://developer.arm.com/docs/den0028/c
  10. All KVM/arm64-specific hypercalls are allocated within the "Vendor
  11. Specific Hypervisor Service Call" range with a UID of
  12. ``28b46fb6-2ec5-11e9-a9ca-4b564d003a74``. This UID should be queried by the
  13. guest using the standard "Call UID" function for the service range in
  14. order to determine that the KVM/arm64-specific hypercalls are available.
  15. ``ARM_SMCCC_KVM_FUNC_FEATURES``
  16. ---------------------------------------------
  17. Provides a discovery mechanism for other KVM/arm64 hypercalls.
  18. +---------------------+-------------------------------------------------------------+
  19. | Presence: | Mandatory for the KVM/arm64 UID |
  20. +---------------------+-------------------------------------------------------------+
  21. | Calling convention: | HVC32 |
  22. +---------------------+----------+--------------------------------------------------+
  23. | Function ID: | (uint32) | 0x86000000 |
  24. +---------------------+----------+--------------------------------------------------+
  25. | Arguments: | None |
  26. +---------------------+----------+----+---------------------------------------------+
  27. | Return Values: | (uint32) | R0 | Bitmap of available function numbers 0-31 |
  28. | +----------+----+---------------------------------------------+
  29. | | (uint32) | R1 | Bitmap of available function numbers 32-63 |
  30. | +----------+----+---------------------------------------------+
  31. | | (uint32) | R2 | Bitmap of available function numbers 64-95 |
  32. | +----------+----+---------------------------------------------+
  33. | | (uint32) | R3 | Bitmap of available function numbers 96-127 |
  34. +---------------------+----------+----+---------------------------------------------+
  35. ``ARM_SMCCC_KVM_FUNC_PTP``
  36. ----------------------------------------
  37. See ptp_kvm.rst
  38. ``ARM_SMCCC_KVM_FUNC_HYP_MEMINFO``
  39. ----------------------------------
  40. Query the memory protection parameters for a protected virtual machine.
  41. +---------------------+-------------------------------------------------------------+
  42. | Presence: | Optional; protected guests only. |
  43. +---------------------+-------------------------------------------------------------+
  44. | Calling convention: | HVC64 |
  45. +---------------------+----------+--------------------------------------------------+
  46. | Function ID: | (uint32) | 0xC6000002 |
  47. +---------------------+----------+----+---------------------------------------------+
  48. | Arguments: | (uint64) | R1 | Reserved / Must be zero |
  49. | +----------+----+---------------------------------------------+
  50. | | (uint64) | R2 | Reserved / Must be zero |
  51. | +----------+----+---------------------------------------------+
  52. | | (uint64) | R3 | Reserved / Must be zero |
  53. +---------------------+----------+----+---------------------------------------------+
  54. | Return Values: | (int64) | R0 | ``INVALID_PARAMETER (-3)`` on error, else |
  55. | | | | memory protection granule in bytes |
  56. +---------------------+----------+----+---------------------------------------------+
  57. ``ARM_SMCCC_KVM_FUNC_MEM_SHARE``
  58. --------------------------------
  59. Share a region of memory with the KVM host, granting it read, write and execute
  60. permissions. The size of the region is equal to the memory protection granule
  61. advertised by ``ARM_SMCCC_KVM_FUNC_HYP_MEMINFO``.
  62. +---------------------+-------------------------------------------------------------+
  63. | Presence: | Optional; protected guests only. |
  64. +---------------------+-------------------------------------------------------------+
  65. | Calling convention: | HVC64 |
  66. +---------------------+----------+--------------------------------------------------+
  67. | Function ID: | (uint32) | 0xC6000003 |
  68. +---------------------+----------+----+---------------------------------------------+
  69. | Arguments: | (uint64) | R1 | Base IPA of memory region to share |
  70. | +----------+----+---------------------------------------------+
  71. | | (uint64) | R2 | Reserved / Must be zero |
  72. | +----------+----+---------------------------------------------+
  73. | | (uint64) | R3 | Reserved / Must be zero |
  74. +---------------------+----------+----+---------------------------------------------+
  75. | Return Values: | (int64) | R0 | ``SUCCESS (0)`` |
  76. | | | +---------------------------------------------+
  77. | | | | ``INVALID_PARAMETER (-3)`` |
  78. +---------------------+----------+----+---------------------------------------------+
  79. ``ARM_SMCCC_KVM_FUNC_MEM_UNSHARE``
  80. ----------------------------------
  81. Revoke access permission from the KVM host to a memory region previously shared
  82. with ``ARM_SMCCC_KVM_FUNC_MEM_SHARE``. The size of the region is equal to the
  83. memory protection granule advertised by ``ARM_SMCCC_KVM_FUNC_HYP_MEMINFO``.
  84. +---------------------+-------------------------------------------------------------+
  85. | Presence: | Optional; protected guests only. |
  86. +---------------------+-------------------------------------------------------------+
  87. | Calling convention: | HVC64 |
  88. +---------------------+----------+--------------------------------------------------+
  89. | Function ID: | (uint32) | 0xC6000004 |
  90. +---------------------+----------+----+---------------------------------------------+
  91. | Arguments: | (uint64) | R1 | Base IPA of memory region to unshare |
  92. | +----------+----+---------------------------------------------+
  93. | | (uint64) | R2 | Reserved / Must be zero |
  94. | +----------+----+---------------------------------------------+
  95. | | (uint64) | R3 | Reserved / Must be zero |
  96. +---------------------+----------+----+---------------------------------------------+
  97. | Return Values: | (int64) | R0 | ``SUCCESS (0)`` |
  98. | | | +---------------------------------------------+
  99. | | | | ``INVALID_PARAMETER (-3)`` |
  100. +---------------------+----------+----+---------------------------------------------+
  101. ``ARM_SMCCC_KVM_FUNC_MEM_RELINQUISH``
  102. --------------------------------------
  103. Cooperatively relinquish ownership of a memory region. The size of the
  104. region is equal to the memory protection granule advertised by
  105. ``ARM_SMCCC_KVM_FUNC_HYP_MEMINFO``. If this hypercall is advertised
  106. then it is mandatory to call it before freeing memory via, for
  107. example, virtio balloon. If the caller is a protected VM, it is
  108. guaranteed that the memory region will be completely cleared before
  109. becoming visible to another VM.
  110. +---------------------+-------------------------------------------------------------+
  111. | Presence: | Optional. |
  112. +---------------------+-------------------------------------------------------------+
  113. | Calling convention: | HVC64 |
  114. +---------------------+----------+--------------------------------------------------+
  115. | Function ID: | (uint32) | 0xC6000009 |
  116. +---------------------+----------+----+---------------------------------------------+
  117. | Arguments: | (uint64) | R1 | Base IPA of memory region to relinquish |
  118. | +----------+----+---------------------------------------------+
  119. | | (uint64) | R2 | Reserved / Must be zero |
  120. | +----------+----+---------------------------------------------+
  121. | | (uint64) | R3 | Reserved / Must be zero |
  122. +---------------------+----------+----+---------------------------------------------+
  123. | Return Values: | (int64) | R0 | ``SUCCESS (0)`` |
  124. | | | +---------------------------------------------+
  125. | | | | ``INVALID_PARAMETER (-3)`` |
  126. +---------------------+----------+----+---------------------------------------------+
  127. ``ARM_SMCCC_KVM_FUNC_MMIO_GUARD_*``
  128. -----------------------------------
  129. See mmio-guard.rst