From: Guillaume Thouvenin Subject: [RFC PATCH] x86 emulator: emulate CPUID instruction Date: Mon, 15 Dec 2008 12:43:55 +0100 Message-ID: <20081215124355.009afdb5@frecb000711> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org Return-path: Received: from ecfrec.frec.bull.fr ([129.183.4.8]:56011 "EHLO ecfrec.frec.bull.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750879AbYLOMFy (ORCPT ); Mon, 15 Dec 2008 07:05:54 -0500 Received: from localhost (localhost [127.0.0.1]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id C358D19D9BD for ; Mon, 15 Dec 2008 13:05:58 +0100 (CET) Received: from ecfrec.frec.bull.fr ([127.0.0.1]) by localhost (ecfrec.frec.bull.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 30988-01 for ; Mon, 15 Dec 2008 13:05:54 +0100 (CET) Received: from cyclope.frec.bull.fr (cyclope.frec.bull.fr [129.183.4.9]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id CB34519DA8B for ; Mon, 15 Dec 2008 12:43:55 +0100 (CET) Received: from frecb000711 (frecb000711.frec.bull.fr [129.183.101.50]) by cyclope.frec.bull.fr (Postfix) with ESMTP id 2BBDB27289 for ; Mon, 15 Dec 2008 12:43:53 +0100 (CET) Sender: kvm-owner@vger.kernel.org List-ID: This patch emulates CPUID instruction. It should work but when I'm testing it in kvm-userspace, the cpuid instruction seems to have no effect (I mean eax == ebx == ecx == edx == 0x0). Should kvm_cpuid_emulate() be modified? Is cpuid instruction correctly implemented? Regards, Signed-off-by: Guillaume Thouvenin --- arch/x86/kvm/x86_emulate.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c index d174db7..4d1821c 100644 --- a/arch/x86/kvm/x86_emulate.c +++ b/arch/x86/kvm/x86_emulate.c @@ -237,7 +237,7 @@ static u32 twobyte_table[256] = { /* 0x90 - 0x9F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xA0 - 0xA7 */ - 0, 0, 0, DstMem | SrcReg | ModRM | BitOp, + 0, 0, ImplicitOps, DstMem | SrcReg | ModRM | BitOp, DstMem | SrcReg | Src2ImmByte | ModRM, DstMem | SrcReg | Src2CL | ModRM, 0, 0, /* 0xA8 - 0xAF */ @@ -2035,6 +2035,9 @@ twobyte_insn: c->dst.type = OP_NONE; break; } + case 0xa2: /* cpuid */ + kvm_emulate_cpuid(ctxt->vcpu); + break; case 0xa3: bt: /* bt */ c->dst.type = OP_NONE; -- 1.6.0.4.623.g171d7