aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-07-27 13:29:32 +0000
committerlloyd <[email protected]>2010-07-27 13:29:32 +0000
commitafa1f82524d11574f19a713b16fe2809b4665db4 (patch)
tree76837831edbca7c02a60e6cfe8469886e03a4c58
parent0cbb71fc33ac56c584bdd4574082a974e79d67f1 (diff)
Add support in CPUID for detecting PCMULUDQ and MOVBE instructions.
Rename CPUID::has_aes_intel to has_aes_ni.
-rw-r--r--doc/examples/cpuid.cpp9
-rw-r--r--src/engine/aes_isa_eng/aes_isa_engine.cpp2
-rw-r--r--src/utils/cpuid.h22
3 files changed, 23 insertions, 10 deletions
diff --git a/doc/examples/cpuid.cpp b/doc/examples/cpuid.cpp
index 059cfdbc0..3693257b8 100644
--- a/doc/examples/cpuid.cpp
+++ b/doc/examples/cpuid.cpp
@@ -13,10 +13,7 @@ namespace {
void print_if_feature(const std::string& feature_name, bool exists)
{
- if(exists)
- std::cout << "Y: " << feature_name << "\n";
- else
- std::cout << "N: " << feature_name << "\n";
+ std::cout << (exists ? '+' : '-') << " " << feature_name << "\n";
}
}
@@ -34,7 +31,9 @@ int main()
print_if_feature("SSE4.2", CPUID::has_sse42());
print_if_feature("AVX", CPUID::has_avx());
- print_if_feature("AES-NI", CPUID::has_aes_intel());
+ print_if_feature("MOVBE", CPUID::has_movbe());
+ print_if_feature("PCMUL", CPUID::has_pcmuludq());
+ print_if_feature("AES-NI", CPUID::has_aes_ni());
print_if_feature("AltiVec", CPUID::has_altivec());
}
diff --git a/src/engine/aes_isa_eng/aes_isa_engine.cpp b/src/engine/aes_isa_eng/aes_isa_engine.cpp
index 682dfe6b1..7f541d583 100644
--- a/src/engine/aes_isa_eng/aes_isa_engine.cpp
+++ b/src/engine/aes_isa_eng/aes_isa_engine.cpp
@@ -19,7 +19,7 @@ AES_ISA_Engine::find_block_cipher(const SCAN_Name& request,
Algorithm_Factory&) const
{
#if defined(BOTAN_HAS_AES_INTEL)
- if(CPUID::has_aes_intel())
+ if(CPUID::has_aes_ni())
{
if(request.algo_name() == "AES-128")
return new AES_128_Intel;
diff --git a/src/utils/cpuid.h b/src/utils/cpuid.h
index 6339a0117..6cb4092bb 100644
--- a/src/utils/cpuid.h
+++ b/src/utils/cpuid.h
@@ -65,10 +65,22 @@ class BOTAN_DLL CPUID
{ return x86_processor_flags_has(CPUID_AVX_BIT); }
/**
- * Check if the processor supports Intel's AES instructions
+ * Check if the processor supports AES-NI
*/
- static bool has_aes_intel()
- { return x86_processor_flags_has(CPUID_INTEL_AES_BIT); }
+ static bool has_aes_ni()
+ { return x86_processor_flags_has(CPUID_AESNI_BIT); }
+
+ /**
+ * Check if the processor supports PCMULUDQ
+ */
+ static bool has_pcmuludq()
+ { return x86_processor_flags_has(CPUID_PCMUL_BIT); }
+
+ /**
+ * Check if the processor supports MOVBE
+ */
+ static bool has_movbe()
+ { return x86_processor_flags_has(CPUID_MOVBE_BIT); }
/**
* Check if the processor supports AltiVec/VMX
@@ -78,10 +90,12 @@ class BOTAN_DLL CPUID
enum CPUID_bits {
CPUID_RDTSC_BIT = 4,
CPUID_SSE2_BIT = 26,
+ CPUID_PCMUL_BIT = 33,
CPUID_SSSE3_BIT = 41,
CPUID_SSE41_BIT = 51,
CPUID_SSE42_BIT = 52,
- CPUID_INTEL_AES_BIT = 57,
+ CPUID_MOVBE_BIT = 54,
+ CPUID_AESNI_BIT = 57,
CPUID_AVX_BIT = 60
};