Commit 5c404cab authored by Paolo Bonzini's avatar Paolo Bonzini

KVM: x86: use F() macro throughout cpuid.c

For code that deals with cpuid, this makes things a bit more readable.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent df1daba7
...@@ -53,6 +53,8 @@ u64 kvm_supported_xcr0(void) ...@@ -53,6 +53,8 @@ u64 kvm_supported_xcr0(void)
return xcr0; return xcr0;
} }
#define F(x) bit(X86_FEATURE_##x)
int kvm_update_cpuid(struct kvm_vcpu *vcpu) int kvm_update_cpuid(struct kvm_vcpu *vcpu)
{ {
struct kvm_cpuid_entry2 *best; struct kvm_cpuid_entry2 *best;
...@@ -64,13 +66,13 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu) ...@@ -64,13 +66,13 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu)
/* Update OSXSAVE bit */ /* Update OSXSAVE bit */
if (cpu_has_xsave && best->function == 0x1) { if (cpu_has_xsave && best->function == 0x1) {
best->ecx &= ~(bit(X86_FEATURE_OSXSAVE)); best->ecx &= ~F(OSXSAVE);
if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE)) if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE))
best->ecx |= bit(X86_FEATURE_OSXSAVE); best->ecx |= F(OSXSAVE);
} }
if (apic) { if (apic) {
if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER)) if (best->ecx & F(TSC_DEADLINE_TIMER))
apic->lapic_timer.timer_mode_mask = 3 << 17; apic->lapic_timer.timer_mode_mask = 3 << 17;
else else
apic->lapic_timer.timer_mode_mask = 1 << 17; apic->lapic_timer.timer_mode_mask = 1 << 17;
...@@ -122,8 +124,8 @@ static void cpuid_fix_nx_cap(struct kvm_vcpu *vcpu) ...@@ -122,8 +124,8 @@ static void cpuid_fix_nx_cap(struct kvm_vcpu *vcpu)
break; break;
} }
} }
if (entry && (entry->edx & bit(X86_FEATURE_NX)) && !is_efer_nx()) { if (entry && (entry->edx & F(NX)) && !is_efer_nx()) {
entry->edx &= ~bit(X86_FEATURE_NX); entry->edx &= ~F(NX);
printk(KERN_INFO "kvm: guest NX capability removed\n"); printk(KERN_INFO "kvm: guest NX capability removed\n");
} }
} }
...@@ -227,8 +229,6 @@ static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function, ...@@ -227,8 +229,6 @@ static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function,
entry->flags = 0; entry->flags = 0;
} }
#define F(x) bit(X86_FEATURE_##x)
static int __do_cpuid_ent_emulated(struct kvm_cpuid_entry2 *entry, static int __do_cpuid_ent_emulated(struct kvm_cpuid_entry2 *entry,
u32 func, u32 index, int *nent, int maxnent) u32 func, u32 index, int *nent, int maxnent)
{ {
......
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