gh_private.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef _GH_PRIVATE_H
  6. #define _GH_PRIVATE_H
  7. #include <linux/gunyah/gh_rm_drv.h>
  8. #include <linux/gunyah/gh_vm.h>
  9. #include <linux/refcount.h>
  10. #include <linux/gunyah_deprecated.h>
  11. #include <linux/wait.h>
  12. #define GH_EVENT_CREATE_VM 0
  13. #define GH_EVENT_DESTROY_VM 1
  14. #define GH_MAX_VCPUS 8
  15. struct gh_vcpu {
  16. u32 vcpu_id;
  17. struct gh_vm *vm;
  18. };
  19. struct gh_ext_reg {
  20. u32 ext_label;
  21. phys_addr_t ext_phys;
  22. ssize_t ext_size;
  23. gh_memparcel_handle_t ext_mem_handle;
  24. };
  25. struct gh_vm {
  26. bool is_secure_vm; /* is true for Qcom authenticated secure VMs */
  27. bool vm_run_once;
  28. bool keep_running;
  29. u32 created_vcpus;
  30. u32 allowed_vcpus;
  31. gh_vmid_t vmid;
  32. struct gh_vcpu *vcpus[GH_MAX_VCPUS];
  33. char fw_name[GH_VM_FW_NAME_MAX];
  34. struct notifier_block rm_nb;
  35. struct gh_vm_status status;
  36. wait_queue_head_t vm_status_wait;
  37. int exit_type;
  38. refcount_t users_count;
  39. gh_memparcel_handle_t mem_handle;
  40. struct gh_ext_reg *ext_region;
  41. bool ext_region_supported;
  42. struct mutex vm_lock;
  43. };
  44. /*
  45. * memory lending/donating and reclaiming APIs
  46. */
  47. int gh_provide_mem(struct gh_vm *vm, phys_addr_t phys,
  48. ssize_t size, bool is_system_vm);
  49. int gh_reclaim_mem(struct gh_vm *vm, phys_addr_t phys,
  50. ssize_t size, bool is_system_vm);
  51. long gh_vm_configure(u16 auth_mech, u64 image_offset,
  52. u64 image_size, u64 dtb_offset, u64 dtb_size,
  53. u32 pas_id, const char *fw_name, struct gh_vm *vm);
  54. void gh_uevent_notify_change(unsigned int type, struct gh_vm *vm);
  55. #endif /* _GH_PRIVATE_H */