From patchwork Wed Oct 31 09:39:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 195811 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D3FF52C036A for ; Wed, 31 Oct 2012 21:10:26 +1100 (EST) Received: from localhost ([::1]:38433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTUnq-0001Yb-MD for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2012 05:41:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTUml-0007pd-Ls for qemu-devel@nongnu.org; Wed, 31 Oct 2012 05:40:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTUmi-00035O-NQ for qemu-devel@nongnu.org; Wed, 31 Oct 2012 05:40:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTUmi-00034T-EC for qemu-devel@nongnu.org; Wed, 31 Oct 2012 05:40:28 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9V9eRIP026114 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 31 Oct 2012 05:40:27 -0400 Received: from amt.cnet (vpn1-4-142.gru2.redhat.com [10.97.4.142]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9V9eQ3H018619; Wed, 31 Oct 2012 05:40:27 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 6E92C652290; Wed, 31 Oct 2012 07:40:11 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.5/8.14.5/Submit) id q9V9eBSd025074; Wed, 31 Oct 2012 07:40:11 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Wed, 31 Oct 2012 07:39:42 -0200 Message-Id: <829ae2f9fa37bf026de556f50d58ef14a7dab9b3.1351676405.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org, Eduardo Habkost Subject: [Qemu-devel] [PATCH 04/28] i386: kvm: extract register switch to cpuid_entry_get_reg() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Eduardo Habkost No behavior change: just code movement. Signed-off-by: Eduardo Habkost Signed-off-by: Marcelo Tosatti --- target-i386/kvm.c | 37 +++++++++++++++++++++++-------------- 1 files changed, 23 insertions(+), 14 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 18782e4..695deb9 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -123,6 +123,28 @@ static int get_para_features(KVMState *s) } +/* Returns the value for a specific register on the cpuid entry + */ +static uint32_t cpuid_entry_get_reg(struct kvm_cpuid_entry2 *entry, int reg) +{ + uint32_t ret = 0; + switch (reg) { + case R_EAX: + ret = entry->eax; + break; + case R_EBX: + ret = entry->ebx; + break; + case R_ECX: + ret = entry->ecx; + break; + case R_EDX: + ret = entry->edx; + break; + } + return ret; +} + uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, uint32_t index, int reg) { @@ -142,20 +164,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, cpuid->entries[i].index == index) { struct kvm_cpuid_entry2 *entry = &cpuid->entries[i]; found = true; - switch (reg) { - case R_EAX: - ret = entry->eax; - break; - case R_EBX: - ret = entry->ebx; - break; - case R_ECX: - ret = entry->ecx; - break; - case R_EDX: - ret = entry->edx; - break; - } + ret = cpuid_entry_get_reg(entry, reg); } }