tools/testing/vma/include/dup.h
Source file repositories/reference/linux-study-clean/tools/testing/vma/include/dup.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/vma/include/dup.h- Extension
.h- Size
- 46342 bytes
- Lines
- 1541
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
struct vm_area_structstruct mm_structstruct address_spacestruct file_operationsstruct filestruct anon_vma_chainstruct task_structstruct krefstruct anon_vma_namestruct vma_iteratorstruct mmap_actionstruct vm_area_descstruct vm_area_structstruct vm_operations_structstruct vm_unmapped_area_infostruct pagetable_move_controlenum mmap_action_typeenum vma_operationfunction vma_flags_emptyfunction vma_iter_invalidatefunction pgprot_modifyfunction vm_get_page_protfunction mm_flags_testfunction vma_flags_overwrite_wordfunction vma_flags_overwrite_word_oncefunction vma_flags_set_wordfunction vma_flags_clear_wordfunction vma_flags_clear_allfunction vma_flags_to_legacyfunction legacy_to_vma_flagsfunction vma_flags_set_flagfunction vm_flags_initfunction vm_flags_resetfunction vma_flags_reset_oncefunction vm_flags_setfunction vm_flags_clearfunction __mk_vma_flagsfunction COUNT_ARGSfunction vma_flags_testfunction vma_flags_and_maskfunction vma_flags_test_any_maskfunction vma_flags_test_all_maskfunction vma_flags_test_single_maskfunction vma_flags_set_maskfunction vma_flags_clear_maskfunction vma_flags_diff_pairfunction vma_flags_same_pairfunction vma_flags_same_mask
Annotated Snippet
struct file_operations {
int (*mmap)(struct file *, struct vm_area_struct *);
int (*mmap_prepare)(struct vm_area_desc *);
};
struct file {
struct address_space *f_mapping;
const struct file_operations *f_op;
};
struct anon_vma_chain {
struct anon_vma *anon_vma;
struct list_head same_vma;
};
struct task_struct {
char comm[TASK_COMM_LEN];
pid_t pid;
struct mm_struct *mm;
/* Used for emulating ABI behavior of previous Linux versions: */
unsigned int personality;
};
struct kref {
refcount_t refcount;
};
struct anon_vma_name {
struct kref kref;
/* The name needs to be at the end because it is dynamically sized. */
char name[];
};
/*
* Contains declarations that are DUPLICATED from kernel source in order to
* faciliate userland VMA testing.
*
* These must be kept in sync with kernel source.
*/
#define VMA_LOCK_OFFSET 0x40000000
typedef struct { unsigned long v; } freeptr_t;
#define VM_NONE 0x00000000
typedef int __bitwise vma_flag_t;
#define ACCESS_PRIVATE(p, member) ((p)->member)
#define DECLARE_VMA_BIT(name, bitnum) \
VMA_ ## name ## _BIT = ((__force vma_flag_t)bitnum)
#define DECLARE_VMA_BIT_ALIAS(name, aliased) \
VMA_ ## name ## _BIT = VMA_ ## aliased ## _BIT
enum {
DECLARE_VMA_BIT(READ, 0),
DECLARE_VMA_BIT(WRITE, 1),
DECLARE_VMA_BIT(EXEC, 2),
DECLARE_VMA_BIT(SHARED, 3),
/* mprotect() hardcodes VM_MAYREAD >> 4 == VM_READ, and so for r/w/x bits. */
DECLARE_VMA_BIT(MAYREAD, 4), /* limits for mprotect() etc. */
DECLARE_VMA_BIT(MAYWRITE, 5),
DECLARE_VMA_BIT(MAYEXEC, 6),
DECLARE_VMA_BIT(MAYSHARE, 7),
DECLARE_VMA_BIT(GROWSDOWN, 8), /* general info on the segment */
#ifdef CONFIG_MMU
DECLARE_VMA_BIT(UFFD_MISSING, 9),/* missing pages tracking */
#else
/* nommu: R/O MAP_PRIVATE mapping that might overlay a file mapping */
DECLARE_VMA_BIT(MAYOVERLAY, 9),
#endif /* CONFIG_MMU */
/* Page-ranges managed without "struct page", just pure PFN */
DECLARE_VMA_BIT(PFNMAP, 10),
DECLARE_VMA_BIT(MAYBE_GUARD, 11),
DECLARE_VMA_BIT(UFFD_WP, 12), /* wrprotect pages tracking */
DECLARE_VMA_BIT(LOCKED, 13),
DECLARE_VMA_BIT(IO, 14), /* Memory mapped I/O or similar */
DECLARE_VMA_BIT(SEQ_READ, 15), /* App will access data sequentially */
DECLARE_VMA_BIT(RAND_READ, 16), /* App will not benefit from clustered reads */
DECLARE_VMA_BIT(DONTCOPY, 17), /* Do not copy this vma on fork */
DECLARE_VMA_BIT(DONTEXPAND, 18),/* Cannot expand with mremap() */
DECLARE_VMA_BIT(LOCKONFAULT, 19),/* Lock pages covered when faulted in */
DECLARE_VMA_BIT(ACCOUNT, 20), /* Is a VM accounted object */
DECLARE_VMA_BIT(NORESERVE, 21), /* should the VM suppress accounting */
DECLARE_VMA_BIT(HUGETLB, 22), /* Huge TLB Page VM */
DECLARE_VMA_BIT(SYNC, 23), /* Synchronous page faults */
DECLARE_VMA_BIT(ARCH_1, 24), /* Architecture-specific flag */
DECLARE_VMA_BIT(WIPEONFORK, 25),/* Wipe VMA contents in child. */
DECLARE_VMA_BIT(DONTDUMP, 26), /* Do not include in the core dump */
DECLARE_VMA_BIT(SOFTDIRTY, 27), /* NOT soft dirty clean area */
DECLARE_VMA_BIT(MIXEDMAP, 28), /* Can contain struct page and pure PFN pages */
DECLARE_VMA_BIT(HUGEPAGE, 29), /* MADV_HUGEPAGE marked this vma */
Annotation
- Detected declarations: `struct vm_area_struct`, `struct mm_struct`, `struct address_space`, `struct file_operations`, `struct file`, `struct anon_vma_chain`, `struct task_struct`, `struct kref`, `struct anon_vma_name`, `struct vma_iterator`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.