mmio-guard.rst 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ==============
  3. KVM MMIO guard
  4. ==============
  5. KVM implements device emulation by handling translation faults to any
  6. IPA range that is not contained in a memory slot. Such a translation
  7. fault is in most cases passed on to userspace (or in rare cases to the
  8. host kernel) with the address, size and possibly data of the access
  9. for emulation.
  10. Should the guest exit with an address that is not one that corresponds
  11. to an emulatable device, userspace may take measures that are not the
  12. most graceful as far as the guest is concerned (such as terminating it
  13. or delivering a fatal exception).
  14. There is also an element of trust: by forwarding the request to
  15. userspace, the kernel assumes that the guest trusts userspace to do
  16. the right thing.
  17. The KVM MMIO guard offers a way to mitigate this last point: a guest
  18. can request that only certain regions of the IPA space are valid as
  19. MMIO. Only these regions will be handled as an MMIO, and any other
  20. will result in an exception being delivered to the guest.
  21. This relies on a set of hypercalls defined in the KVM-specific range,
  22. using the HVC64 calling convention.
  23. * ARM_SMCCC_KVM_FUNC_MMIO_GUARD_INFO
  24. ============== ======== ================================
  25. Function ID: (uint32) 0xC6000005
  26. Arguments: r1-r3 Reserved / Must be zero
  27. Return Values: (int64) NOT_SUPPORTED(-1) on error, or
  28. (uint64) Protection Granule (PG) size in
  29. bytes (r0)
  30. ============== ======== ================================
  31. * ARM_SMCCC_KVM_FUNC_MMIO_GUARD_ENROLL
  32. ============== ======== ==============================
  33. Function ID: (uint32) 0xC6000006
  34. Arguments: none
  35. Return Values: (int64) NOT_SUPPORTED(-1) on error, or
  36. RET_SUCCESS(0) (r0)
  37. ============== ======== ==============================
  38. * ARM_SMCCC_KVM_FUNC_MMIO_GUARD_MAP
  39. ============== ======== ====================================
  40. Function ID: (uint32) 0xC6000007
  41. Arguments: (uint64) The base of the PG-sized IPA range
  42. that is allowed to be accessed as
  43. MMIO. Must be aligned to the PG size
  44. (r1)
  45. (uint64) Index in the MAIR_EL1 register
  46. providing the memory attribute that
  47. is used by the guest (r2)
  48. Return Values: (int64) NOT_SUPPORTED(-1) on error, or
  49. RET_SUCCESS(0) (r0)
  50. ============== ======== ====================================
  51. * ARM_SMCCC_KVM_FUNC_MMIO_GUARD_UNMAP
  52. ============== ======== ======================================
  53. Function ID: (uint32) 0xC6000008
  54. Arguments: (uint64) PG-sized IPA range aligned to the PG
  55. size which has been previously mapped.
  56. Must be aligned to the PG size and
  57. have been previously mapped (r1)
  58. Return Values: (int64) NOT_SUPPORTED(-1) on error, or
  59. RET_SUCCESS(0) (r0)
  60. ============== ======== ======================================