]>
Commit | Line | Data |
---|---|---|
eb035b48 PM |
1 | /* |
2 | * QEMU KVM support -- ARM specific functions. | |
3 | * | |
4 | * Copyright (c) 2012 Linaro Limited | |
5 | * | |
6 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
7 | * See the COPYING file in the top-level directory. | |
8 | * | |
9 | */ | |
10 | ||
11 | #ifndef QEMU_KVM_ARM_H | |
12 | #define QEMU_KVM_ARM_H | |
13 | ||
14 | #include "sysemu/kvm.h" | |
15 | #include "exec/memory.h" | |
16 | ||
17 | /** | |
18 | * kvm_arm_register_device: | |
19 | * @mr: memory region for this device | |
20 | * @devid: the KVM device ID | |
1da41cc1 CD |
21 | * @group: device control API group for setting addresses |
22 | * @attr: device control API address type | |
23 | * @dev_fd: device control device file descriptor (or -1 if not supported) | |
eb035b48 PM |
24 | * |
25 | * Remember the memory region @mr, and when it is mapped by the | |
26 | * machine model, tell the kernel that base address using the | |
1da41cc1 CD |
27 | * KVM_ARM_SET_DEVICE_ADDRESS ioctl or the newer device control API. @devid |
28 | * should be the ID of the device as defined by KVM_ARM_SET_DEVICE_ADDRESS or | |
29 | * the arm-vgic device in the device control API. | |
30 | * The machine model may map | |
31 | * and unmap the device multiple times; the kernel will only be told the final | |
32 | * address at the point where machine init is complete. | |
eb035b48 | 33 | */ |
1da41cc1 CD |
34 | void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group, |
35 | uint64_t attr, int dev_fd); | |
eb035b48 | 36 | |
ff047453 PM |
37 | /** |
38 | * write_list_to_kvmstate: | |
39 | * @cpu: ARMCPU | |
40 | * | |
41 | * For each register listed in the ARMCPU cpreg_indexes list, write | |
42 | * its value from the cpreg_values list into the kernel (via ioctl). | |
43 | * This updates KVM's working data structures from TCG data or | |
44 | * from incoming migration state. | |
45 | * | |
46 | * Returns: true if all register values were updated correctly, | |
47 | * false if some register was unknown to the kernel or could not | |
48 | * be written (eg constant register with the wrong value). | |
49 | * Note that we do not stop early on failure -- we will attempt | |
50 | * writing all registers in the list. | |
51 | */ | |
52 | bool write_list_to_kvmstate(ARMCPU *cpu); | |
53 | ||
54 | /** | |
55 | * write_kvmstate_to_list: | |
56 | * @cpu: ARMCPU | |
57 | * | |
58 | * For each register listed in the ARMCPU cpreg_indexes list, write | |
59 | * its value from the kernel into the cpreg_values list. This is used to | |
60 | * copy info from KVM's working data structures into TCG or | |
61 | * for outbound migration. | |
62 | * | |
63 | * Returns: true if all register values were read correctly, | |
64 | * false if some register was unknown or could not be read. | |
65 | * Note that we do not stop early on failure -- we will attempt | |
66 | * reading all registers in the list. | |
67 | */ | |
68 | bool write_kvmstate_to_list(ARMCPU *cpu); | |
69 | ||
50a2c6e5 PB |
70 | /** |
71 | * kvm_arm_reset_vcpu: | |
72 | * @cpu: ARMCPU | |
73 | * | |
74 | * Called at reset time to kernel registers to their initial values. | |
75 | */ | |
76 | void kvm_arm_reset_vcpu(ARMCPU *cpu); | |
77 | ||
a96c0514 PM |
78 | #ifdef CONFIG_KVM |
79 | /** | |
80 | * kvm_arm_create_scratch_host_vcpu: | |
81 | * @cpus_to_try: array of QEMU_KVM_ARM_TARGET_* values (terminated with | |
82 | * QEMU_KVM_ARM_TARGET_NONE) to try as fallback if the kernel does not | |
83 | * know the PREFERRED_TARGET ioctl | |
84 | * @fdarray: filled in with kvmfd, vmfd, cpufd file descriptors in that order | |
85 | * @init: filled in with the necessary values for creating a host vcpu | |
86 | * | |
87 | * Create a scratch vcpu in its own VM of the type preferred by the host | |
88 | * kernel (as would be used for '-cpu host'), for purposes of probing it | |
89 | * for capabilities. | |
90 | * | |
91 | * Returns: true on success (and fdarray and init are filled in), | |
92 | * false on failure (and fdarray and init are not valid). | |
93 | */ | |
94 | bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, | |
95 | int *fdarray, | |
96 | struct kvm_vcpu_init *init); | |
97 | ||
98 | /** | |
99 | * kvm_arm_destroy_scratch_host_vcpu: | |
100 | * @fdarray: array of fds as set up by kvm_arm_create_scratch_host_vcpu | |
101 | * | |
102 | * Tear down the scratch vcpu created by kvm_arm_create_scratch_host_vcpu. | |
103 | */ | |
104 | void kvm_arm_destroy_scratch_host_vcpu(int *fdarray); | |
105 | ||
106 | #define TYPE_ARM_HOST_CPU "host-" TYPE_ARM_CPU | |
107 | #define ARM_HOST_CPU_CLASS(klass) \ | |
108 | OBJECT_CLASS_CHECK(ARMHostCPUClass, (klass), TYPE_ARM_HOST_CPU) | |
109 | #define ARM_HOST_CPU_GET_CLASS(obj) \ | |
110 | OBJECT_GET_CLASS(ARMHostCPUClass, (obj), TYPE_ARM_HOST_CPU) | |
111 | ||
112 | typedef struct ARMHostCPUClass { | |
113 | /*< private >*/ | |
114 | ARMCPUClass parent_class; | |
115 | /*< public >*/ | |
116 | ||
117 | uint64_t features; | |
118 | uint32_t target; | |
119 | const char *dtb_compatible; | |
120 | } ARMHostCPUClass; | |
121 | ||
122 | /** | |
123 | * kvm_arm_get_host_cpu_features: | |
124 | * @ahcc: ARMHostCPUClass to fill in | |
125 | * | |
126 | * Probe the capabilities of the host kernel's preferred CPU and fill | |
127 | * in the ARMHostCPUClass struct accordingly. | |
128 | */ | |
129 | bool kvm_arm_get_host_cpu_features(ARMHostCPUClass *ahcc); | |
130 | ||
131 | #endif | |
132 | ||
eb035b48 | 133 | #endif |