Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * This is a module to test the HMM (Heterogeneous Memory Management) API
0004  * of the kernel. It allows a userspace program to expose its entire address
0005  * space through the HMM test module device file.
0006  */
0007 #ifndef _LIB_TEST_HMM_UAPI_H
0008 #define _LIB_TEST_HMM_UAPI_H
0009 
0010 #include <linux/types.h>
0011 #include <linux/ioctl.h>
0012 
0013 /*
0014  * Structure to pass to the HMM test driver to mimic a device accessing
0015  * system memory and ZONE_DEVICE private memory through device page tables.
0016  *
0017  * @addr: (in) user address the device will read/write
0018  * @ptr: (in) user address where device data is copied to/from
0019  * @npages: (in) number of pages to read/write
0020  * @cpages: (out) number of pages copied
0021  * @faults: (out) number of device page faults seen
0022  */
0023 struct hmm_dmirror_cmd {
0024     __u64       addr;
0025     __u64       ptr;
0026     __u64       npages;
0027     __u64       cpages;
0028     __u64       faults;
0029 };
0030 
0031 /* Expose the address space of the calling process through hmm device file */
0032 #define HMM_DMIRROR_READ        _IOWR('H', 0x00, struct hmm_dmirror_cmd)
0033 #define HMM_DMIRROR_WRITE       _IOWR('H', 0x01, struct hmm_dmirror_cmd)
0034 #define HMM_DMIRROR_MIGRATE_TO_DEV  _IOWR('H', 0x02, struct hmm_dmirror_cmd)
0035 #define HMM_DMIRROR_MIGRATE_TO_SYS  _IOWR('H', 0x03, struct hmm_dmirror_cmd)
0036 #define HMM_DMIRROR_SNAPSHOT        _IOWR('H', 0x04, struct hmm_dmirror_cmd)
0037 #define HMM_DMIRROR_EXCLUSIVE       _IOWR('H', 0x05, struct hmm_dmirror_cmd)
0038 #define HMM_DMIRROR_CHECK_EXCLUSIVE _IOWR('H', 0x06, struct hmm_dmirror_cmd)
0039 
0040 /*
0041  * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT.
0042  * HMM_DMIRROR_PROT_ERROR: no valid mirror PTE for this page
0043  * HMM_DMIRROR_PROT_NONE: unpopulated PTE or PTE with no access
0044  * HMM_DMIRROR_PROT_READ: read-only PTE
0045  * HMM_DMIRROR_PROT_WRITE: read/write PTE
0046  * HMM_DMIRROR_PROT_PMD: PMD sized page is fully mapped by same permissions
0047  * HMM_DMIRROR_PROT_PUD: PUD sized page is fully mapped by same permissions
0048  * HMM_DMIRROR_PROT_ZERO: special read-only zero page
0049  * HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL: Migrated device private page on the
0050  *                  device the ioctl() is made
0051  * HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE: Migrated device private page on some
0052  *                  other device
0053  * HMM_DMIRROR_PROT_DEV_COHERENT: Migrate device coherent page on the device
0054  *                the ioctl() is made
0055  */
0056 enum {
0057     HMM_DMIRROR_PROT_ERROR          = 0xFF,
0058     HMM_DMIRROR_PROT_NONE           = 0x00,
0059     HMM_DMIRROR_PROT_READ           = 0x01,
0060     HMM_DMIRROR_PROT_WRITE          = 0x02,
0061     HMM_DMIRROR_PROT_PMD            = 0x04,
0062     HMM_DMIRROR_PROT_PUD            = 0x08,
0063     HMM_DMIRROR_PROT_ZERO           = 0x10,
0064     HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL  = 0x20,
0065     HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30,
0066     HMM_DMIRROR_PROT_DEV_COHERENT_LOCAL = 0x40,
0067     HMM_DMIRROR_PROT_DEV_COHERENT_REMOTE    = 0x50,
0068 };
0069 
0070 enum {
0071     /* 0 is reserved to catch uninitialized type fields */
0072     HMM_DMIRROR_MEMORY_DEVICE_PRIVATE = 1,
0073     HMM_DMIRROR_MEMORY_DEVICE_COHERENT,
0074 };
0075 
0076 #endif /* _LIB_TEST_HMM_UAPI_H */