# include <unistd.h>
# include <sys/syscall.h>
# include <asm/hwprobe.h>
+# include <sys/auxv.h>
#endif
extern size_t riscv_vlen_asm(void);
static size_t vlen = 0;
+#ifdef OSSL_RISCV_HWPROBE
+unsigned int OPENSSL_riscv_hwcap_P = 0;
+#endif
+
uint32_t OPENSSL_rdtsc(void)
{
return 0;
if (pairs[j].key == RISCV_capabilities[i].hwprobe_key
&& (pairs[j].value & RISCV_capabilities[i].hwprobe_value)
!= 0)
- /* Match, set relevant bit in OPENSSL_riscvcap_P[] */
- OPENSSL_riscvcap_P[RISCV_capabilities[i].index] |=
- (1 << RISCV_capabilities[i].bit_offset);
+ if (!IS_IN_DEPEND_VECTOR(RISCV_capabilities[i].bit_offset) || VECTOR_CAPABLE)
+ /* Match, set relevant bit in OPENSSL_riscvcap_P[] */
+ OPENSSL_riscvcap_P[RISCV_capabilities[i].index] |=
+ (1 << RISCV_capabilities[i].bit_offset);
}
}
}
}
#ifdef OSSL_RISCV_HWPROBE
else {
+ OPENSSL_riscv_hwcap_P = getauxval(AT_HWCAP);
hwprobe_to_cap();
}
#endif
*/
# ifdef __NR_riscv_hwprobe
# define OSSL_RISCV_HWPROBE
+# include <asm/hwcap.h>
+extern unsigned int OPENSSL_riscv_hwcap_P;
+# define VECTOR_CAPABLE (OPENSSL_riscv_hwcap_P & COMPAT_HWCAP_ISA_V)
+# define ZVX_MIN 15
+# define ZVX_MAX 23
+# define IS_IN_DEPEND_VECTOR(offset) ((ZVX_MIN >= offset) && (offset <= ZVX_MAX))
# endif
# endif
# endif