WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / kvm / lib / kvm_util_internal.h
blob34465dc562d8cf809890f0a2060ba5fe282a32d7
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * tools/testing/selftests/kvm/lib/kvm_util_internal.h
5 * Copyright (C) 2018, Google LLC.
6 */
8 #ifndef SELFTEST_KVM_UTIL_INTERNAL_H
9 #define SELFTEST_KVM_UTIL_INTERNAL_H
11 #include "sparsebit.h"
13 #define KVM_DEV_PATH "/dev/kvm"
15 struct userspace_mem_region {
16 struct kvm_userspace_memory_region region;
17 struct sparsebit *unused_phy_pages;
18 int fd;
19 off_t offset;
20 void *host_mem;
21 void *mmap_start;
22 size_t mmap_size;
23 struct list_head list;
26 struct vcpu {
27 struct list_head list;
28 uint32_t id;
29 int fd;
30 struct kvm_run *state;
31 struct kvm_dirty_gfn *dirty_gfns;
32 uint32_t fetch_index;
33 uint32_t dirty_gfns_count;
36 struct kvm_vm {
37 int mode;
38 unsigned long type;
39 int kvm_fd;
40 int fd;
41 unsigned int pgtable_levels;
42 unsigned int page_size;
43 unsigned int page_shift;
44 unsigned int pa_bits;
45 unsigned int va_bits;
46 uint64_t max_gfn;
47 struct list_head vcpus;
48 struct list_head userspace_mem_regions;
49 struct sparsebit *vpages_valid;
50 struct sparsebit *vpages_mapped;
51 bool has_irqchip;
52 bool pgd_created;
53 vm_paddr_t pgd;
54 vm_vaddr_t gdt;
55 vm_vaddr_t tss;
56 vm_vaddr_t idt;
57 vm_vaddr_t handlers;
58 uint32_t dirty_ring_size;
61 struct vcpu *vcpu_find(struct kvm_vm *vm, uint32_t vcpuid);
64 * Virtual Translation Tables Dump
66 * Input Args:
67 * stream - Output FILE stream
68 * vm - Virtual Machine
69 * indent - Left margin indent amount
71 * Output Args: None
73 * Return: None
75 * Dumps to the FILE stream given by @stream, the contents of all the
76 * virtual translation tables for the VM given by @vm.
78 void virt_dump(FILE *stream, struct kvm_vm *vm, uint8_t indent);
81 * Register Dump
83 * Input Args:
84 * stream - Output FILE stream
85 * regs - Registers
86 * indent - Left margin indent amount
88 * Output Args: None
90 * Return: None
92 * Dumps the state of the registers given by @regs, to the FILE stream
93 * given by @stream.
95 void regs_dump(FILE *stream, struct kvm_regs *regs, uint8_t indent);
98 * System Register Dump
100 * Input Args:
101 * stream - Output FILE stream
102 * sregs - System registers
103 * indent - Left margin indent amount
105 * Output Args: None
107 * Return: None
109 * Dumps the state of the system registers given by @sregs, to the FILE stream
110 * given by @stream.
112 void sregs_dump(FILE *stream, struct kvm_sregs *sregs, uint8_t indent);
114 struct userspace_mem_region *
115 memslot2region(struct kvm_vm *vm, uint32_t memslot);
117 #endif /* SELFTEST_KVM_UTIL_INTERNAL_H */