18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * This is a module to test the HMM (Heterogeneous Memory Management) API 48c2ecf20Sopenharmony_ci * of the kernel. It allows a userspace program to expose its entire address 58c2ecf20Sopenharmony_ci * space through the HMM test module device file. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#ifndef _LIB_TEST_HMM_UAPI_H 88c2ecf20Sopenharmony_ci#define _LIB_TEST_HMM_UAPI_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/types.h> 118c2ecf20Sopenharmony_ci#include <linux/ioctl.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Structure to pass to the HMM test driver to mimic a device accessing 158c2ecf20Sopenharmony_ci * system memory and ZONE_DEVICE private memory through device page tables. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * @addr: (in) user address the device will read/write 188c2ecf20Sopenharmony_ci * @ptr: (in) user address where device data is copied to/from 198c2ecf20Sopenharmony_ci * @npages: (in) number of pages to read/write 208c2ecf20Sopenharmony_ci * @cpages: (out) number of pages copied 218c2ecf20Sopenharmony_ci * @faults: (out) number of device page faults seen 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_cistruct hmm_dmirror_cmd { 248c2ecf20Sopenharmony_ci __u64 addr; 258c2ecf20Sopenharmony_ci __u64 ptr; 268c2ecf20Sopenharmony_ci __u64 npages; 278c2ecf20Sopenharmony_ci __u64 cpages; 288c2ecf20Sopenharmony_ci __u64 faults; 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* Expose the address space of the calling process through hmm device file */ 328c2ecf20Sopenharmony_ci#define HMM_DMIRROR_READ _IOWR('H', 0x00, struct hmm_dmirror_cmd) 338c2ecf20Sopenharmony_ci#define HMM_DMIRROR_WRITE _IOWR('H', 0x01, struct hmm_dmirror_cmd) 348c2ecf20Sopenharmony_ci#define HMM_DMIRROR_MIGRATE _IOWR('H', 0x02, struct hmm_dmirror_cmd) 358c2ecf20Sopenharmony_ci#define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x03, struct hmm_dmirror_cmd) 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* 388c2ecf20Sopenharmony_ci * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT. 398c2ecf20Sopenharmony_ci * HMM_DMIRROR_PROT_ERROR: no valid mirror PTE for this page 408c2ecf20Sopenharmony_ci * HMM_DMIRROR_PROT_NONE: unpopulated PTE or PTE with no access 418c2ecf20Sopenharmony_ci * HMM_DMIRROR_PROT_READ: read-only PTE 428c2ecf20Sopenharmony_ci * HMM_DMIRROR_PROT_WRITE: read/write PTE 438c2ecf20Sopenharmony_ci * HMM_DMIRROR_PROT_PMD: PMD sized page is fully mapped by same permissions 448c2ecf20Sopenharmony_ci * HMM_DMIRROR_PROT_PUD: PUD sized page is fully mapped by same permissions 458c2ecf20Sopenharmony_ci * HMM_DMIRROR_PROT_ZERO: special read-only zero page 468c2ecf20Sopenharmony_ci * HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL: Migrated device private page on the 478c2ecf20Sopenharmony_ci * device the ioctl() is made 488c2ecf20Sopenharmony_ci * HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE: Migrated device private page on some 498c2ecf20Sopenharmony_ci * other device 508c2ecf20Sopenharmony_ci */ 518c2ecf20Sopenharmony_cienum { 528c2ecf20Sopenharmony_ci HMM_DMIRROR_PROT_ERROR = 0xFF, 538c2ecf20Sopenharmony_ci HMM_DMIRROR_PROT_NONE = 0x00, 548c2ecf20Sopenharmony_ci HMM_DMIRROR_PROT_READ = 0x01, 558c2ecf20Sopenharmony_ci HMM_DMIRROR_PROT_WRITE = 0x02, 568c2ecf20Sopenharmony_ci HMM_DMIRROR_PROT_PMD = 0x04, 578c2ecf20Sopenharmony_ci HMM_DMIRROR_PROT_PUD = 0x08, 588c2ecf20Sopenharmony_ci HMM_DMIRROR_PROT_ZERO = 0x10, 598c2ecf20Sopenharmony_ci HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL = 0x20, 608c2ecf20Sopenharmony_ci HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30, 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#endif /* _LIB_TEST_HMM_UAPI_H */ 64