1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * tools/testing/selftests/kvm/lib/kvm_util_internal.h
5 * Copyright (C) 2018, Google LLC.
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
;
23 struct list_head list
;
27 struct list_head list
;
30 struct kvm_run
*state
;
31 struct kvm_dirty_gfn
*dirty_gfns
;
33 uint32_t dirty_gfns_count
;
41 unsigned int pgtable_levels
;
42 unsigned int page_size
;
43 unsigned int page_shift
;
47 struct list_head vcpus
;
48 struct list_head userspace_mem_regions
;
49 struct sparsebit
*vpages_valid
;
50 struct sparsebit
*vpages_mapped
;
58 uint32_t dirty_ring_size
;
61 struct vcpu
*vcpu_find(struct kvm_vm
*vm
, uint32_t vcpuid
);
64 * Virtual Translation Tables Dump
67 * stream - Output FILE stream
68 * vm - Virtual Machine
69 * indent - Left margin indent amount
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
);
84 * stream - Output FILE stream
86 * indent - Left margin indent amount
92 * Dumps the state of the registers given by @regs, to the FILE stream
95 void regs_dump(FILE *stream
, struct kvm_regs
*regs
, uint8_t indent
);
98 * System Register Dump
101 * stream - Output FILE stream
102 * sregs - System registers
103 * indent - Left margin indent amount
109 * Dumps the state of the system registers given by @sregs, to the FILE 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 */