eal: abstract away the auxiliary vector
PATCH 1/1 eal: abstract away the auxiliary vector
Rather than attempting to load the contents of the auxv directly, prefer to use an exposed API - and if that doesn't exist then attempt to load the vector. This is because on some systems, when a user is downgraded, the /proc/self/auxv file retains the old ownership and permissions. The original method of /proc/self/auxv is retained.
This also removes a potential abort() in the code when compiled with NDEBUG. A quick parse of the code shows that many (if not all) of the CPU flag parsing isn't used internally, so it should be okay.
---
NOTE: These APIs aren't added to the map because I really want
them to be internal-only. No other component really needs access to them. I couldn't find a good common internal include file which is why they're in the rte_cpuflags.h - but if there's a better one, we can spin another version.
lib/librte_eal/common/arch/arm/rte_cpuflags.c | 20 ++---- lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c | 15 +---- lib/librte_eal/common/eal_common_cpuflags.c | 76 ++++++++++++++++++++++ .../common/include/generic/rte_cpuflags.h | 13 ++++ 4 files changed, 95 insertions(+), 29 deletions(-)
lib/librte_eal/common/arch/arm/rte_cpuflags.c +4 -16
@@ -133,22 +133,10 @@ const struct feature_entry rte_cpu_feature_table[] = {static void rte_cpu_get_features (hwcap_registers_t out) { -int auxv_fd; -_Elfx_auxv_t auxv; - - auxv_fd =open ("/proc/self/auxv" ,O_RDONLY ); -assert (auxv_fd !=-1 ); -while (read (auxv_fd, &auxv,sizeof (auxv)) ==sizeof (auxv)) { -if (auxv.a_type ==AT_HWCAP ) { - out[REG_HWCAP ] = auxv.a_un.a_val; - }else if (auxv.a_type ==AT_HWCAP2 ) { - out[REG_HWCAP2 ] = auxv.a_un.a_val; - }else if (auxv.a_type ==AT_PLATFORM ) { -if (!strcmp ((const char *)auxv.a_un.a_val,PLATFORM_STR )) - out[REG_PLATFORM ] =0x0001 ; - } - } -close (auxv_fd); + out[REG_HWCAP ] =rte_cpu_getauxval (AT_HWCAP ); + out[REG_HWCAP2 ] =rte_cpu_getauxval (AT_HWCAP2 ); +if (!rte_cpu_strcmp_auxval (AT_PLATFORM ,PLATFORM_STR )) + out[REG_PLATFORM ] =0x0001 ; }/*
lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c +2 -13
@@ -104,19 +104,8 @@ const struct feature_entry rte_cpu_feature_table[] = {static void rte_cpu_get_features (hwcap_registers_t out) { -int auxv_fd; -Elf64_auxv_t auxv; - - auxv_fd =open ("/proc/self/auxv" ,O_RDONLY ); -assert (auxv_fd !=-1 ); -while (read (auxv_fd, &auxv, -sizeof (Elf64_auxv_t)) ==sizeof (Elf64_auxv_t)) { -if (auxv.a_type ==AT_HWCAP ) - out[REG_HWCAP ] = auxv.a_un.a_val; -else if (auxv.a_type ==AT_HWCAP2 ) - out[REG_HWCAP2 ] = auxv.a_un.a_val; - } -close (auxv_fd); + out[REG_HWCAP ] =rte_cpu_getauxval (AT_HWCAP ); + out[REG_HWCAP2 ] =rte_cpu_getauxval (AT_HWCAP2 ); }/*
lib/librte_eal/common/eal_common_cpuflags.c +76 -0
87 lines not on this page · raw message
lib/librte_eal/common/include/generic/rte_cpuflags.h +13 -0
@@ -64,4 +64,17 @@ rte_cpu_check_supported(void);int rte_cpu_is_supported (void ); +/** +* This function attempts to retrieve a value from the auxiliary vector. +*/ +unsigned long +rte_cpu_getauxval (unsigned long type); + +/** +* This function retrieves a value from the auxiliary vector, and compares it +* as a string. +*/ +int +rte_cpu_strcmp_auxval (unsigned long type,const char *str); +#endif /* _RTE_CPUFLAGS_H_ */
Signature · 1 line
2.14.3
Quoted 47 lines · Aaron Conole
Rather than attempting to load the contents of the auxv directly, prefer to use an exposed API - and if that doesn't exist then attempt to load the vector. This is because on some systems, when a user is downgraded, the
/proc/self/auxvfile retains the old ownership and permissions. The original method of/proc/self/auxvis retained.This also removes a potential
abort()in the code when compiled with NDEBUG. A quick parse of the code shows that many (if not all) of the CPU flag parsing isn't used internally, so it should be okay.Signed-off-by Aaron Conole <[email protected]>Signed-off-by Timothy Redaelli <[email protected]>---
NOTE: These APIs aren't added to the map because I really want
them to be internal-only. No other component really needs access to them. I couldn't find a good common internal include file which is why they're in therte_cpuflags.h- but if there's a better one, we can spin another version.lib/librte_eal/common/arch/arm/rte_cpuflags.c | 20 ++---- lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c | 15 +---- lib/librte_eal/common/eal_common_cpuflags.c | 76 ++++++++++++++++++++++ .../common/include/generic/rte_cpuflags.h | 13 ++++ 4 files changed, 95 insertions(+), 29 deletions(-)lib/librte_eal/common/arch/arm/rte_cpuflags.c +0
-0@@ -133,22 +133,10 @@ const struct feature_entry rte_cpu_feature_table[] = {static void
rte_cpu_get_features(hwcap_registers_t out)
{lib/librte_eal/common/arch/arm/rte_cpuflags.c +0
-10-int auxv_fd; -_Elfx_auxv_t auxv; - - auxv_fd =open ("/proc/self/auxv" ,O_RDONLY ); -assert (auxv_fd !=-1 ); -while (read (auxv_fd, &auxv,sizeof (auxv)) ==sizeof (auxv)) { -if (auxv.a_type ==AT_HWCAP ) { - out[REG_HWCAP ] = auxv.a_un.a_val; - }else if (auxv.a_type ==AT_HWCAP2 ) { - out[REG_HWCAP2 ] = auxv.a_un.a_val;
lib/librte_eal/common/arch/arm/rte_cpuflags.c const struct feature_entry rte_cpu_feature_table[] = { · line 139
Quoted 10 lines
lib/librte_eal/common/arch/arm/rte_cpuflags.c +4
-6- }else if (auxv.a_type ==AT_PLATFORM ) { -if (!strcmp ((const char *)auxv.a_un.a_val,PLATFORM_STR )) - out[REG_PLATFORM ] =0x0001 ; - } - } -close (auxv_fd); + out[REG_HWCAP ] =rte_cpu_getauxval (AT_HWCAP ); + out[REG_HWCAP2 ] =rte_cpu_getauxval (AT_HWCAP2 ); +if (!rte_cpu_strcmp_auxval (AT_PLATFORM ,PLATFORM_STR )) + out[REG_PLATFORM ] =0x0001 ;
I like the way you reduced this code here, which does make a lot of sense.
Quoted 64 lines
}
/*
lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c +0
-0@@ -104,19 +104,8 @@ const struct feature_entry rte_cpu_feature_table[] = {static void
rte_cpu_get_features(hwcap_registers_t out)
{lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c +2
-13-int auxv_fd; -Elf64_auxv_t auxv; - - auxv_fd =open ("/proc/self/auxv" ,O_RDONLY ); -assert (auxv_fd !=-1 ); -while (read (auxv_fd, &auxv, -sizeof (Elf64_auxv_t)) ==sizeof (Elf64_auxv_t)) { -if (auxv.a_type ==AT_HWCAP ) - out[REG_HWCAP ] = auxv.a_un.a_val; -else if (auxv.a_type ==AT_HWCAP2 ) - out[REG_HWCAP2 ] = auxv.a_un.a_val; - } -close (auxv_fd); + out[REG_HWCAP ] =rte_cpu_getauxval (AT_HWCAP ); + out[REG_HWCAP2 ] =rte_cpu_getauxval (AT_HWCAP2 );}
/*
lib/librte_eal/common/eal_common_cpuflags.c +22
-0@@ -2,11 +2,87 @@* Copyright(c) 2010-2014 Intel Corporation */ +#include <elf.h> +#include <fcntl.h> #include <stdio.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> + +#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) +#if __GLIBC_PREREQ (2 ,16 ) +#include <sys/auxv.h> +#define HAS_AUXV 1 +#endif +#endif #include <rte_common.h> #include <rte_cpuflags.h> +#ifndef HAS_AUXV +static unsigned long +getauxval (unsigned long type) +{ + errno =ENOTSUP ; +return 0 ; +} +#endif +
lib/librte_eal/common/eal_common_cpuflags.c line 41
Quoted 10 lines
lib/librte_eal/common/eal_common_cpuflags.c +10
-0+#if RTE_ARCH_64 +typedef Elf64_auxv_t Internal_Elfx_auxv_t ; +#else +typedef Elf32_auxv_t Internal_Elfx_auxv_t ; +#endif + + +/** +* Provides a method for retrieving values from the auxiliary vector and +* possibly running a string comparison.
Need to add more docs here as zero is not the normal error return value, same for header file. Please add the correct doxygen formats.
lib/librte_eal/common/eal_common_cpuflags.c line 44
Quoted 3 lines
lib/librte_eal/common/eal_common_cpuflags.c +3
-0+*/ +static unsigned long +_rte_cpu_getauxval (unsigned long type,int cmp_str,const char *str)
Can we not remove cmp_str and just test for str != NULL to compare strings. This would be cleaner IMO.
lib/librte_eal/common/eal_common_cpuflags.c line 52
Quoted 8 lines
lib/librte_eal/common/eal_common_cpuflags.c +8
-0+{ +unsigned long val; + + errno =0 ; + val =getauxval (type); + +if (!val && (errno ==ENOTSUP || errno ==ENOENT )) { +Internal_Elfx_auxv_t auxv;
Should we set auxv = { 0 }; here, maybe not required.
lib/librte_eal/common/eal_common_cpuflags.c line 64
Quoted 12 lines
lib/librte_eal/common/eal_common_cpuflags.c +12
-0+int auxv_fd =open ("/proc/self/auxv" ,O_RDONLY ); + + errno =ENOENT ; +if (auxv_fd ==-1 ) +return 0 ; + +while (read (auxv_fd, &auxv,sizeof (auxv)) ==sizeof (auxv)) { +if (auxv.a_type == type) { + errno =0 ; + val = auxv.a_un.a_val; +if (cmp_str) + val =strcmp ((const char *)val, str);
Does this need to be case sensitive or should we use strcasecmp() instead.
Quoted 32 lines
lib/librte_eal/common/eal_common_cpuflags.c +21
-0+break ; + } + } +close (auxv_fd); + } + +return val; +} + +unsigned long +rte_cpu_getauxval (unsigned long type) +{ +return _rte_cpu_getauxval (type,0 ,NULL ); +} + +int +rte_cpu_strcmp_auxval (unsigned long type,const char *str) +{ +return _rte_cpu_getauxval (type,1 , str); +} +/** * Checks if the machine is adequate for running the binary. If it is not, the * program exits with status 1. lib/librte_eal/common/include/generic/rte_cpuflags.h +0
-0@@ -64,4 +64,17 @@ rte_cpu_check_supported(void);int
rte_cpu_is_supported(void);
Quoted 2 lines
+/**
+ * This function attempts to retrieve a value from the auxiliary vector.
Document the return value here as it is not the normal -1 value on error, same for the next one. And the doxygen formats too.
Quoted 11 lines
+ */
lib/librte_eal/common/include/generic/rte_cpuflags.h +10
-0+unsigned long +rte_cpu_getauxval (unsigned long type); + +/** +* This function retrieves a value from the auxiliary vector, and compares it +* as a string. +*/ +int +rte_cpu_strcmp_auxval (unsigned long type,const char *str); +
Quoted 4 lines
#endif /* _RTE_CPUFLAGS_H_ */
Signature · 1 line
2.14.3
Regards,
Keith
Quoted 130 lines · Keith
Quoted 46 lines · Aaron Conole
Rather than attempting to load the contents of the auxv directly, prefer to use an exposed API - and if that doesn't exist then attempt to load the vector. This is because on some systems, when a user is downgraded, the
/proc/self/auxvfile retains the old ownership and permissions. The original method of/proc/self/auxvis retained.This also removes a potential
abort()in the code when compiled with NDEBUG. A quick parse of the code shows that many (if not all) of the CPU flag parsing isn't used internally, so it should be okay.Signed-off-by Aaron Conole <[email protected]>Signed-off-by Timothy Redaelli <[email protected]>---
NOTE: These APIs aren't added to the map because I really want
them to be internal-only. No other component really needs access to them. I couldn't find a good common internal include file which is why they're in therte_cpuflags.h- but if there's a better one, we can spin another version.lib/librte_eal/common/arch/arm/rte_cpuflags.c | 20 ++---- lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c | 15 +---- lib/librte_eal/common/eal_common_cpuflags.c | 76 ++++++++++++++++++++++ .../common/include/generic/rte_cpuflags.h | 13 ++++ 4 files changed, 95 insertions(+), 29 deletions(-)lib/librte_eal/common/arch/arm/rte_cpuflags.c +0
-0@@ -133,22 +133,10 @@ const struct feature_entry rte_cpu_feature_table[] = {static void
rte_cpu_get_features(hwcap_registers_t out)
{lib/librte_eal/common/arch/arm/rte_cpuflags.c +0
-10-int auxv_fd; -_Elfx_auxv_t auxv; - - auxv_fd =open ("/proc/self/auxv" ,O_RDONLY ); -assert (auxv_fd !=-1 ); -while (read (auxv_fd, &auxv,sizeof (auxv)) ==sizeof (auxv)) { -if (auxv.a_type ==AT_HWCAP ) { - out[REG_HWCAP ] = auxv.a_un.a_val; - }else if (auxv.a_type ==AT_HWCAP2 ) { - out[REG_HWCAP2 ] = auxv.a_un.a_val;lib/librte_eal/common/arch/arm/rte_cpuflags.c const struct feature_entry rte_cpu_feature_table[] = { · line 139
Quoted 10 lines
lib/librte_eal/common/arch/arm/rte_cpuflags.c +4
-6- }else if (auxv.a_type ==AT_PLATFORM ) { -if (!strcmp ((const char *)auxv.a_un.a_val,PLATFORM_STR )) - out[REG_PLATFORM ] =0x0001 ; - } - } -close (auxv_fd); + out[REG_HWCAP ] =rte_cpu_getauxval (AT_HWCAP ); + out[REG_HWCAP2 ] =rte_cpu_getauxval (AT_HWCAP2 ); +if (!rte_cpu_strcmp_auxval (AT_PLATFORM ,PLATFORM_STR )) + out[REG_PLATFORM ] =0x0001 ;I like the way you reduced this code here, which does make a lot of sense.
Quoted 71 lines
}
/*
lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c +0
-0@@ -104,19 +104,8 @@ const struct feature_entry rte_cpu_feature_table[] = {static void
rte_cpu_get_features(hwcap_registers_t out)
{lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c +2
-13-int auxv_fd; -Elf64_auxv_t auxv; - - auxv_fd =open ("/proc/self/auxv" ,O_RDONLY ); -assert (auxv_fd !=-1 ); -while (read (auxv_fd, &auxv, -sizeof (Elf64_auxv_t)) ==sizeof (Elf64_auxv_t)) { -if (auxv.a_type ==AT_HWCAP ) - out[REG_HWCAP ] = auxv.a_un.a_val; -else if (auxv.a_type ==AT_HWCAP2 ) - out[REG_HWCAP2 ] = auxv.a_un.a_val; - } -close (auxv_fd); + out[REG_HWCAP ] =rte_cpu_getauxval (AT_HWCAP ); + out[REG_HWCAP2 ] =rte_cpu_getauxval (AT_HWCAP2 );}
/*
lib/librte_eal/common/eal_common_cpuflags.c +27
-0@@ -2,11 +2,87 @@* Copyright(c) 2010-2014 Intel Corporation */ +#include <elf.h> +#include <fcntl.h> #include <stdio.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> + +#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) +#if __GLIBC_PREREQ (2 ,16 ) +#include <sys/auxv.h> +#define HAS_AUXV 1 +#endif +#endif #include <rte_common.h> #include <rte_cpuflags.h> +#ifndef HAS_AUXV +static unsigned long +getauxval (unsigned long type) +{ + errno =ENOTSUP ; +return 0 ; +} +#endif + +#if RTE_ARCH_64 +typedef Elf64_auxv_t Internal_Elfx_auxv_t ; +#else +typedef Elf32_auxv_t Internal_Elfx_auxv_t ; +#endif
Quoted 8 lines
lib/librte_eal/common/eal_common_cpuflags.c line 41
Quoted 5 lines
lib/librte_eal/common/eal_common_cpuflags.c +5
-0+ + +/** +* Provides a method for retrieving values from the auxiliary vector and +* possibly running a string comparison. Need to add more docs here as zero is not the normal error return value, same for header file. Please add the correct doxygen formats.
Will do.
Quoted 6 lines
lib/librte_eal/common/eal_common_cpuflags.c line 44
Quoted 3 lines
lib/librte_eal/common/eal_common_cpuflags.c +3
-0+*/ +static unsigned long +_rte_cpu_getauxval (unsigned long type,int cmp_str,const char *str)Can we not remove
cmp_strand just test for str != NULL to compare strings. This would be cleaner IMO.
Agreed - will fix in v2.
Quoted 10 lines
lib/librte_eal/common/eal_common_cpuflags.c line 52
Quoted 8 lines
lib/librte_eal/common/eal_common_cpuflags.c +8
-0+{ +unsigned long val; + + errno =0 ; + val =getauxval (type); + +if (!val && (errno ==ENOTSUP || errno ==ENOENT )) { +Internal_Elfx_auxv_t auxv;Should we set auxv = { 0 }; here, maybe not required.
It shouldn't be needed because we read() into it before ever using it as an r-value.
Quoted 7 lines
Quoted 7 lines
lib/librte_eal/common/eal_common_cpuflags.c +7
-0+int auxv_fd =open ("/proc/self/auxv" ,O_RDONLY ); + + errno =ENOENT ; +if (auxv_fd ==-1 ) +return 0 ; + +while (read (auxv_fd, &auxv,sizeof (auxv)) ==sizeof (auxv)) {
Quoted 8 lines
lib/librte_eal/common/eal_common_cpuflags.c line 64
Quoted 5 lines
lib/librte_eal/common/eal_common_cpuflags.c +5
-0+if (auxv.a_type == type) { + errno =0 ; + val = auxv.a_un.a_val; +if (cmp_str) + val =strcmp ((const char *)val, str);Does this need to be case sensitive or should we use
strcasecmp()instead.
The original code was case sensitive, so I left it. I'd rather not introduce a functional change like that in this patch.
Quoted 33 lines
Quoted 33 lines
lib/librte_eal/common/eal_common_cpuflags.c +21
-0+break ; + } + } +close (auxv_fd); + } + +return val; +} + +unsigned long +rte_cpu_getauxval (unsigned long type) +{ +return _rte_cpu_getauxval (type,0 ,NULL ); +} + +int +rte_cpu_strcmp_auxval (unsigned long type,const char *str) +{ +return _rte_cpu_getauxval (type,1 , str); +} +/** * Checks if the machine is adequate for running the binary. If it is not, the * program exits with status 1. lib/librte_eal/common/include/generic/rte_cpuflags.h +0
-0@@ -64,4 +64,17 @@ rte_cpu_check_supported(void);int
rte_cpu_is_supported(void);
Quoted 5 lines
Quoted 2 lines
+/**
+ * This function attempts to retrieve a value from the auxiliary vector.Document the return value here as it is not the normal -1 value on error, same for the next one. And the doxygen formats too.
Good call on these. Will do for v2.
Quoted 7 lines
Quoted 7 lines
+ */
lib/librte_eal/common/include/generic/rte_cpuflags.h +6
-0+unsigned long +rte_cpu_getauxval (unsigned long type); + +/** +* This function retrieves a value from the auxiliary vector, and compares it +* as a string.
Quoted 8 lines
Quoted 8 lines
+ */
lib/librte_eal/common/include/generic/rte_cpuflags.h +3
-0+int +rte_cpu_strcmp_auxval (unsigned long type,const char *str); +#endif /* _RTE_CPUFLAGS_H_ */
Signature · 1 line
2.14.3
Thanks for the review, Keith!
Quoted 2 lines
Regards,
Keith
PATCH v2 1/1 eal: abstract away the auxiliary vector
In reply to Aaron ConoleRather than attempting to load the contents of the auxv directly, prefer to use an exposed API - and if that doesn't exist then attempt to load the vector. This is because on some systems, when a user is downgraded, the /proc/self/auxv file retains the old ownership and permissions. The original method of /proc/self/auxv is retained.
This also removes a potential abort() in the code when compiled with NDEBUG. A quick parse of the code shows that many (if not all) of the CPU flag parsing isn't used internally, so it should be okay.
--- lib/librte_eal/common/arch/arm/rte_cpuflags.c | 20 ++---- lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c | 15 +--- lib/librte_eal/common/eal_common_cpuflags.c | 79 ++++++++++++++++++++++ .../common/include/generic/rte_cpuflags.h | 21 ++++++ 4 files changed, 106 insertions(+), 29 deletions(-)
lib/librte_eal/common/arch/arm/rte_cpuflags.c +4 -16
@@ -133,22 +133,10 @@ const struct feature_entry rte_cpu_feature_table[] = {static void rte_cpu_get_features (hwcap_registers_t out) { -int auxv_fd; -_Elfx_auxv_t auxv; - - auxv_fd =open ("/proc/self/auxv" ,O_RDONLY ); -assert (auxv_fd !=-1 ); -while (read (auxv_fd, &auxv,sizeof (auxv)) ==sizeof (auxv)) { -if (auxv.a_type ==AT_HWCAP ) { - out[REG_HWCAP ] = auxv.a_un.a_val; - }else if (auxv.a_type ==AT_HWCAP2 ) { - out[REG_HWCAP2 ] = auxv.a_un.a_val; - }else if (auxv.a_type ==AT_PLATFORM ) { -if (!strcmp ((const char *)auxv.a_un.a_val,PLATFORM_STR )) - out[REG_PLATFORM ] =0x0001 ; - } - } -close (auxv_fd); + out[REG_HWCAP ] =rte_cpu_getauxval (AT_HWCAP ); + out[REG_HWCAP2 ] =rte_cpu_getauxval (AT_HWCAP2 ); +if (!rte_cpu_strcmp_auxval (AT_PLATFORM ,PLATFORM_STR )) + out[REG_PLATFORM ] =0x0001 ; }/*
lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c +2 -13
@@ -104,19 +104,8 @@ const struct feature_entry rte_cpu_feature_table[] = {static void rte_cpu_get_features (hwcap_registers_t out) { -int auxv_fd; -Elf64_auxv_t auxv; - - auxv_fd =open ("/proc/self/auxv" ,O_RDONLY ); -assert (auxv_fd !=-1 ); -while (read (auxv_fd, &auxv, -sizeof (Elf64_auxv_t)) ==sizeof (Elf64_auxv_t)) { -if (auxv.a_type ==AT_HWCAP ) - out[REG_HWCAP ] = auxv.a_un.a_val; -else if (auxv.a_type ==AT_HWCAP2 ) - out[REG_HWCAP2 ] = auxv.a_un.a_val; - } -close (auxv_fd); + out[REG_HWCAP ] =rte_cpu_getauxval (AT_HWCAP ); + out[REG_HWCAP2 ] =rte_cpu_getauxval (AT_HWCAP2 ); }/*
lib/librte_eal/common/eal_common_cpuflags.c +79 -0
90 lines not on this page · raw message
lib/librte_eal/common/include/generic/rte_cpuflags.h +21 -0
@@ -64,4 +64,25 @@ rte_cpu_check_supported(void);int rte_cpu_is_supported (void ); +/** +* This function attempts to retrieve a value from the auxiliary vector. +* If it is unsuccessful, the result will be 0, and errno will be set. +* +* @return A value from the auxiliary vector. When the value is 0, check +* errno to determine if an error occurred. +*/ +unsigned long +rte_cpu_getauxval (unsigned long type); + +/** +* This function retrieves a value from the auxiliary vector, and compares it +* as a string against the value retrieved. +* +* @return The result of calling strcmp() against the value retrieved from +* the auxiliary vector. When the value is 0 (meaning a match is found), +* check errno to determine if an error occurred. +*/ +int +rte_cpu_strcmp_auxval (unsigned long type,const char *str); +#endif /* _RTE_CPUFLAGS_H_ */
Signature · 1 line
2.14.3
Anyone to review, please?
02/04/2018 20:24, Aaron Conole:
Quoted 12 lines
Rather than attempting to load the contents of the auxv directly, prefer to use an exposed API - and if that doesn't exist then attempt to load the vector. This is because on some systems, when a user is downgraded, the
/proc/self/auxvfile retains the old ownership and permissions. The original method of/proc/self/auxvis retained.This also removes a potential
abort()in the code when compiled with NDEBUG. A quick parse of the code shows that many (if not all) of the CPU flag parsing isn't used internally, so it should be okay.Signed-off-by Aaron Conole <[email protected]>Signed-off-by Timothy Redaelli <[email protected]>
11/04/2018 23:34, Thomas Monjalon:
Quoted 15 lines
Anyone to review, please?
02/04/2018 20:24, Aaron Conole:
Quoted 12 lines
Rather than attempting to load the contents of the auxv directly, prefer to use an exposed API - and if that doesn't exist then attempt to load the vector. This is because on some systems, when a user is downgraded, the
/proc/self/auxvfile retains the old ownership and permissions. The original method of/proc/self/auxvis retained.This also removes a potential
abort()in the code when compiled with NDEBUG. A quick parse of the code shows that many (if not all) of the CPU flag parsing isn't used internally, so it should be okay.Signed-off-by Aaron Conole <[email protected]>Signed-off-by Timothy Redaelli <[email protected]>
3 weeks without a single comment.
Applied with below fix, thanks
fix applied:
-#if RTE_ARCH_64
+#ifdef RTE_ARCH_64