Package: libhsa-runtime64-1
Version: 7.2.4+dfsg-1~exp1
Severity: important
Tags: patch

Hi,

On ppc64el, hsa_init() segfaults before it finds any GPU, so nothing that uses ROCm can start. I hit it on a Raptor Talos II (2x POWER9) with an AMD Radeon AI PRO R9700 (gfx1201), on kernel 7.3.4 from trixie-backports, with the experimental packages in a sid chroot. Any HIP program, or plain rocminfo, crashes the same way.

The cause is the vDSO check in runtime/hsa-runtime/core/util/lnx/os_linux.cpp. During init, ROCr walks the loaded objects with dl_iterate_phdr() and reads each one's dynamic section, and it skips the vDSO by searching the name for "vdso.so". That matches linux-vdso.so.1 on amd64 and arm64, but on ppc64el the vDSO is called linux-vdso64.so.1, so it isn't skipped. The vDSO's dynamic section is never relocated, so DT_STRTAB is still a small raw offset (0x2d8 on this machine), and ROCr dereferences it as a pointer. gdb shows the crash in the dl_iterate_phdr callback in libhsa-runtime64.

s390x names its vDSO linux-vdso64.so.1 too, so it should have the same problem, but I haven't been able to test that.

Matching on "linux-vdso" fixes it. With this change, rocminfo lists the GPU, and HIP kernels run and pass a 200,000-dispatch stress test on this box:

--- a/runtime/hsa-runtime/core/util/lnx/os_linux.cpp
+++ b/runtime/hsa-runtime/core/util/lnx/os_linux.cpp
@@ -326,7 +326,10 @@ static int callback(struct dl_phdr_info* info, size_t size, void* data) {
    */
    if ((info) && (info->dlpi_name[0] != '\0')) {
- if (std::string(info->dlpi_name).find("vdso.so") != std::string::npos) return 0; + // The vDSO is named linux-vdso.so.1 on x86-64/arm64 but linux-vdso64.so.1 on + // ppc64/s390x (linux-vdso32.so.1 on 32-bit). Its dynamic section is never + // relocated by ld.so, so DT_STRTAB is a raw offset; dereferencing it crashes. + if (std::string(info->dlpi_name).find("linux-vdso") != std::string::npos) return 0;
      /*
* Iterate through the program headers of the loaded lib and check for PT_DYNAMIC program

There's a small test program and the rest of our ppc64el work (other ROCr, libhsakmt and HIP fixes) here:
https://github.com/Scottcjn/rocm-ppc64le
I plan to send this one upstream to AMD as well.

The hardware is on loan from Raptor Computing Systems and hosted by Integricloud, so I can test follow-up changes on POWER9 if that helps.

Thanks,
Scott

Reply via email to