Expose them to assembly code, and replace open-coded versions.
No functional change.
Signed-off-by: Andrew Cooper
---
CC: Jan Beulich
---
xen/arch/x86/boot/head.S | 2 +-
xen/arch/x86/boot/trampoline.S | 2 +-
xen/arch/x86/cpu/common.c| 4 +-
xen/arch/x86/efi/efi-boot.h | 2 +-
xen/arch/x86/hvm/hvm.c | 10 ++---
xen/arch/x86/traps.c | 2 +-
xen/arch/x86/xstate.c| 4 +-
xen/include/asm-x86/amd.h| 89 +++-
xen/include/asm-x86/asm_defns.h | 2 +-
xen/include/asm-x86/cpufeature.h | 7 +++-
10 files changed, 63 insertions(+), 61 deletions(-)
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index f63b349..ac4962b 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -142,7 +142,7 @@ __start:
mov
%edx,sym_phys(boot_cpu_data)+CPUINFO_FEATURE_OFFSET(X86_FEATURE_LM)
/* Check for availability of long mode. */
-bt $X86_FEATURE_LM & 0x1f,%edx
+bt $cpufeat_bit(X86_FEATURE_LM),%edx
jnc bad_cpu
/* Stash TSC to calculate a good approximation of time-since-boot */
diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index 8b0d9c1..c8f32cd 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -89,7 +89,7 @@ trampoline_protmode_entry:
movl$MSR_EFER,%ecx
rdmsr
or $EFER_LME|EFER_SCE,%eax /* Long Mode + SYSCALL/SYSRET */
-bt $X86_FEATURE_NX % 32,%edi /* No Execute? */
+bt $cpufeat_bit(X86_FEATURE_NX),%edi /* No Execute? */
jnc 1f
btsl$_EFER_NX,%eax /* No Execute */
1: wrmsr
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index f256444..a5caa84 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -202,7 +202,7 @@ static void __init early_cpu_detect(void)
c->x86_mask = tfms & 15;
cap0 &= ~cleared_caps[0];
cap4 &= ~cleared_caps[4];
- if (cap0 & (1<<19))
+ if (cap0 & cpufeat_mask(X86_FEATURE_CLFLSH))
c->x86_cache_alignment = ((misc >> 8) & 0xff) * 8;
/* Leaf 0x1 capabilities filled in early for Xen. */
c->x86_capability[0] = cap0;
@@ -263,7 +263,7 @@ static void __cpuinit generic_identify(struct cpuinfo_x86
*c)
if ( c->cpuid_level >= 0x0007 ) {
u32 dummy;
cpuid_count(0x0007, 0, &dummy, &ebx, &dummy, &dummy);
- c->x86_capability[X86_FEATURE_FSGSBASE / 32] = ebx;
+ c->x86_capability[cpufeat_word(X86_FEATURE_FSGSBASE)] = ebx;
}
}
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 4c7f383..d8ca862 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -225,7 +225,7 @@ static void __init noreturn efi_arch_post_exit_boot(void)
asm volatile("pushq $0\n\tpopfq");
rdmsrl(MSR_EFER, efer);
efer |= EFER_SCE;
-if ( cpuid_ext_features & (1 << (X86_FEATURE_NX & 0x1f)) )
+if ( cpuid_ext_features & cpufeat_mask(X86_FEATURE_NX) )
efer |= EFER_NX;
wrmsrl(MSR_EFER, efer);
write_cr0(X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP |
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 3fa2280..965bfbf 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1850,8 +1850,8 @@ static const char * hvm_efer_valid(const struct vcpu *v,
uint64_t value,
}
else
{
-ext1_edx = boot_cpu_data.x86_capability[X86_FEATURE_LM / 32];
-ext1_ecx = boot_cpu_data.x86_capability[X86_FEATURE_SVM / 32];
+ext1_edx = boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_LM)];
+ext1_ecx = boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_SVM)];
}
/*
@@ -1917,9 +1917,9 @@ static unsigned long hvm_cr4_guest_reserved_bits(const
struct vcpu *v,
}
else
{
-leaf1_edx = boot_cpu_data.x86_capability[X86_FEATURE_VME / 32];
-leaf1_ecx = boot_cpu_data.x86_capability[X86_FEATURE_PCID / 32];
-leaf7_0_ebx = boot_cpu_data.x86_capability[X86_FEATURE_FSGSBASE / 32];
+leaf1_edx =
boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_VME)];
+leaf1_ecx =
boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_PCID)];
+leaf7_0_ebx =
boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_FSGSBASE)];
}
return ~(unsigned long)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 8093535..b32f696 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -935,7 +935,7 @@ void pv_cpuid(struct cpu_user_regs *regs)
goto unsupported;
if ( regs->_ecx == 1 )
{
-a &= boot_cpu_data.x86_capability[X86_FEATURE_XSAVEOPT / 32];
+a &=
boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_XSAVEOPT)];
if (