Revision bb0300dc target-i386/kvm.c
b/target-i386/kvm.c | ||
---|---|---|
25 | 25 |
#include "gdbstub.h" |
26 | 26 |
#include "host-utils.h" |
27 | 27 |
|
28 |
#ifdef CONFIG_KVM_PARA |
|
29 |
#include <linux/kvm_para.h> |
|
30 |
#endif |
|
31 |
// |
|
28 | 32 |
//#define DEBUG_KVM |
29 | 33 |
|
30 | 34 |
#ifdef DEBUG_KVM |
... | ... | |
134 | 138 |
} |
135 | 139 |
} |
136 | 140 |
|
141 |
#ifdef CONFIG_KVM_PARA |
|
142 |
struct kvm_para_features { |
|
143 |
int cap; |
|
144 |
int feature; |
|
145 |
} para_features[] = { |
|
146 |
#ifdef KVM_CAP_CLOCKSOURCE |
|
147 |
{ KVM_CAP_CLOCKSOURCE, KVM_FEATURE_CLOCKSOURCE }, |
|
148 |
#endif |
|
149 |
#ifdef KVM_CAP_NOP_IO_DELAY |
|
150 |
{ KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY }, |
|
151 |
#endif |
|
152 |
#ifdef KVM_CAP_PV_MMU |
|
153 |
{ KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP }, |
|
154 |
#endif |
|
155 |
#ifdef KVM_CAP_CR3_CACHE |
|
156 |
{ KVM_CAP_CR3_CACHE, KVM_FEATURE_CR3_CACHE }, |
|
157 |
#endif |
|
158 |
{ -1, -1 } |
|
159 |
}; |
|
160 |
|
|
161 |
static int get_para_features(CPUState *env) |
|
162 |
{ |
|
163 |
int i, features = 0; |
|
164 |
|
|
165 |
for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) { |
|
166 |
if (kvm_check_extension(env->kvm_state, para_features[i].cap)) |
|
167 |
features |= (1 << para_features[i].feature); |
|
168 |
} |
|
169 |
|
|
170 |
return features; |
|
171 |
} |
|
172 |
#endif |
|
173 |
|
|
137 | 174 |
int kvm_arch_init_vcpu(CPUState *env) |
138 | 175 |
{ |
139 | 176 |
struct { |
... | ... | |
142 | 179 |
} __attribute__((packed)) cpuid_data; |
143 | 180 |
uint32_t limit, i, j, cpuid_i; |
144 | 181 |
uint32_t unused; |
182 |
struct kvm_cpuid_entry2 *c; |
|
183 |
#ifdef KVM_CPUID_SIGNATURE |
|
184 |
uint32_t signature[3]; |
|
185 |
#endif |
|
145 | 186 |
|
146 | 187 |
env->mp_state = KVM_MP_STATE_RUNNABLE; |
147 | 188 |
|
... | ... | |
160 | 201 |
|
161 | 202 |
cpuid_i = 0; |
162 | 203 |
|
204 |
#ifdef CONFIG_KVM_PARA |
|
205 |
/* Paravirtualization CPUIDs */ |
|
206 |
memcpy(signature, "KVMKVMKVM\0\0\0", 12); |
|
207 |
c = &cpuid_data.entries[cpuid_i++]; |
|
208 |
memset(c, 0, sizeof(*c)); |
|
209 |
c->function = KVM_CPUID_SIGNATURE; |
|
210 |
c->eax = 0; |
|
211 |
c->ebx = signature[0]; |
|
212 |
c->ecx = signature[1]; |
|
213 |
c->edx = signature[2]; |
|
214 |
|
|
215 |
c = &cpuid_data.entries[cpuid_i++]; |
|
216 |
memset(c, 0, sizeof(*c)); |
|
217 |
c->function = KVM_CPUID_FEATURES; |
|
218 |
c->eax = env->cpuid_kvm_features & get_para_features(env); |
|
219 |
#endif |
|
220 |
|
|
163 | 221 |
cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused); |
164 | 222 |
|
165 | 223 |
for (i = 0; i <= limit; i++) { |
166 |
struct kvm_cpuid_entry2 *c = &cpuid_data.entries[cpuid_i++];
|
|
224 |
c = &cpuid_data.entries[cpuid_i++]; |
|
167 | 225 |
|
168 | 226 |
switch (i) { |
169 | 227 |
case 2: { |
... | ... | |
213 | 271 |
cpu_x86_cpuid(env, 0x80000000, 0, &limit, &unused, &unused, &unused); |
214 | 272 |
|
215 | 273 |
for (i = 0x80000000; i <= limit; i++) { |
216 |
struct kvm_cpuid_entry2 *c = &cpuid_data.entries[cpuid_i++];
|
|
274 |
c = &cpuid_data.entries[cpuid_i++]; |
|
217 | 275 |
|
218 | 276 |
c->function = i; |
219 | 277 |
c->flags = 0; |
Also available in: Unified diff