From f155880eda515b8424e4984cb39cdf38946356f2 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Thu, 2 Apr 2015 14:02:57 +0200 Subject: cpu-feature: Add a common class to query available CPU features Currently supported is x86/x64 via cpuid() for some common features. --- src/libstrongswan/utils/cpu_feature.h | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/libstrongswan/utils/cpu_feature.h (limited to 'src/libstrongswan/utils/cpu_feature.h') diff --git a/src/libstrongswan/utils/cpu_feature.h b/src/libstrongswan/utils/cpu_feature.h new file mode 100644 index 000000000..d7300a30a --- /dev/null +++ b/src/libstrongswan/utils/cpu_feature.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2015 Martin Willi + * Copyright (C) 2015 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +/** + * @defgroup cpu_feature cpu_feature + * @{ @ingroup utils + */ + +#ifndef CPU_FEATURE_H_ +#define CPU_FEATURE_H_ + +#include + +typedef enum { + /** x86/x64 extensions */ + CPU_FEATURE_MMX = (1 << 0), + CPU_FEATURE_SSE = (1 << 1), + CPU_FEATURE_SSE2 = (1 << 2), + CPU_FEATURE_SSE3 = (1 << 3), + CPU_FEATURE_SSSE3 = (1 << 4), + CPU_FEATURE_SSE41 = (1 << 5), + CPU_FEATURE_SSE42 = (1 << 6), + CPU_FEATURE_AVX = (1 << 7), + CPU_FEATURE_RDRAND = (1 << 8), + CPU_FEATURE_AESNI = (1 << 9), + CPU_FEATURE_PCLMULQDQ = (1 << 10), +} cpu_feature_t; + +/** + * Get a bitmask for all supported CPU features + */ +cpu_feature_t cpu_feature_get_all(); + +/** + * Check if a given set of CPU features is available. + */ +bool cpu_feature_available(cpu_feature_t feature); + +#endif /** CPU_FEATURE_H_ @}*/ -- cgit v1.2.3 From 793851856bb74191df7f5fd008dd46d83eca8ebc Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Thu, 2 Apr 2015 14:04:57 +0200 Subject: cpu-feature: Support Via Padlock security features --- src/libstrongswan/utils/cpu_feature.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/libstrongswan/utils/cpu_feature.h') diff --git a/src/libstrongswan/utils/cpu_feature.h b/src/libstrongswan/utils/cpu_feature.h index d7300a30a..3a807fa2b 100644 --- a/src/libstrongswan/utils/cpu_feature.h +++ b/src/libstrongswan/utils/cpu_feature.h @@ -36,6 +36,17 @@ typedef enum { CPU_FEATURE_RDRAND = (1 << 8), CPU_FEATURE_AESNI = (1 << 9), CPU_FEATURE_PCLMULQDQ = (1 << 10), + /** Via Padlock Security features */ + CPU_FEATURE_PADLOCK_RNG_AVAILABLE = (1 << 22), + CPU_FEATURE_PADLOCK_RNG_ENABLED = (1 << 23), + CPU_FEATURE_PADLOCK_ACE_AVAILABLE = (1 << 24), + CPU_FEATURE_PADLOCK_ACE_ENABLED = (1 << 25), + CPU_FEATURE_PADLOCK_ACE2_AVAILABLE = (1 << 26), + CPU_FEATURE_PADLOCK_ACE2_ENABLED = (1 << 27), + CPU_FEATURE_PADLOCK_PHE_AVAILABLE = (1 << 28), + CPU_FEATURE_PADLOCK_PHE_ENABLED = (1 << 29), + CPU_FEATURE_PADLOCK_PMM_AVAILABLE = (1 << 30), + CPU_FEATURE_PADLOCK_PMM_ENABLED = (1 << 31), } cpu_feature_t; /** -- cgit v1.2.3