From patchwork Fri Feb 19 18:22:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 45874 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6D808B7D04 for ; Sat, 20 Feb 2010 05:43:25 +1100 (EST) Received: from localhost ([127.0.0.1]:38333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NiXhm-00020g-67 for incoming@patchwork.ozlabs.org; Fri, 19 Feb 2010 13:35:58 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NiXUw-0006zM-Rs for qemu-devel@nongnu.org; Fri, 19 Feb 2010 13:22:43 -0500 Received: from [199.232.76.173] (port=44326 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NiXUw-0006yv-8l for qemu-devel@nongnu.org; Fri, 19 Feb 2010 13:22:42 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NiXUp-000064-1P for qemu-devel@nongnu.org; Fri, 19 Feb 2010 13:22:42 -0500 Received: from david.siemens.de ([192.35.17.14]:15172) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NiXUk-000053-K8 for qemu-devel@nongnu.org; Fri, 19 Feb 2010 13:22:31 -0500 Received: from mail3.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1JIMTkj017246; Fri, 19 Feb 2010 19:22:29 +0100 Received: from localhost.localdomain (mchn012c.ww002.siemens.net [139.25.109.167] (may be forged)) by mail3.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1JIMRGB025400; Fri, 19 Feb 2010 19:22:28 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Fri, 19 Feb 2010 19:22:24 +0100 Message-Id: <7966c9a8de51632bd0813f3dfda8615d4ee7bc27.1266603744.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: Anthony Liguori , qemu-devel@nongnu.org, kvm@vger.kernel.org, Gleb Natapov Subject: [Qemu-devel] [PATCH 6/9] qemu-kvm: Use upstream kvm_arch_get_supported_cpuid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It is idential to our version now, so drop the copy. Signed-off-by: Jan Kiszka --- kvm.h | 3 - qemu-kvm-x86.c | 106 ----------------------------------------------------- qemu-kvm.h | 5 -- target-i386/kvm.c | 4 +- 4 files changed, 2 insertions(+), 116 deletions(-) diff --git a/kvm.h b/kvm.h index b78e469..7f32f95 100644 --- a/kvm.h +++ b/kvm.h @@ -130,11 +130,8 @@ void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg); int kvm_check_extension(KVMState *s, unsigned int extension); -#ifdef KVM_UPSTREAM uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg); -#endif - void kvm_cpu_synchronize_state(CPUState *env); /* generic hooks - to be moved/refactored once there are more users */ diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 4cb1cb3..a7bf446 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -627,106 +627,6 @@ int kvm_disable_tpr_access_reporting(CPUState *env) #endif -#ifdef KVM_CAP_EXT_CPUID - -static struct kvm_cpuid2 *try_get_cpuid(kvm_context_t kvm, int max) -{ - struct kvm_cpuid2 *cpuid; - int r, size; - - size = sizeof(*cpuid) + max * sizeof(*cpuid->entries); - cpuid = qemu_malloc(size); - cpuid->nent = max; - r = kvm_ioctl(kvm_state, KVM_GET_SUPPORTED_CPUID, cpuid); - if (r == 0 && cpuid->nent >= max) - r = -E2BIG; - if (r < 0) { - if (r == -E2BIG) { - free(cpuid); - return NULL; - } else { - fprintf(stderr, "KVM_GET_SUPPORTED_CPUID failed: %s\n", - strerror(-r)); - exit(1); - } - } - return cpuid; -} - -#define R_EAX 0 -#define R_ECX 1 -#define R_EDX 2 -#define R_EBX 3 -#define R_ESP 4 -#define R_EBP 5 -#define R_ESI 6 -#define R_EDI 7 - -uint32_t kvm_get_supported_cpuid(kvm_context_t kvm, uint32_t function, int reg) -{ - struct kvm_cpuid2 *cpuid; - int i, max; - uint32_t ret = 0; - uint32_t cpuid_1_edx; - - if (!kvm_check_extension(kvm_state, KVM_CAP_EXT_CPUID)) { - return -1U; - } - - max = 1; - while ((cpuid = try_get_cpuid(kvm, max)) == NULL) { - max *= 2; - } - - for (i = 0; i < cpuid->nent; ++i) { - if (cpuid->entries[i].function == function) { - switch (reg) { - case R_EAX: - ret = cpuid->entries[i].eax; - break; - case R_EBX: - ret = cpuid->entries[i].ebx; - break; - case R_ECX: - ret = cpuid->entries[i].ecx; - break; - case R_EDX: - ret = cpuid->entries[i].edx; - if (function == 1) { - /* kvm misreports the following features - */ - ret |= 1 << 12; /* MTRR */ - ret |= 1 << 16; /* PAT */ - ret |= 1 << 7; /* MCE */ - ret |= 1 << 14; /* MCA */ - } - - /* On Intel, kvm returns cpuid according to - * the Intel spec, so add missing bits - * according to the AMD spec: - */ - if (function == 0x80000001) { - cpuid_1_edx = kvm_get_supported_cpuid(kvm, 1, R_EDX); - ret |= cpuid_1_edx & 0xdfeff7ff; - } - break; - } - } - } - - free(cpuid); - - return ret; -} - -#else - -uint32_t kvm_get_supported_cpuid(kvm_context_t kvm, uint32_t function, int reg) -{ - return -1U; -} - -#endif int kvm_qemu_create_memory_alias(uint64_t phys_start, uint64_t len, uint64_t target_phys) @@ -1690,12 +1590,6 @@ int kvm_arch_init_irq_routing(void) return 0; } -uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, - int reg) -{ - return kvm_get_supported_cpuid(kvm_context, function, reg); -} - void kvm_arch_process_irqchip_events(CPUState *env) { if (env->interrupt_request & CPU_INTERRUPT_INIT) { diff --git a/qemu-kvm.h b/qemu-kvm.h index 1266a3f..967162c 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -859,8 +859,6 @@ int kvm_assign_set_msix_entry(kvm_context_t kvm, struct kvm_assigned_msix_entry *entry); #endif -uint32_t kvm_get_supported_cpuid(kvm_context_t kvm, uint32_t function, int reg); - #else /* !CONFIG_KVM */ typedef struct kvm_context *kvm_context_t; @@ -1048,9 +1046,6 @@ static inline int kvm_sync_vcpus(void) return 0; } -uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, - int reg); - static inline int kvm_set_migration_log(int enable) { return kvm_physical_memory_set_dirty_tracking(enable); diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 9fb96b5..8743f32 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -25,8 +25,6 @@ #include "gdbstub.h" #include "host-utils.h" -#ifdef KVM_UPSTREAM - #ifdef CONFIG_KVM_PARA #include #endif @@ -133,6 +131,8 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg) #endif +#ifdef KVM_UPSTREAM + static void kvm_trim_features(uint32_t *features, uint32_t supported) { int i;