blob: 7095d9a2153b9fc0c7e26d578ad1dcaa87ffb38a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#include "config.h"
#include "config-host.h"
#include <string.h>
#include "hw/hw.h"
#include "qemu-kvm.h"
#include <libkvm.h>
#include <pthread.h>
#include <sys/utsname.h>
extern kvm_context_t kvm_context;
int kvm_arch_qemu_create_context(void)
{
return 0;
}
void kvm_arch_load_regs(CPUState *env)
{
}
void kvm_arch_save_regs(CPUState *env)
{
}
int kvm_arch_qemu_init_env(CPUState *cenv)
{
return 0;
}
int kvm_arch_halt(void *opaque, int vcpu)
{
CPUState *env = cpu_single_env;
env->hflags |= HF_HALTED_MASK;
env->exception_index = EXCP_HLT;
return 1;
}
void kvm_arch_pre_kvm_run(void *opaque, int vcpu)
{
}
void kvm_arch_post_kvm_run(void *opaque, int vcpu)
{
}
int kvm_arch_has_work(CPUState *env)
{
return 1;
}
int kvm_arch_try_push_interrupts(void *opaque)
{
return 1;
}
int kvm_arch_try_push_nmi(void *opaque)
{
return 1;
}
void kvm_arch_update_regs_for_sipi(CPUState *env)
{
}
void kvm_save_mpstate(CPUState *env)
{
#ifdef KVM_CAP_MP_STATE
int r;
struct kvm_mp_state mp_state;
r = kvm_get_mpstate(kvm_context, env->cpu_index, &mp_state);
if (r < 0)
env->mp_state = -1;
else
env->mp_state = mp_state.mp_state;
#endif
}
void kvm_load_mpstate(CPUState *env)
{
#ifdef KVM_CAP_MP_STATE
struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
/*
* -1 indicates that the host did not support GET_MP_STATE ioctl,
* so don't touch it.
*/
if (env->mp_state != -1)
kvm_set_mpstate(kvm_context, env->cpu_index, &mp_state);
#endif
}
void kvm_arch_cpu_reset(CPUState *env)
{
if (kvm_irqchip_in_kernel(kvm_context)) {
#ifdef KVM_CAP_MP_STATE
kvm_reset_mpstate(kvm_context, env->cpu_index);
#endif
} else {
env->interrupt_request &= ~CPU_INTERRUPT_HARD;
env->halted = 1;
env->exception_index = EXCP_HLT;
}
}
void kvm_arch_do_ioperm(void *_data)
{
struct ioperm_data *data = _data;
ioperm(data->start_port, data->num, data->turn_on);
}
|