From efbbd9c33adfa843d65860b1b02adebb8ecb57ce Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 5 Dec 2020 07:01:58 -0800 Subject: ldconfig/x86: Store ISA level in cache and aux cache Store ISA level in the portion of the unused upper 32 bits of the hwcaps field in cache and the unused pad field in aux cache. ISA level is stored and checked only for shared objects in glibc-hwcaps subdirectories. The shared objects in the default directories aren't checked since there are no fallbacks for these shared objects. Tested on x86-64-v2, x86-64-v3 and x86-64-v4 machines with --disable-hardcoded-path-in-tests and --enable-hardcoded-path-in-tests. --- sysdeps/generic/dl-cache.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'sysdeps/generic/dl-cache.h') diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h index c7eca70d0c..964d50a486 100644 --- a/sysdeps/generic/dl-cache.h +++ b/sysdeps/generic/dl-cache.h @@ -106,14 +106,24 @@ struct file_entry_new entries. */ #define DL_CACHE_HWCAP_EXTENSION (1ULL << 62) +/* The number of the ISA level bits in the upper 32 bits of the hwcap + field. */ +#define DL_CACHE_HWCAP_ISA_LEVEL_COUNT 10 + +/* The mask of the ISA level bits in the hwcap field. */ +#define DL_CACHE_HWCAP_ISA_LEVEL_MASK \ + ((1 << DL_CACHE_HWCAP_ISA_LEVEL_COUNT) -1) + /* Return true if the ENTRY->hwcap value indicates that DL_CACHE_HWCAP_EXTENSION is used. */ static inline bool dl_cache_hwcap_extension (struct file_entry_new *entry) { - /* If DL_CACHE_HWCAP_EXTENSION is set, but other bits as well, this - is a different kind of extension. */ - return (entry->hwcap >> 32) == (DL_CACHE_HWCAP_EXTENSION >> 32); + /* This is an hwcap extension if only the DL_CACHE_HWCAP_EXTENSION bit + is set, ignoring the lower 32 bits as well as the ISA level bits in + the upper 32 bits. */ + return (((entry->hwcap >> 32) & ~DL_CACHE_HWCAP_ISA_LEVEL_MASK) + == (DL_CACHE_HWCAP_EXTENSION >> 32)); } /* See flags member of struct cache_file_new below. */ -- cgit 1.4.1