diff --git a/src/cpu/aarch64/xbyak_aarch64/src/util_impl_linux.h b/src/cpu/aarch64/xbyak_aarch64/src/util_impl_linux.h index 2c7b28e58b0..58f8d9b0210 100644 --- a/src/cpu/aarch64/xbyak_aarch64/src/util_impl_linux.h +++ b/src/cpu/aarch64/xbyak_aarch64/src/util_impl_linux.h @@ -144,8 +144,13 @@ class CpuInfoLinux : public CpuInfo { regex_t regexBuf; regmatch_t match[1]; - if (regcomp(®exBuf, regex, REG_EXTENDED) != 0) - throw ERR_INTERNAL; + if (regcomp(®exBuf, regex, REG_EXTENDED) != 0) { + /* There are platforms with /sys not mounted. return empty buffers + * in these scenarios + */ + buf[0] = '\0'; + return 0; + } const int retVal = regexec(®exBuf, path, 1, match, 0); regfree(®exBuf); @@ -187,8 +192,12 @@ class CpuInfoLinux : public CpuInfo { regex_t regexBuf; regmatch_t match[2]; - if (regcomp(®exBuf, "index[0-9]*$", REG_EXTENDED) != 0) - throw ERR_INTERNAL; + if (regcomp(®exBuf, "index[0-9]*$", REG_EXTENDED) != 0) { + /* There are platforms with /sys not mounted. return gracefully + * in these scenarios + */ + goto init_and_return_false; + } if (regexec(®exBuf, dp->d_name, 1, match, 0) == 0) { // Found index[1-9][0-9]. directory char *dir_name = buf0; @@ -438,12 +447,15 @@ class CpuInfoLinux : public CpuInfo { FILE *file = fopen(path_midr_el1, "r"); if (file == nullptr) { - throw Error(ERR_INTERNAL); + /* There are platforms with /sys not mounted. return empty buffer + * in these scenarios + */ + buf[0] = '\0'; return; } if (fread(buf, sizeof(char), 64, file) == 0) { - throw Error(ERR_INTERNAL); + cacheInfo_.midr_el1 = 0xFE << 24; return; } diff --git a/src/cpu/aarch64/xbyak_aarch64/src/util_impl_mac.h b/src/cpu/aarch64/xbyak_aarch64/src/util_impl_mac.h index ebd6dba7c0d..93bdae1d7a8 100644 --- a/src/cpu/aarch64/xbyak_aarch64/src/util_impl_mac.h +++ b/src/cpu/aarch64/xbyak_aarch64/src/util_impl_mac.h @@ -102,18 +102,21 @@ class CpuInfoMac : public CpuInfo { size_t val = 0; size_t len = sizeof(val); + /* There are platforms with /sys not mounted. skip + * handling HW caps for such platforms. + */ if (sysctlbyname(hw_opt_atomics, &val, &len, NULL, 0) != 0) - throw Error(ERR_INTERNAL); + type_ = 0; else type_ |= (val == 1) ? (Type)XBYAK_AARCH64_HWCAP_ATOMIC : 0; if (sysctlbyname(hw_opt_fp, &val, &len, NULL, 0) != 0) - throw Error(ERR_INTERNAL); + type_ = 0; else type_ |= (val == 1) ? (Type)XBYAK_AARCH64_HWCAP_FP : 0; if (sysctlbyname(hw_opt_neon, &val, &len, NULL, 0) != 0) - throw Error(ERR_INTERNAL); + type_ = 0; else type_ |= (val == 1) ? (Type)XBYAK_AARCH64_HWCAP_ADVSIMD : 0; }