aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2012-06-07 07:10:16 -0400
committerAvi Kivity <avi@redhat.com>2012-07-09 07:19:00 -0400
commit0017f93a2776597b798ec1a9594e41dfd96d3c11 (patch)
treeef0a1e1a409f6d9a5d48894b0256a723c1b1183b /arch/x86/kvm/x86.c
parent62046e5a867cbff35e0beff42718dda41ff5d74b (diff)
KVM: x86 emulator: change ->get_cpuid() accessor to use the x86 semantics
Instead of getting an exact leaf, follow the spec and fall back to the last main leaf instead. This lets us easily emulate the cpuid instruction in the emulator. Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8eacb2e6456..ff0b487e725 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4302,26 +4302,10 @@ static int emulator_intercept(struct x86_emulate_ctxt *ctxt,
4302 return kvm_x86_ops->check_intercept(emul_to_vcpu(ctxt), info, stage); 4302 return kvm_x86_ops->check_intercept(emul_to_vcpu(ctxt), info, stage);
4303} 4303}
4304 4304
4305static bool emulator_get_cpuid(struct x86_emulate_ctxt *ctxt, 4305static void emulator_get_cpuid(struct x86_emulate_ctxt *ctxt,
4306 u32 *eax, u32 *ebx, u32 *ecx, u32 *edx) 4306 u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
4307{ 4307{
4308 struct kvm_cpuid_entry2 *cpuid = NULL; 4308 kvm_cpuid(emul_to_vcpu(ctxt), eax, ebx, ecx, edx);
4309
4310 if (eax && ecx)
4311 cpuid = kvm_find_cpuid_entry(emul_to_vcpu(ctxt),
4312 *eax, *ecx);
4313
4314 if (cpuid) {
4315 *eax = cpuid->eax;
4316 *ecx = cpuid->ecx;
4317 if (ebx)
4318 *ebx = cpuid->ebx;
4319 if (edx)
4320 *edx = cpuid->edx;
4321 return true;
4322 }
4323
4324 return false;
4325} 4309}
4326 4310
4327static struct x86_emulate_ops emulate_ops = { 4311static struct x86_emulate_ops emulate_ops = {