media: venus: pm_helpers: Fix kernel module reload
[linux-2.6-microblaze.git] / tools / testing / selftests / kvm / lib / kvm_util_internal.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * tools/testing/selftests/kvm/lib/kvm_util_internal.h
4  *
5  * Copyright (C) 2018, Google LLC.
6  */
7
8 #ifndef SELFTEST_KVM_UTIL_INTERNAL_H
9 #define SELFTEST_KVM_UTIL_INTERNAL_H
10
11 #include "sparsebit.h"
12
13 #define KVM_DEV_PATH            "/dev/kvm"
14
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;
24 };
25
26 struct vcpu {
27         struct list_head list;
28         uint32_t id;
29         int fd;
30         struct kvm_run *state;
31 };
32
33 struct kvm_vm {
34         int mode;
35         unsigned long type;
36         int kvm_fd;
37         int fd;
38         unsigned int pgtable_levels;
39         unsigned int page_size;
40         unsigned int page_shift;
41         unsigned int pa_bits;
42         unsigned int va_bits;
43         uint64_t max_gfn;
44         struct list_head vcpus;
45         struct list_head userspace_mem_regions;
46         struct sparsebit *vpages_valid;
47         struct sparsebit *vpages_mapped;
48         bool has_irqchip;
49         bool pgd_created;
50         vm_paddr_t pgd;
51         vm_vaddr_t gdt;
52         vm_vaddr_t tss;
53 };
54
55 struct vcpu *vcpu_find(struct kvm_vm *vm, uint32_t vcpuid);
56
57 /*
58  * Virtual Translation Tables Dump
59  *
60  * Input Args:
61  *   stream - Output FILE stream
62  *   vm     - Virtual Machine
63  *   indent - Left margin indent amount
64  *
65  * Output Args: None
66  *
67  * Return: None
68  *
69  * Dumps to the FILE stream given by @stream, the contents of all the
70  * virtual translation tables for the VM given by @vm.
71  */
72 void virt_dump(FILE *stream, struct kvm_vm *vm, uint8_t indent);
73
74 /*
75  * Register Dump
76  *
77  * Input Args:
78  *   stream - Output FILE stream
79  *   regs   - Registers
80  *   indent - Left margin indent amount
81  *
82  * Output Args: None
83  *
84  * Return: None
85  *
86  * Dumps the state of the registers given by @regs, to the FILE stream
87  * given by @stream.
88  */
89 void regs_dump(FILE *stream, struct kvm_regs *regs, uint8_t indent);
90
91 /*
92  * System Register Dump
93  *
94  * Input Args:
95  *   stream - Output FILE stream
96  *   sregs  - System registers
97  *   indent - Left margin indent amount
98  *
99  * Output Args: None
100  *
101  * Return: None
102  *
103  * Dumps the state of the system registers given by @sregs, to the FILE stream
104  * given by @stream.
105  */
106 void sregs_dump(FILE *stream, struct kvm_sregs *sregs, uint8_t indent);
107
108 struct userspace_mem_region *
109 memslot2region(struct kvm_vm *vm, uint32_t memslot);
110
111 #endif /* SELFTEST_KVM_UTIL_INTERNAL_H */