]> git.proxmox.com Git - mirror_qemu.git/blame - target-arm/kvm_arm.h
cpu-exec: Make debug_excp_handler a QOM CPU method
[mirror_qemu.git] / target-arm / kvm_arm.h
CommitLineData
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
228d5e04
PS
17/**
18 * kvm_arm_vcpu_init:
19 * @cs: CPUState
20 *
21 * Initialize (or reinitialize) the VCPU by invoking the
22 * KVM_ARM_VCPU_INIT ioctl with the CPU type and feature
23 * bitmask specified in the CPUState.
24 *
25 * Returns: 0 if success else < 0 error code
26 */
27int kvm_arm_vcpu_init(CPUState *cs);
28
eb035b48
PM
29/**
30 * kvm_arm_register_device:
31 * @mr: memory region for this device
32 * @devid: the KVM device ID
1da41cc1
CD
33 * @group: device control API group for setting addresses
34 * @attr: device control API address type
35 * @dev_fd: device control device file descriptor (or -1 if not supported)
eb035b48
PM
36 *
37 * Remember the memory region @mr, and when it is mapped by the
38 * machine model, tell the kernel that base address using the
1da41cc1
CD
39 * KVM_ARM_SET_DEVICE_ADDRESS ioctl or the newer device control API. @devid
40 * should be the ID of the device as defined by KVM_ARM_SET_DEVICE_ADDRESS or
41 * the arm-vgic device in the device control API.
42 * The machine model may map
43 * and unmap the device multiple times; the kernel will only be told the final
44 * address at the point where machine init is complete.
eb035b48 45 */
1da41cc1
CD
46void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group,
47 uint64_t attr, int dev_fd);
eb035b48 48
ff047453
PM
49/**
50 * write_list_to_kvmstate:
51 * @cpu: ARMCPU
52 *
53 * For each register listed in the ARMCPU cpreg_indexes list, write
54 * its value from the cpreg_values list into the kernel (via ioctl).
55 * This updates KVM's working data structures from TCG data or
56 * from incoming migration state.
57 *
58 * Returns: true if all register values were updated correctly,
59 * false if some register was unknown to the kernel or could not
60 * be written (eg constant register with the wrong value).
61 * Note that we do not stop early on failure -- we will attempt
62 * writing all registers in the list.
63 */
64bool write_list_to_kvmstate(ARMCPU *cpu);
65
66/**
67 * write_kvmstate_to_list:
68 * @cpu: ARMCPU
69 *
70 * For each register listed in the ARMCPU cpreg_indexes list, write
71 * its value from the kernel into the cpreg_values list. This is used to
72 * copy info from KVM's working data structures into TCG or
73 * for outbound migration.
74 *
75 * Returns: true if all register values were read correctly,
76 * false if some register was unknown or could not be read.
77 * Note that we do not stop early on failure -- we will attempt
78 * reading all registers in the list.
79 */
80bool write_kvmstate_to_list(ARMCPU *cpu);
81
50a2c6e5
PB
82/**
83 * kvm_arm_reset_vcpu:
84 * @cpu: ARMCPU
85 *
86 * Called at reset time to kernel registers to their initial values.
87 */
88void kvm_arm_reset_vcpu(ARMCPU *cpu);
89
a96c0514
PM
90#ifdef CONFIG_KVM
91/**
92 * kvm_arm_create_scratch_host_vcpu:
93 * @cpus_to_try: array of QEMU_KVM_ARM_TARGET_* values (terminated with
94 * QEMU_KVM_ARM_TARGET_NONE) to try as fallback if the kernel does not
95 * know the PREFERRED_TARGET ioctl
96 * @fdarray: filled in with kvmfd, vmfd, cpufd file descriptors in that order
97 * @init: filled in with the necessary values for creating a host vcpu
98 *
99 * Create a scratch vcpu in its own VM of the type preferred by the host
100 * kernel (as would be used for '-cpu host'), for purposes of probing it
101 * for capabilities.
102 *
103 * Returns: true on success (and fdarray and init are filled in),
104 * false on failure (and fdarray and init are not valid).
105 */
106bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
107 int *fdarray,
108 struct kvm_vcpu_init *init);
109
110/**
111 * kvm_arm_destroy_scratch_host_vcpu:
112 * @fdarray: array of fds as set up by kvm_arm_create_scratch_host_vcpu
113 *
114 * Tear down the scratch vcpu created by kvm_arm_create_scratch_host_vcpu.
115 */
116void kvm_arm_destroy_scratch_host_vcpu(int *fdarray);
117
118#define TYPE_ARM_HOST_CPU "host-" TYPE_ARM_CPU
119#define ARM_HOST_CPU_CLASS(klass) \
120 OBJECT_CLASS_CHECK(ARMHostCPUClass, (klass), TYPE_ARM_HOST_CPU)
121#define ARM_HOST_CPU_GET_CLASS(obj) \
122 OBJECT_GET_CLASS(ARMHostCPUClass, (obj), TYPE_ARM_HOST_CPU)
123
124typedef struct ARMHostCPUClass {
125 /*< private >*/
126 ARMCPUClass parent_class;
127 /*< public >*/
128
129 uint64_t features;
130 uint32_t target;
131 const char *dtb_compatible;
132} ARMHostCPUClass;
133
134/**
135 * kvm_arm_get_host_cpu_features:
136 * @ahcc: ARMHostCPUClass to fill in
137 *
138 * Probe the capabilities of the host kernel's preferred CPU and fill
139 * in the ARMHostCPUClass struct accordingly.
140 */
141bool kvm_arm_get_host_cpu_features(ARMHostCPUClass *ahcc);
142
143#endif
144
eb035b48 145#endif