x86: Replace ad-hoc bitmaskof() macro with single cpufeat_mask() defn.

Signed-off-by: Keir Fraser <keir@xen.org>
This commit is contained in:
Keir Fraser committed 2011-06-02 14:34:34 +01:00
1 parent e894fe2367
commit 7a21e8ea1d
4 files changed
+7 -9

No files matched your search

+4 -5
View File
@@ -2380,7 +2380,6 @@ unsigned long copy_from_user_hvm(void *to, const void *from, unsigned len)
return rc ? len : 0; /* fake a copy_from_user() return code */
}
#define bitmaskof(idx) (1U << ((idx) & 31))
void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
{
@@ -2407,7 +2406,7 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
/* Fix up OSXSAVE. */
if ( xsave_enabled(v) )
*ecx |= (v->arch.hvm_vcpu.guest_cr[4] & X86_CR4_OSXSAVE) ?
bitmaskof(X86_FEATURE_OSXSAVE) : 0;
cpufeat_mask(X86_FEATURE_OSXSAVE) : 0;
break;
case 0xb:
/* Fix the x2APIC identifier. */
@@ -2438,7 +2437,7 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
tsc_mode == TSC_MODE_DEFAULT and host_tsc_is_safe() returns 1 */
if ( v->domain->arch.tsc_mode != TSC_MODE_DEFAULT ||
!host_tsc_is_safe() )
*edx &= ~bitmaskof(X86_FEATURE_RDTSCP);
*edx &= ~cpufeat_mask(X86_FEATURE_RDTSCP);
break;
}
}
@@ -2467,7 +2466,7 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content)
fixed_range_base = (uint64_t *)v->arch.hvm_vcpu.mtrr.fixed_ranges;
hvm_cpuid(1, &cpuid[0], &cpuid[1], &cpuid[2], &cpuid[3]);
mtrr = !!(cpuid[3] & bitmaskof(X86_FEATURE_MTRR));
mtrr = !!(cpuid[3] & cpufeat_mask(X86_FEATURE_MTRR));
switch ( msr )
{
@@ -2579,7 +2578,7 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content)
(uint32_t)msr_content, (uint32_t)(msr_content >> 32));
hvm_cpuid(1, &cpuid[0], &cpuid[1], &cpuid[2], &cpuid[3]);
mtrr = !!(cpuid[3] & bitmaskof(X86_FEATURE_MTRR));
mtrr = !!(cpuid[3] & cpufeat_mask(X86_FEATURE_MTRR));
switch ( msr )
{
-1
View File
@@ -1190,7 +1190,6 @@ static void svm_fpu_dirty_intercept(void)
vmcb_set_cr0(vmcb, vmcb_get_cr0(vmcb) & ~X86_CR0_TS);
}
#define bitmaskof(idx) (1U << ((idx) & 31))
static void svm_cpuid_intercept(
unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
+2 -3
View File
@@ -1487,7 +1487,6 @@ static void vmx_fpu_dirty_intercept(void)
}
}
#define bitmaskof(idx) (1U << ((idx) & 31))
static void vmx_cpuid_intercept(
unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
@@ -1504,9 +1503,9 @@ static void vmx_cpuid_intercept(
/* SYSCALL is visible iff running in long mode. */
hvm_get_segment_register(v, x86_seg_cs, &cs);
if ( cs.attr.fields.l )
*edx |= bitmaskof(X86_FEATURE_SYSCALL);
*edx |= cpufeat_mask(X86_FEATURE_SYSCALL);
else
*edx &= ~(bitmaskof(X86_FEATURE_SYSCALL));
*edx &= ~(cpufeat_mask(X86_FEATURE_SYSCALL));
break;
}
+1
View File
@@ -146,6 +146,7 @@
#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability)
#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)
#define cpufeat_mask(idx) (1u << ((idx) & 31))
#ifdef __i386__
#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.