Skip to content

Commit

Permalink
eal/x86: check rdrand and rdseed
Browse files Browse the repository at this point in the history
The meson build never checked for the presence of rdrand and rdseed
instructions, while make build never checked for rdseed. Ensure builds
always have the appropriate checks - and therefore defines - for these
instructions. For runtime, we also add in rdseed to the list of known
bits returned from cpuid() instruction, so we can confirm its presence at
application init time.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Tested-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
  • Loading branch information
bruce-richardson authored and tmonjalo committed Jun 3, 2019
1 parent a7c5f26 commit ffadd93
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion config/x86/meson.build
Expand Up @@ -29,11 +29,14 @@ foreach f:base_flags
endforeach

optional_flags = ['AES', 'PCLMUL',
'AVX', 'AVX2', 'AVX512F']
'AVX', 'AVX2', 'AVX512F',
'RDRND', 'RDSEED']
foreach f:optional_flags
if cc.get_define('__@0@__'.format(f), args: machine_args) == '1'
if f == 'PCLMUL' # special case flags with different defines
f = 'PCLMULQDQ'
elif f == 'RDRND'
f = 'RDRAND'
endif
dpdk_conf.set('RTE_MACHINE_CPUFLAG_' + f, 1)
compile_time_cpuflags += ['RTE_CPUFLAG_' + f]
Expand Down
1 change: 1 addition & 0 deletions lib/librte_eal/common/arch/x86/rte_cpuflags.c
Expand Up @@ -108,6 +108,7 @@ const struct feature_entry rte_cpu_feature_table[] = {
FEAT_DEF(INVPCID, 0x00000007, 0, RTE_REG_EBX, 10)
FEAT_DEF(RTM, 0x00000007, 0, RTE_REG_EBX, 11)
FEAT_DEF(AVX512F, 0x00000007, 0, RTE_REG_EBX, 16)
FEAT_DEF(RDSEED, 0x00000007, 0, RTE_REG_EBX, 18)

FEAT_DEF(LAHF_SAHF, 0x80000001, 0, RTE_REG_ECX, 0)
FEAT_DEF(LZCNT, 0x80000001, 0, RTE_REG_ECX, 4)
Expand Down
1 change: 1 addition & 0 deletions lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
Expand Up @@ -97,6 +97,7 @@ enum rte_cpu_flag_t {
RTE_CPUFLAG_INVPCID, /**< INVPCID */
RTE_CPUFLAG_RTM, /**< Transactional memory */
RTE_CPUFLAG_AVX512F, /**< AVX512F */
RTE_CPUFLAG_RDSEED, /**< RDSEED instruction */

/* (EAX 80000001h) ECX features */
RTE_CPUFLAG_LAHF_SAHF, /**< LAHF_SAHF */
Expand Down
4 changes: 4 additions & 0 deletions mk/rte.cpuflags.mk
Expand Up @@ -51,6 +51,10 @@ ifneq ($(filter $(AUTO_CPUFLAGS),__RDRND__),)
CPUFLAGS += RDRAND
endif

ifneq ($(filter $(AUTO_CPUFLAGS),__RDSEED__),)
CPUFLAGS += RDSEED
endif

ifneq ($(filter $(AUTO_CPUFLAGS),__FSGSBASE__),)
CPUFLAGS += FSGSBASE
endif
Expand Down

0 comments on commit ffadd93

Please sign in to comment.