tools/testing/selftests/kvm/include/kvm_util.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/include/kvm_util.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/include/kvm_util.h- Extension
.h- Size
- 34315 bytes
- Lines
- 1289
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
test_util.hlinux/compiler.hlinux/hashtable.hlinux/list.hlinux/kernel.hlinux/kvm.hlinux/rbtree.hlinux/types.hasm/atomic.hasm/kvm.hsys/eventfd.hsys/ioctl.hpthread.hkvm_syscalls.hkvm_util_arch.hkvm_util_types.hsparsebit.h
Detected Declarations
struct userspace_mem_regionstruct kvm_binary_statsstruct kvm_vcpustruct userspace_mem_regionsstruct kvm_mmustruct kvm_vmstruct vcpu_reg_subliststruct vcpu_reg_liststruct vm_shapestruct vm_guest_mode_paramsenum kvm_mem_region_typeenum vm_guest_modefunction get_kvm_param_boolfunction get_kvm_param_integerfunction kvm_has_capfunction static_assert_is_vmfunction __vm_ioctlfunction static_assert_is_vcpufunction vm_check_capfunction __vm_enable_capfunction vm_enable_capfunction vm_set_memory_attributesfunction vm_mem_set_privatefunction vm_mem_set_sharedfunction vm_guest_mem_punch_holefunction vm_guest_mem_allocatefunction kvm_vm_get_dirty_logfunction kvm_vm_clear_dirty_logfunction kvm_vm_reset_dirty_ringfunction kvm_vm_register_coalesced_iofunction kvm_vm_unregister_coalesced_iofunction vm_get_stats_fdfunction __kvm_irqfdfunction kvm_irqfdfunction kvm_assign_irqfdfunction kvm_deassign_irqfdfunction kvm_new_eventfdfunction read_stats_headerfunction get_stats_descriptor_sizefunction read_smt_controlfunction is_smt_possiblefunction is_smt_onfunction __vm_create_guest_memfdfunction vm_create_guest_memfdfunction vm_arch_has_protected_memoryfunction vm_untag_gpafunction __vcpu_runfunction vcpu_enable_cap
Annotated Snippet
struct userspace_mem_region {
struct kvm_userspace_memory_region2 region;
struct sparsebit *unused_phy_pages;
struct sparsebit *protected_phy_pages;
int fd;
off_t offset;
enum vm_mem_backing_src_type backing_src_type;
void *host_mem;
void *host_alias;
void *mmap_start;
void *mmap_alias;
size_t mmap_size;
struct rb_node gpa_node;
struct rb_node hva_node;
struct hlist_node slot_node;
};
struct kvm_binary_stats {
int fd;
struct kvm_stats_header header;
struct kvm_stats_desc *desc;
};
struct kvm_vcpu {
struct list_head list;
u32 id;
int fd;
struct kvm_vm *vm;
struct kvm_run *run;
#ifdef __x86_64__
struct kvm_cpuid2 *cpuid;
#endif
#ifdef __aarch64__
struct kvm_vcpu_init init;
#endif
struct kvm_binary_stats stats;
struct kvm_dirty_gfn *dirty_gfns;
u32 fetch_index;
u32 dirty_gfns_count;
};
struct userspace_mem_regions {
struct rb_root gpa_tree;
struct rb_root hva_tree;
DECLARE_HASHTABLE(slot_hash, 9);
};
enum kvm_mem_region_type {
MEM_REGION_CODE,
MEM_REGION_DATA,
MEM_REGION_PT,
MEM_REGION_TEST_DATA,
NR_MEM_REGIONS,
};
struct kvm_mmu {
bool pgd_created;
u64 pgd;
int pgtable_levels;
struct kvm_mmu_arch arch;
};
struct kvm_vm {
int mode;
unsigned long type;
int kvm_fd;
int fd;
unsigned int page_size;
unsigned int page_shift;
unsigned int pa_bits;
unsigned int va_bits;
u64 max_gfn;
struct list_head vcpus;
struct userspace_mem_regions regions;
struct sparsebit *vpages_valid;
struct sparsebit *vpages_mapped;
bool has_irqchip;
gpa_t ucall_mmio_addr;
gva_t handlers;
u32 dirty_ring_size;
gpa_t gpa_tag_mask;
/*
* "mmu" is the guest's stage-1, with a short name because the vast
* majority of tests only care about the stage-1 MMU.
*/
struct kvm_mmu mmu;
struct kvm_mmu stage2_mmu;
Annotation
- Immediate include surface: `test_util.h`, `linux/compiler.h`, `linux/hashtable.h`, `linux/list.h`, `linux/kernel.h`, `linux/kvm.h`, `linux/rbtree.h`, `linux/types.h`.
- Detected declarations: `struct userspace_mem_region`, `struct kvm_binary_stats`, `struct kvm_vcpu`, `struct userspace_mem_regions`, `struct kvm_mmu`, `struct kvm_vm`, `struct vcpu_reg_sublist`, `struct vcpu_reg_list`, `struct vm_shape`, `struct vm_guest_mode_params`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.