diff options
author | Avi Kivity <avi@redhat.com> | 2010-11-09 09:15:43 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-01-12 04:29:17 -0500 |
commit | 945ee35e0764a834bc5bc5d572085d5b6409902a (patch) | |
tree | e2ecb853b8bca8a20261bd652fa71d05309da226 | |
parent | 2a6b20b83d1d37db57a9c25d99dc78454ad0747b (diff) |
KVM: Mask KVM_GET_SUPPORTED_CPUID data with Linux cpuid info
This allows Linux to mask cpuid bits if, for example, nx is enabled on only
some cpus.
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | arch/x86/kvm/x86.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c673e726fbdb..651cf9004fbe 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -2227,6 +2227,11 @@ out: | |||
2227 | return r; | 2227 | return r; |
2228 | } | 2228 | } |
2229 | 2229 | ||
2230 | static void cpuid_mask(u32 *word, int wordnum) | ||
2231 | { | ||
2232 | *word &= boot_cpu_data.x86_capability[wordnum]; | ||
2233 | } | ||
2234 | |||
2230 | static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function, | 2235 | static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function, |
2231 | u32 index) | 2236 | u32 index) |
2232 | { | 2237 | { |
@@ -2301,7 +2306,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, | |||
2301 | break; | 2306 | break; |
2302 | case 1: | 2307 | case 1: |
2303 | entry->edx &= kvm_supported_word0_x86_features; | 2308 | entry->edx &= kvm_supported_word0_x86_features; |
2309 | cpuid_mask(&entry->edx, 0); | ||
2304 | entry->ecx &= kvm_supported_word4_x86_features; | 2310 | entry->ecx &= kvm_supported_word4_x86_features; |
2311 | cpuid_mask(&entry->ecx, 4); | ||
2305 | /* we support x2apic emulation even if host does not support | 2312 | /* we support x2apic emulation even if host does not support |
2306 | * it since we emulate x2apic in software */ | 2313 | * it since we emulate x2apic in software */ |
2307 | entry->ecx |= F(X2APIC); | 2314 | entry->ecx |= F(X2APIC); |
@@ -2392,7 +2399,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, | |||
2392 | break; | 2399 | break; |
2393 | case 0x80000001: | 2400 | case 0x80000001: |
2394 | entry->edx &= kvm_supported_word1_x86_features; | 2401 | entry->edx &= kvm_supported_word1_x86_features; |
2402 | cpuid_mask(&entry->edx, 1); | ||
2395 | entry->ecx &= kvm_supported_word6_x86_features; | 2403 | entry->ecx &= kvm_supported_word6_x86_features; |
2404 | cpuid_mask(&entry->ecx, 6); | ||
2396 | break; | 2405 | break; |
2397 | } | 2406 | } |
2398 | 2407 | ||