test_hmm_uapi.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * This is a module to test the HMM (Heterogeneous Memory Management) API
  4. * of the kernel. It allows a userspace program to expose its entire address
  5. * space through the HMM test module device file.
  6. */
  7. #ifndef _LIB_TEST_HMM_UAPI_H
  8. #define _LIB_TEST_HMM_UAPI_H
  9. #include <linux/types.h>
  10. #include <linux/ioctl.h>
  11. /*
  12. * Structure to pass to the HMM test driver to mimic a device accessing
  13. * system memory and ZONE_DEVICE private memory through device page tables.
  14. *
  15. * @addr: (in) user address the device will read/write
  16. * @ptr: (in) user address where device data is copied to/from
  17. * @npages: (in) number of pages to read/write
  18. * @cpages: (out) number of pages copied
  19. * @faults: (out) number of device page faults seen
  20. */
  21. struct hmm_dmirror_cmd {
  22. __u64 addr;
  23. __u64 ptr;
  24. __u64 npages;
  25. __u64 cpages;
  26. __u64 faults;
  27. };
  28. /* Expose the address space of the calling process through hmm device file */
  29. #define HMM_DMIRROR_READ _IOWR('H', 0x00, struct hmm_dmirror_cmd)
  30. #define HMM_DMIRROR_WRITE _IOWR('H', 0x01, struct hmm_dmirror_cmd)
  31. #define HMM_DMIRROR_MIGRATE _IOWR('H', 0x02, struct hmm_dmirror_cmd)
  32. #define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x03, struct hmm_dmirror_cmd)
  33. /*
  34. * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT.
  35. * HMM_DMIRROR_PROT_ERROR: no valid mirror PTE for this page
  36. * HMM_DMIRROR_PROT_NONE: unpopulated PTE or PTE with no access
  37. * HMM_DMIRROR_PROT_READ: read-only PTE
  38. * HMM_DMIRROR_PROT_WRITE: read/write PTE
  39. * HMM_DMIRROR_PROT_PMD: PMD sized page is fully mapped by same permissions
  40. * HMM_DMIRROR_PROT_PUD: PUD sized page is fully mapped by same permissions
  41. * HMM_DMIRROR_PROT_ZERO: special read-only zero page
  42. * HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL: Migrated device private page on the
  43. * device the ioctl() is made
  44. * HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE: Migrated device private page on some
  45. * other device
  46. */
  47. enum {
  48. HMM_DMIRROR_PROT_ERROR = 0xFF,
  49. HMM_DMIRROR_PROT_NONE = 0x00,
  50. HMM_DMIRROR_PROT_READ = 0x01,
  51. HMM_DMIRROR_PROT_WRITE = 0x02,
  52. HMM_DMIRROR_PROT_PMD = 0x04,
  53. HMM_DMIRROR_PROT_PUD = 0x08,
  54. HMM_DMIRROR_PROT_ZERO = 0x10,
  55. HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL = 0x20,
  56. HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30,
  57. };
  58. #endif /* _LIB_TEST_HMM_UAPI_H */