]> git.proxmox.com Git - mirror_qemu.git/blob - target-arm/kvm_arm.h
Merge remote-tracking branch 'pmaydell/tags/pull-target-arm-20131210' into staging
[mirror_qemu.git] / target-arm / kvm_arm.h
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
21 *
22 * Remember the memory region @mr, and when it is mapped by the
23 * machine model, tell the kernel that base address using the
24 * KVM_SET_DEVICE_ADDRESS ioctl. @devid should be the ID of
25 * the device as defined by KVM_SET_DEVICE_ADDRESS.
26 * The machine model may map and unmap the device multiple times;
27 * the kernel will only be told the final address at the point
28 * where machine init is complete.
29 */
30 void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid);
31
32 /**
33 * write_list_to_kvmstate:
34 * @cpu: ARMCPU
35 *
36 * For each register listed in the ARMCPU cpreg_indexes list, write
37 * its value from the cpreg_values list into the kernel (via ioctl).
38 * This updates KVM's working data structures from TCG data or
39 * from incoming migration state.
40 *
41 * Returns: true if all register values were updated correctly,
42 * false if some register was unknown to the kernel or could not
43 * be written (eg constant register with the wrong value).
44 * Note that we do not stop early on failure -- we will attempt
45 * writing all registers in the list.
46 */
47 bool write_list_to_kvmstate(ARMCPU *cpu);
48
49 /**
50 * write_kvmstate_to_list:
51 * @cpu: ARMCPU
52 *
53 * For each register listed in the ARMCPU cpreg_indexes list, write
54 * its value from the kernel into the cpreg_values list. This is used to
55 * copy info from KVM's working data structures into TCG or
56 * for outbound migration.
57 *
58 * Returns: true if all register values were read correctly,
59 * false if some register was unknown or could not be read.
60 * Note that we do not stop early on failure -- we will attempt
61 * reading all registers in the list.
62 */
63 bool write_kvmstate_to_list(ARMCPU *cpu);
64
65 #ifdef CONFIG_KVM
66 /**
67 * kvm_arm_create_scratch_host_vcpu:
68 * @cpus_to_try: array of QEMU_KVM_ARM_TARGET_* values (terminated with
69 * QEMU_KVM_ARM_TARGET_NONE) to try as fallback if the kernel does not
70 * know the PREFERRED_TARGET ioctl
71 * @fdarray: filled in with kvmfd, vmfd, cpufd file descriptors in that order
72 * @init: filled in with the necessary values for creating a host vcpu
73 *
74 * Create a scratch vcpu in its own VM of the type preferred by the host
75 * kernel (as would be used for '-cpu host'), for purposes of probing it
76 * for capabilities.
77 *
78 * Returns: true on success (and fdarray and init are filled in),
79 * false on failure (and fdarray and init are not valid).
80 */
81 bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
82 int *fdarray,
83 struct kvm_vcpu_init *init);
84
85 /**
86 * kvm_arm_destroy_scratch_host_vcpu:
87 * @fdarray: array of fds as set up by kvm_arm_create_scratch_host_vcpu
88 *
89 * Tear down the scratch vcpu created by kvm_arm_create_scratch_host_vcpu.
90 */
91 void kvm_arm_destroy_scratch_host_vcpu(int *fdarray);
92
93 #define TYPE_ARM_HOST_CPU "host-" TYPE_ARM_CPU
94 #define ARM_HOST_CPU_CLASS(klass) \
95 OBJECT_CLASS_CHECK(ARMHostCPUClass, (klass), TYPE_ARM_HOST_CPU)
96 #define ARM_HOST_CPU_GET_CLASS(obj) \
97 OBJECT_GET_CLASS(ARMHostCPUClass, (obj), TYPE_ARM_HOST_CPU)
98
99 typedef struct ARMHostCPUClass {
100 /*< private >*/
101 ARMCPUClass parent_class;
102 /*< public >*/
103
104 uint64_t features;
105 uint32_t target;
106 const char *dtb_compatible;
107 } ARMHostCPUClass;
108
109 /**
110 * kvm_arm_get_host_cpu_features:
111 * @ahcc: ARMHostCPUClass to fill in
112 *
113 * Probe the capabilities of the host kernel's preferred CPU and fill
114 * in the ARMHostCPUClass struct accordingly.
115 */
116 bool kvm_arm_get_host_cpu_features(ARMHostCPUClass *ahcc);
117
118 #endif
119
120 #endif