Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/linux
File: userfaultfd.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
[0] Fix | Delete
/*
[1] Fix | Delete
* include/linux/userfaultfd.h
[2] Fix | Delete
*
[3] Fix | Delete
* Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
[4] Fix | Delete
* Copyright (C) 2015 Red Hat, Inc.
[5] Fix | Delete
*
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
#ifndef _LINUX_USERFAULTFD_H
[9] Fix | Delete
#define _LINUX_USERFAULTFD_H
[10] Fix | Delete
[11] Fix | Delete
#include <linux/types.h>
[12] Fix | Delete
[13] Fix | Delete
/*
[14] Fix | Delete
* If the UFFDIO_API is upgraded someday, the UFFDIO_UNREGISTER and
[15] Fix | Delete
* UFFDIO_WAKE ioctls should be defined as _IOW and not as _IOR. In
[16] Fix | Delete
* userfaultfd.h we assumed the kernel was reading (instead _IOC_READ
[17] Fix | Delete
* means the userland is reading).
[18] Fix | Delete
*/
[19] Fix | Delete
#define UFFD_API ((__u64)0xAA)
[20] Fix | Delete
#define UFFD_API_FEATURES (UFFD_FEATURE_PAGEFAULT_FLAG_WP | \
[21] Fix | Delete
UFFD_FEATURE_EVENT_FORK | \
[22] Fix | Delete
UFFD_FEATURE_EVENT_REMAP | \
[23] Fix | Delete
UFFD_FEATURE_EVENT_REMOVE | \
[24] Fix | Delete
UFFD_FEATURE_EVENT_UNMAP | \
[25] Fix | Delete
UFFD_FEATURE_MISSING_HUGETLBFS | \
[26] Fix | Delete
UFFD_FEATURE_MISSING_SHMEM | \
[27] Fix | Delete
UFFD_FEATURE_SIGBUS | \
[28] Fix | Delete
UFFD_FEATURE_THREAD_ID)
[29] Fix | Delete
#define UFFD_API_IOCTLS \
[30] Fix | Delete
((__u64)1 << _UFFDIO_REGISTER | \
[31] Fix | Delete
(__u64)1 << _UFFDIO_UNREGISTER | \
[32] Fix | Delete
(__u64)1 << _UFFDIO_API)
[33] Fix | Delete
#define UFFD_API_RANGE_IOCTLS \
[34] Fix | Delete
((__u64)1 << _UFFDIO_WAKE | \
[35] Fix | Delete
(__u64)1 << _UFFDIO_COPY | \
[36] Fix | Delete
(__u64)1 << _UFFDIO_ZEROPAGE | \
[37] Fix | Delete
(__u64)1 << _UFFDIO_WRITEPROTECT)
[38] Fix | Delete
#define UFFD_API_RANGE_IOCTLS_BASIC \
[39] Fix | Delete
((__u64)1 << _UFFDIO_WAKE | \
[40] Fix | Delete
(__u64)1 << _UFFDIO_COPY)
[41] Fix | Delete
[42] Fix | Delete
/*
[43] Fix | Delete
* Valid ioctl command number range with this API is from 0x00 to
[44] Fix | Delete
* 0x3F. UFFDIO_API is the fixed number, everything else can be
[45] Fix | Delete
* changed by implementing a different UFFD_API. If sticking to the
[46] Fix | Delete
* same UFFD_API more ioctl can be added and userland will be aware of
[47] Fix | Delete
* which ioctl the running kernel implements through the ioctl command
[48] Fix | Delete
* bitmask written by the UFFDIO_API.
[49] Fix | Delete
*/
[50] Fix | Delete
#define _UFFDIO_REGISTER (0x00)
[51] Fix | Delete
#define _UFFDIO_UNREGISTER (0x01)
[52] Fix | Delete
#define _UFFDIO_WAKE (0x02)
[53] Fix | Delete
#define _UFFDIO_COPY (0x03)
[54] Fix | Delete
#define _UFFDIO_ZEROPAGE (0x04)
[55] Fix | Delete
#define _UFFDIO_WRITEPROTECT (0x06)
[56] Fix | Delete
#define _UFFDIO_API (0x3F)
[57] Fix | Delete
[58] Fix | Delete
/* userfaultfd ioctl ids */
[59] Fix | Delete
#define UFFDIO 0xAA
[60] Fix | Delete
#define UFFDIO_API _IOWR(UFFDIO, _UFFDIO_API, \
[61] Fix | Delete
struct uffdio_api)
[62] Fix | Delete
#define UFFDIO_REGISTER _IOWR(UFFDIO, _UFFDIO_REGISTER, \
[63] Fix | Delete
struct uffdio_register)
[64] Fix | Delete
#define UFFDIO_UNREGISTER _IOR(UFFDIO, _UFFDIO_UNREGISTER, \
[65] Fix | Delete
struct uffdio_range)
[66] Fix | Delete
#define UFFDIO_WAKE _IOR(UFFDIO, _UFFDIO_WAKE, \
[67] Fix | Delete
struct uffdio_range)
[68] Fix | Delete
#define UFFDIO_COPY _IOWR(UFFDIO, _UFFDIO_COPY, \
[69] Fix | Delete
struct uffdio_copy)
[70] Fix | Delete
#define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, \
[71] Fix | Delete
struct uffdio_zeropage)
[72] Fix | Delete
#define UFFDIO_WRITEPROTECT _IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, \
[73] Fix | Delete
struct uffdio_writeprotect)
[74] Fix | Delete
[75] Fix | Delete
/* read() structure */
[76] Fix | Delete
struct uffd_msg {
[77] Fix | Delete
__u8 event;
[78] Fix | Delete
[79] Fix | Delete
__u8 reserved1;
[80] Fix | Delete
__u16 reserved2;
[81] Fix | Delete
__u32 reserved3;
[82] Fix | Delete
[83] Fix | Delete
union {
[84] Fix | Delete
struct {
[85] Fix | Delete
__u64 flags;
[86] Fix | Delete
__u64 address;
[87] Fix | Delete
union {
[88] Fix | Delete
__u32 ptid;
[89] Fix | Delete
} feat;
[90] Fix | Delete
} pagefault;
[91] Fix | Delete
[92] Fix | Delete
struct {
[93] Fix | Delete
__u32 ufd;
[94] Fix | Delete
} fork;
[95] Fix | Delete
[96] Fix | Delete
struct {
[97] Fix | Delete
__u64 from;
[98] Fix | Delete
__u64 to;
[99] Fix | Delete
__u64 len;
[100] Fix | Delete
} remap;
[101] Fix | Delete
[102] Fix | Delete
struct {
[103] Fix | Delete
__u64 start;
[104] Fix | Delete
__u64 end;
[105] Fix | Delete
} remove;
[106] Fix | Delete
[107] Fix | Delete
struct {
[108] Fix | Delete
/* unused reserved fields */
[109] Fix | Delete
__u64 reserved1;
[110] Fix | Delete
__u64 reserved2;
[111] Fix | Delete
__u64 reserved3;
[112] Fix | Delete
} reserved;
[113] Fix | Delete
} arg;
[114] Fix | Delete
} __attribute__((packed));
[115] Fix | Delete
[116] Fix | Delete
/*
[117] Fix | Delete
* Start at 0x12 and not at 0 to be more strict against bugs.
[118] Fix | Delete
*/
[119] Fix | Delete
#define UFFD_EVENT_PAGEFAULT 0x12
[120] Fix | Delete
#define UFFD_EVENT_FORK 0x13
[121] Fix | Delete
#define UFFD_EVENT_REMAP 0x14
[122] Fix | Delete
#define UFFD_EVENT_REMOVE 0x15
[123] Fix | Delete
#define UFFD_EVENT_UNMAP 0x16
[124] Fix | Delete
[125] Fix | Delete
/* flags for UFFD_EVENT_PAGEFAULT */
[126] Fix | Delete
#define UFFD_PAGEFAULT_FLAG_WRITE (1<<0) /* If this was a write fault */
[127] Fix | Delete
#define UFFD_PAGEFAULT_FLAG_WP (1<<1) /* If reason is VM_UFFD_WP */
[128] Fix | Delete
[129] Fix | Delete
struct uffdio_api {
[130] Fix | Delete
/* userland asks for an API number and the features to enable */
[131] Fix | Delete
__u64 api;
[132] Fix | Delete
/*
[133] Fix | Delete
* Kernel answers below with the all available features for
[134] Fix | Delete
* the API, this notifies userland of which events and/or
[135] Fix | Delete
* which flags for each event are enabled in the current
[136] Fix | Delete
* kernel.
[137] Fix | Delete
*
[138] Fix | Delete
* Note: UFFD_EVENT_PAGEFAULT and UFFD_PAGEFAULT_FLAG_WRITE
[139] Fix | Delete
* are to be considered implicitly always enabled in all kernels as
[140] Fix | Delete
* long as the uffdio_api.api requested matches UFFD_API.
[141] Fix | Delete
*
[142] Fix | Delete
* UFFD_FEATURE_MISSING_HUGETLBFS means an UFFDIO_REGISTER
[143] Fix | Delete
* with UFFDIO_REGISTER_MODE_MISSING mode will succeed on
[144] Fix | Delete
* hugetlbfs virtual memory ranges. Adding or not adding
[145] Fix | Delete
* UFFD_FEATURE_MISSING_HUGETLBFS to uffdio_api.features has
[146] Fix | Delete
* no real functional effect after UFFDIO_API returns, but
[147] Fix | Delete
* it's only useful for an initial feature set probe at
[148] Fix | Delete
* UFFDIO_API time. There are two ways to use it:
[149] Fix | Delete
*
[150] Fix | Delete
* 1) by adding UFFD_FEATURE_MISSING_HUGETLBFS to the
[151] Fix | Delete
* uffdio_api.features before calling UFFDIO_API, an error
[152] Fix | Delete
* will be returned by UFFDIO_API on a kernel without
[153] Fix | Delete
* hugetlbfs missing support
[154] Fix | Delete
*
[155] Fix | Delete
* 2) the UFFD_FEATURE_MISSING_HUGETLBFS can not be added in
[156] Fix | Delete
* uffdio_api.features and instead it will be set by the
[157] Fix | Delete
* kernel in the uffdio_api.features if the kernel supports
[158] Fix | Delete
* it, so userland can later check if the feature flag is
[159] Fix | Delete
* present in uffdio_api.features after UFFDIO_API
[160] Fix | Delete
* succeeded.
[161] Fix | Delete
*
[162] Fix | Delete
* UFFD_FEATURE_MISSING_SHMEM works the same as
[163] Fix | Delete
* UFFD_FEATURE_MISSING_HUGETLBFS, but it applies to shmem
[164] Fix | Delete
* (i.e. tmpfs and other shmem based APIs).
[165] Fix | Delete
*
[166] Fix | Delete
* UFFD_FEATURE_SIGBUS feature means no page-fault
[167] Fix | Delete
* (UFFD_EVENT_PAGEFAULT) event will be delivered, instead
[168] Fix | Delete
* a SIGBUS signal will be sent to the faulting process.
[169] Fix | Delete
*
[170] Fix | Delete
* UFFD_FEATURE_THREAD_ID pid of the page faulted task_struct will
[171] Fix | Delete
* be returned, if feature is not requested 0 will be returned.
[172] Fix | Delete
*/
[173] Fix | Delete
#define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0)
[174] Fix | Delete
#define UFFD_FEATURE_EVENT_FORK (1<<1)
[175] Fix | Delete
#define UFFD_FEATURE_EVENT_REMAP (1<<2)
[176] Fix | Delete
#define UFFD_FEATURE_EVENT_REMOVE (1<<3)
[177] Fix | Delete
#define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4)
[178] Fix | Delete
#define UFFD_FEATURE_MISSING_SHMEM (1<<5)
[179] Fix | Delete
#define UFFD_FEATURE_EVENT_UNMAP (1<<6)
[180] Fix | Delete
#define UFFD_FEATURE_SIGBUS (1<<7)
[181] Fix | Delete
#define UFFD_FEATURE_THREAD_ID (1<<8)
[182] Fix | Delete
__u64 features;
[183] Fix | Delete
[184] Fix | Delete
__u64 ioctls;
[185] Fix | Delete
};
[186] Fix | Delete
[187] Fix | Delete
struct uffdio_range {
[188] Fix | Delete
__u64 start;
[189] Fix | Delete
__u64 len;
[190] Fix | Delete
};
[191] Fix | Delete
[192] Fix | Delete
struct uffdio_register {
[193] Fix | Delete
struct uffdio_range range;
[194] Fix | Delete
#define UFFDIO_REGISTER_MODE_MISSING ((__u64)1<<0)
[195] Fix | Delete
#define UFFDIO_REGISTER_MODE_WP ((__u64)1<<1)
[196] Fix | Delete
__u64 mode;
[197] Fix | Delete
[198] Fix | Delete
/*
[199] Fix | Delete
* kernel answers which ioctl commands are available for the
[200] Fix | Delete
* range, keep at the end as the last 8 bytes aren't read.
[201] Fix | Delete
*/
[202] Fix | Delete
__u64 ioctls;
[203] Fix | Delete
};
[204] Fix | Delete
[205] Fix | Delete
struct uffdio_copy {
[206] Fix | Delete
__u64 dst;
[207] Fix | Delete
__u64 src;
[208] Fix | Delete
__u64 len;
[209] Fix | Delete
#define UFFDIO_COPY_MODE_DONTWAKE ((__u64)1<<0)
[210] Fix | Delete
/*
[211] Fix | Delete
* UFFDIO_COPY_MODE_WP will map the page write protected on
[212] Fix | Delete
* the fly. UFFDIO_COPY_MODE_WP is available only if the
[213] Fix | Delete
* write protected ioctl is implemented for the range
[214] Fix | Delete
* according to the uffdio_register.ioctls.
[215] Fix | Delete
*/
[216] Fix | Delete
#define UFFDIO_COPY_MODE_WP ((__u64)1<<1)
[217] Fix | Delete
__u64 mode;
[218] Fix | Delete
[219] Fix | Delete
/*
[220] Fix | Delete
* "copy" is written by the ioctl and must be at the end: the
[221] Fix | Delete
* copy_from_user will not read the last 8 bytes.
[222] Fix | Delete
*/
[223] Fix | Delete
__s64 copy;
[224] Fix | Delete
};
[225] Fix | Delete
[226] Fix | Delete
struct uffdio_zeropage {
[227] Fix | Delete
struct uffdio_range range;
[228] Fix | Delete
#define UFFDIO_ZEROPAGE_MODE_DONTWAKE ((__u64)1<<0)
[229] Fix | Delete
__u64 mode;
[230] Fix | Delete
[231] Fix | Delete
/*
[232] Fix | Delete
* "zeropage" is written by the ioctl and must be at the end:
[233] Fix | Delete
* the copy_from_user will not read the last 8 bytes.
[234] Fix | Delete
*/
[235] Fix | Delete
__s64 zeropage;
[236] Fix | Delete
};
[237] Fix | Delete
[238] Fix | Delete
struct uffdio_writeprotect {
[239] Fix | Delete
struct uffdio_range range;
[240] Fix | Delete
/*
[241] Fix | Delete
* UFFDIO_WRITEPROTECT_MODE_WP: set the flag to write protect a range,
[242] Fix | Delete
* unset the flag to undo protection of a range which was previously
[243] Fix | Delete
* write protected.
[244] Fix | Delete
*
[245] Fix | Delete
* UFFDIO_WRITEPROTECT_MODE_DONTWAKE: set the flag to avoid waking up
[246] Fix | Delete
* any wait thread after the operation succeeds.
[247] Fix | Delete
*
[248] Fix | Delete
* NOTE: Write protecting a region (WP=1) is unrelated to page faults,
[249] Fix | Delete
* therefore DONTWAKE flag is meaningless with WP=1. Removing write
[250] Fix | Delete
* protection (WP=0) in response to a page fault wakes the faulting
[251] Fix | Delete
* task unless DONTWAKE is set.
[252] Fix | Delete
*/
[253] Fix | Delete
#define UFFDIO_WRITEPROTECT_MODE_WP ((__u64)1<<0)
[254] Fix | Delete
#define UFFDIO_WRITEPROTECT_MODE_DONTWAKE ((__u64)1<<1)
[255] Fix | Delete
__u64 mode;
[256] Fix | Delete
};
[257] Fix | Delete
[258] Fix | Delete
#endif /* _LINUX_USERFAULTFD_H */
[259] Fix | Delete
[260] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function