ultravisor.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Ultravisor definitions
  4. *
  5. * Copyright 2019, IBM Corporation.
  6. *
  7. */
  8. #ifndef _ASM_POWERPC_ULTRAVISOR_H
  9. #define _ASM_POWERPC_ULTRAVISOR_H
  10. #include <asm/asm-prototypes.h>
  11. #include <asm/ultravisor-api.h>
  12. #include <asm/firmware.h>
  13. int early_init_dt_scan_ultravisor(unsigned long node, const char *uname,
  14. int depth, void *data);
  15. /*
  16. * In ultravisor enabled systems, PTCR becomes ultravisor privileged only for
  17. * writing and an attempt to write to it will cause a Hypervisor Emulation
  18. * Assistance interrupt.
  19. */
  20. static inline void set_ptcr_when_no_uv(u64 val)
  21. {
  22. if (!firmware_has_feature(FW_FEATURE_ULTRAVISOR))
  23. mtspr(SPRN_PTCR, val);
  24. }
  25. static inline int uv_register_pate(u64 lpid, u64 dw0, u64 dw1)
  26. {
  27. return ucall_norets(UV_WRITE_PATE, lpid, dw0, dw1);
  28. }
  29. static inline int uv_share_page(u64 pfn, u64 npages)
  30. {
  31. return ucall_norets(UV_SHARE_PAGE, pfn, npages);
  32. }
  33. static inline int uv_unshare_page(u64 pfn, u64 npages)
  34. {
  35. return ucall_norets(UV_UNSHARE_PAGE, pfn, npages);
  36. }
  37. static inline int uv_unshare_all_pages(void)
  38. {
  39. return ucall_norets(UV_UNSHARE_ALL_PAGES);
  40. }
  41. static inline int uv_page_in(u64 lpid, u64 src_ra, u64 dst_gpa, u64 flags,
  42. u64 page_shift)
  43. {
  44. return ucall_norets(UV_PAGE_IN, lpid, src_ra, dst_gpa, flags,
  45. page_shift);
  46. }
  47. static inline int uv_page_out(u64 lpid, u64 dst_ra, u64 src_gpa, u64 flags,
  48. u64 page_shift)
  49. {
  50. return ucall_norets(UV_PAGE_OUT, lpid, dst_ra, src_gpa, flags,
  51. page_shift);
  52. }
  53. static inline int uv_register_mem_slot(u64 lpid, u64 start_gpa, u64 size,
  54. u64 flags, u64 slotid)
  55. {
  56. return ucall_norets(UV_REGISTER_MEM_SLOT, lpid, start_gpa,
  57. size, flags, slotid);
  58. }
  59. static inline int uv_unregister_mem_slot(u64 lpid, u64 slotid)
  60. {
  61. return ucall_norets(UV_UNREGISTER_MEM_SLOT, lpid, slotid);
  62. }
  63. static inline int uv_page_inval(u64 lpid, u64 gpa, u64 page_shift)
  64. {
  65. return ucall_norets(UV_PAGE_INVAL, lpid, gpa, page_shift);
  66. }
  67. static inline int uv_svm_terminate(u64 lpid)
  68. {
  69. return ucall_norets(UV_SVM_TERMINATE, lpid);
  70. }
  71. #endif /* _ASM_POWERPC_ULTRAVISOR_H */