|
XenevaOS
|
#include <xe_drm.h>
Public Attributes | |
| __u64 | extensions |
| __u32 | vm_id |
| __u32 | num_mem_ranges |
| __u64 | start |
| __u64 | range |
| __u64 | sizeof_mem_range_attr |
| __u64 | vector_of_mem_attr |
| __u64 | reserved [2] |
struct drm_xe_vm_query_mem_range_attr - Input of &DRM_IOCTL_XE_VM_QUERY_MEM_RANGE_ATTRS
This structure is used to query memory attributes of memory regions within a user specified address range in a VM. It provides detailed information about each memory range, including atomic access policy, page attribute table (PAT) index, and preferred memory location.
Userspace first calls the ioctl with @num_mem_ranges = 0, @sizeof_mem_range_attr = 0 and @vector_of_mem_attr = NULL to retrieve the number of memory regions and size of each memory range attribute. Then, it allocates a buffer of that size and calls the ioctl again to fill the buffer with memory range attributes.
If second call fails with -ENOSPC, it means memory ranges changed between first call and now, retry IOCTL again with @num_mem_ranges = 0, @sizeof_mem_range_attr = 0 and @vector_of_mem_attr = NULL followed by second ioctl call.
Example:
.. code-block:: C
struct drm_xe_vm_query_mem_range_attr query = { .vm_id = vm_id, .start = 0x100000, .range = 0x2000, };
// First ioctl call to get num of mem regions and sizeof each attribute ioctl(fd, DRM_IOCTL_XE_VM_QUERY_MEM_RANGE_ATTRS, &query);
// Allocate buffer for the memory region attributes void *ptr = malloc(query.num_mem_ranges * query.sizeof_mem_range_attr); void *ptr_start = ptr;
query.vector_of_mem_attr = (uintptr_t)ptr;
// Second ioctl call to actually fill the memory attributes ioctl(fd, DRM_IOCTL_XE_VM_QUERY_MEM_RANGE_ATTRS, &query);
// Iterate over the returned memory region attributes for (unsigned int i = 0; i < query.num_mem_ranges; ++i) { struct drm_xe_mem_range_attr *attr = (struct drm_xe_mem_range_attr *)ptr;
// Do something with attr
// Move pointer by one entry ptr += query.sizeof_mem_range_attr; }
| __u64 drm_xe_vm_query_mem_range_attr::extensions |
@extensions: Pointer to the first extension struct, if any
| __u32 drm_xe_vm_query_mem_range_attr::num_mem_ranges |
@num_mem_ranges: number of mem_ranges in range
| __u64 drm_xe_vm_query_mem_range_attr::range |
@range: size of the virtual address range
| __u64 drm_xe_vm_query_mem_range_attr::reserved[2] |
@reserved: Reserved
| __u64 drm_xe_vm_query_mem_range_attr::sizeof_mem_range_attr |
@sizeof_mem_range_attr: size of struct drm_xe_mem_range_attr
| __u64 drm_xe_vm_query_mem_range_attr::start |
@start: start of the virtual address range
| __u64 drm_xe_vm_query_mem_range_attr::vector_of_mem_attr |
@vector_of_mem_attr: userptr to array of struct drm_xe_mem_range_attr
| __u32 drm_xe_vm_query_mem_range_attr::vm_id |
@vm_id: vm_id of the virtual range