Bug 482013 - Unhandled instruction 0xD5380008 on arm64 platform (mrs x8, midr_el1)
Summary: Unhandled instruction 0xD5380008 on arm64 platform (mrs x8, midr_el1)
Status: RESOLVED DUPLICATE of bug 392146
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (show other bugs)
Version: 3.22.0
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-29 11:24 UTC by Adam Folwarczny
Modified: 2024-03-17 10:41 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Folwarczny 2024-02-29 11:24:23 UTC
SUMMARY

ARM64 front end: branch_etc
disInstr(arm64): unhandled instruction 0xD5380008
disInstr(arm64): 1101'0101 0011'1000 0000'0000 0000'1000
==3277832== valgrind: Unrecognised instruction at address 0x8ebb81c.
==3277832==    at 0x8EBB81C: setSysRegVal (util_impl.cpp:123)
==3277832==    by 0x8EBB81C: Xbyak_aarch64::util::Cpu::Cpu() (util_impl.cpp:233)
==3277832==    by 0x8E9597F: cpu (cpu_isa_traits.hpp:171)
==3277832==    by 0x8E9597F: mayiuse (cpu_isa_traits.hpp:188)
==3277832==    by 0x8E9597F: dnnl::impl::cpu::aarch64::tr::jit_single_blk_kernel_t::applicable(dnnl::impl::cpu::aarch64::tr::prb_t const&) (jit_uni_reorder.cpp:1905)
==3277832==    by 0x8E955C7: dnnl::impl::cpu::aarch64::jit_blk_reorder_t::pd_t::create(dnnl::impl::reorder_pd_t**, dnnl_engine*, dnnl_primitive_attr const*, dnnl_engine*, dnnl_memory_desc const*, dnnl_engine*, dnnl_memory_desc const*) (jit_uni_reorder.cpp:2936)

OBSERVED RESULT
valgrind reports unhandled instruction error

EXPECTED RESULT
Valgrind understand instruction mentioned above

SOFTWARE/OS VERSIONS
Linux arm64

ADDITIONAL INFORMATION
The error comes from dnnl library.
Compile command:
clang++-10 -MMD -MF  -DENABLE_NEON -DENABLE_OMP -DNDEBUG -DDISABLE_VERBOSE -DDNNL_DISABLE_PRIMITIVE_CACHE -DDNNL_ENABLE_CONCURRENT_EXEC -DDNNL_ENABLE_JIT_PROFILING=0 -DDNNL_ENABLE_MAX_CPU_ISA -DDNNL_AARCH64=1  -I../../deps/build/dnnl/src -I../../deps/build/dnnl/include -I../../deps/build/dnnl/src/cpu/aarch64/xbyak_aarch64/xbyak_aarch64 -I../../deps/build/acl/arm_compute -I../../deps/build/acl -I../../deps/build/acl/include -I../../deps/build/openmp/pregenerated/include -I../../deps/build/libcxx/include -I../../deps/build/libcxxabi/include  -fopenmp -fno-strict-aliasing -funwind-tables -fPIC -fcolor-diagnostics --target=aarch64-linux-gnu -fstack-protector-strong -pthread -O3 -fno-ident -fdata-sections -ffunction-sections -fno-omit-frame-pointer -g2 --sysroot=/opt/xenial -fvisibility=hidden  -fvisibility-inlines-hidden -frtti -fexceptions -std=c++14 -nostdinc++ -c ../../deps/build/dnnl/src/cpu/aarch64/xbyak_aarch64/src/util_impl.cpp 

Function with unrecognized instruction:
0000000000000000 <_ZN13Xbyak_aarch644util3Cpu12setSysRegValEv>:
   0:	d5380008 	mrs	x8, midr_el1
   4:	f9003c08 	str	x8, [x0, #120]
   8:	d65f03c0 	ret

Implementation:
#define XBYAK_AARCH64_READ_SYSREG(var, ID) asm("mrs %0, " #ID : "=r"(var));
void Cpu::setSysRegVal() {
#ifdef __linux__
  XBYAK_AARCH64_READ_SYSREG(midr_el1_, MIDR_EL1);
#endif
}

Codes comes from opendll (util_impl.cpp)
oneAPI Deep Neural Network Library (oneDNN)
https://github.com/oneapi-src/oneDNN/blob/rls-v3.1/src/cpu/aarch64/xbyak_aarch64/src/util_impl.cpp
Comment 1 Paul Floyd 2024-03-07 14:54:07 UTC
This looks quite similar to cpuid.

The main problem here is that it needs to be consistent with what Valgrind is emulating.
Comment 2 Paul Floyd 2024-03-17 10:41:08 UTC
I see there was an earlier report of this, with a patch.

*** This bug has been marked as a duplicate of bug 392146 ***