Commit 945ee35e authored by Avi Kivity's avatar Avi Kivity

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: default avatarAvi Kivity <avi@redhat.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 2a6b20b8
...@@ -2227,6 +2227,11 @@ static int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu, ...@@ -2227,6 +2227,11 @@ static int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
return r; return r;
} }
static void cpuid_mask(u32 *word, int wordnum)
{
*word &= boot_cpu_data.x86_capability[wordnum];
}
static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function, static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function,
u32 index) u32 index)
{ {
...@@ -2301,7 +2306,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, ...@@ -2301,7 +2306,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
break; break;
case 1: case 1:
entry->edx &= kvm_supported_word0_x86_features; entry->edx &= kvm_supported_word0_x86_features;
cpuid_mask(&entry->edx, 0);
entry->ecx &= kvm_supported_word4_x86_features; entry->ecx &= kvm_supported_word4_x86_features;
cpuid_mask(&entry->ecx, 4);
/* we support x2apic emulation even if host does not support /* we support x2apic emulation even if host does not support
* it since we emulate x2apic in software */ * it since we emulate x2apic in software */
entry->ecx |= F(X2APIC); entry->ecx |= F(X2APIC);
...@@ -2392,7 +2399,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, ...@@ -2392,7 +2399,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
break; break;
case 0x80000001: case 0x80000001:
entry->edx &= kvm_supported_word1_x86_features; entry->edx &= kvm_supported_word1_x86_features;
cpuid_mask(&entry->edx, 1);
entry->ecx &= kvm_supported_word6_x86_features; entry->ecx &= kvm_supported_word6_x86_features;
cpuid_mask(&entry->ecx, 6);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment