mem-buf-ids.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2021-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef MEM_BUF_IDS_H
  7. #define MEM_BUF_IDS_H
  8. #include <linux/cdev.h>
  9. #include <linux/gunyah/gh_common.h>
  10. #define MEM_BUF_API_HYP_ASSIGN BIT(0)
  11. #define MEM_BUF_API_GUNYAH BIT(1)
  12. /*
  13. * @vmid - id assigned by hypervisor to uniquely identify a VM
  14. * @allowed_api - Some vms may use a different hypervisor interface.
  15. */
  16. struct mem_buf_vm {
  17. const char *name;
  18. u16 vmid;
  19. u32 allowed_api;
  20. struct cdev cdev;
  21. struct device dev;
  22. };
  23. extern int current_vmid;
  24. int mem_buf_vm_init(struct device *dev);
  25. void mem_buf_vm_exit(void);
  26. bool mem_buf_vm_uses_hyp_assign(void);
  27. /*
  28. * Returns a negative number for invalid arguments, otherwise a positive value
  29. * if gunyah APIs are required.
  30. */
  31. int mem_buf_vm_uses_gunyah(int *vmids, unsigned int nr_acl_entries);
  32. /* @Return: A negative number on failure, or vmid on success */
  33. int mem_buf_fd_to_vmid(int fd);
  34. #endif