diff options
author | Glauber Costa <glommer@redhat.com> | 2010-05-11 12:17:43 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-19 04:41:03 -0400 |
commit | 84478c829d0f474a1d6749207c53daacc305d4e1 (patch) | |
tree | b901fdad494f058ee43ee7946f77ab6922dc8a1b /arch/x86/kvm/x86.c | |
parent | 0e6ac58acbcddbc9d1687214f0d43d8657cc036c (diff) |
KVM: x86: export paravirtual cpuid flags in KVM_GET_SUPPORTED_CPUID
Right now, we were using individual KVM_CAP entities to communicate
userspace about which cpuids we support. This is suboptimal, since it
generates a delay between the feature arriving in the host, and
being available at the guest.
A much better mechanism is to list para features in KVM_GET_SUPPORTED_CPUID.
This makes userspace automatically aware of what we provide. And if we
ever add a new cpuid bit in the future, we have to do that again,
which create some complexity and delay in feature adoption.
Signed-off-by: Glauber Costa <glommer@redhat.com>
Acked-by: Zachary Amsden <zamsden@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 73d342c69ed4..419c4512e270 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -1972,6 +1972,23 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, | |||
1972 | } | 1972 | } |
1973 | break; | 1973 | break; |
1974 | } | 1974 | } |
1975 | case KVM_CPUID_SIGNATURE: { | ||
1976 | char signature[12] = "KVMKVMKVM\0\0"; | ||
1977 | u32 *sigptr = (u32 *)signature; | ||
1978 | entry->eax = 0; | ||
1979 | entry->ebx = sigptr[0]; | ||
1980 | entry->ecx = sigptr[1]; | ||
1981 | entry->edx = sigptr[2]; | ||
1982 | break; | ||
1983 | } | ||
1984 | case KVM_CPUID_FEATURES: | ||
1985 | entry->eax = (1 << KVM_FEATURE_CLOCKSOURCE) | | ||
1986 | (1 << KVM_FEATURE_NOP_IO_DELAY) | | ||
1987 | (1 << KVM_FEATURE_CLOCKSOURCE2); | ||
1988 | entry->ebx = 0; | ||
1989 | entry->ecx = 0; | ||
1990 | entry->edx = 0; | ||
1991 | break; | ||
1975 | case 0x80000000: | 1992 | case 0x80000000: |
1976 | entry->eax = min(entry->eax, 0x8000001a); | 1993 | entry->eax = min(entry->eax, 0x8000001a); |
1977 | break; | 1994 | break; |
@@ -2018,6 +2035,23 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, | |||
2018 | for (func = 0x80000001; func <= limit && nent < cpuid->nent; ++func) | 2035 | for (func = 0x80000001; func <= limit && nent < cpuid->nent; ++func) |
2019 | do_cpuid_ent(&cpuid_entries[nent], func, 0, | 2036 | do_cpuid_ent(&cpuid_entries[nent], func, 0, |
2020 | &nent, cpuid->nent); | 2037 | &nent, cpuid->nent); |
2038 | |||
2039 | |||
2040 | |||
2041 | r = -E2BIG; | ||
2042 | if (nent >= cpuid->nent) | ||
2043 | goto out_free; | ||
2044 | |||
2045 | do_cpuid_ent(&cpuid_entries[nent], KVM_CPUID_SIGNATURE, 0, &nent, | ||
2046 | cpuid->nent); | ||
2047 | |||
2048 | r = -E2BIG; | ||
2049 | if (nent >= cpuid->nent) | ||
2050 | goto out_free; | ||
2051 | |||
2052 | do_cpuid_ent(&cpuid_entries[nent], KVM_CPUID_FEATURES, 0, &nent, | ||
2053 | cpuid->nent); | ||
2054 | |||
2021 | r = -E2BIG; | 2055 | r = -E2BIG; |
2022 | if (nent >= cpuid->nent) | 2056 | if (nent >= cpuid->nent) |
2023 | goto out_free; | 2057 | goto out_free; |