aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--target-i386/kvm.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 7b092ee385..ff92b1d118 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -106,6 +106,8 @@ static int has_xsave;
static int has_xcrs;
static int has_pit_state2;
+static struct kvm_cpuid2 *cpuid_cache;
+
int kvm_has_pit_state2(void)
{
return has_pit_state2;
@@ -199,9 +201,14 @@ static struct kvm_cpuid2 *get_supported_cpuid(KVMState *s)
{
struct kvm_cpuid2 *cpuid;
int max = 1;
+
+ if (cpuid_cache != NULL) {
+ return cpuid_cache;
+ }
while ((cpuid = try_get_cpuid(s, max)) == NULL) {
max *= 2;
}
+ cpuid_cache = cpuid;
return cpuid;
}
@@ -319,8 +326,6 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
ret |= cpuid_1_edx & CPUID_EXT2_AMD_ALIASES;
}
- g_free(cpuid);
-
/* fallback for older kernels */
if ((function == KVM_CPUID_FEATURES) && !found) {
ret = get_para_features(s);