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.

Dependency Surface

Detected Declarations

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

Implementation Notes