<div dir="ltr">Hi,<div><br></div><div>I did run into the same issue locally. Unfortunately, there doesn't seem to be an option to disable sv57 support in Qemu (I couldn't find anything in the sources either). Using an older kernel (5.17) seems to be the only solution for now.</div><div><br></div><div>Thanks,</div><div>Ludovic</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 23, 2022 at 1:17 PM Xiaolin Zheng <<a href="mailto:yunyao.zxl@alibaba-inc.com">yunyao.zxl@alibaba-inc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="line-height:1.7;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><div style="clear:both">Hi Zixian,</div><div style="clear:both"><br></div><div style="clear:both">The current backend supports sv48 and below only. Please see [1] for more details.</div><div style="clear:both"><br></div><div style="clear:both">The kernel 5.17 supports sv48 and 5.18 supports sv57. Your address `<span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.7px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">0xfffffff71136b8</span>` is a 56-bit address, which is not supported by the backend currently.</div><div style="clear:both"><br></div><div style="clear:both">To bypass this issue, you can try to use kernel 5.17 directly or find if there are options for QEMU to limit the address space to an sv48 one.</div><div style="clear:both"><br></div><div style="clear:both">Not sure if there will be support for a larger address space recently in the backend, for there seems no hardware supporting even sv48 now.</div><div style="clear:both"><br></div><div style="clear:both"><br></div><div style="clear:both">Thanks,</div><div style="clear:both">Xiaolin</div><div style="clear:both"><br></div><div style="clear:both">[1] <span><a href="https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp#L910-L914" target="_blank">https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp#L910-L914</a></span></div><div style="clear:both"><br></div><blockquote style="margin-right:0px;margin-top:0px;margin-bottom:0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><div style="clear:both">------------------------------------------------------------------</div><div style="clear:both">From:Zixian Cai <<a href="mailto:zixian.cai@anu.edu.au" target="_blank">zixian.cai@anu.edu.au</a>></div><div style="clear:both">Send Time:2022年9月23日(星期五) 16:57</div><div style="clear:both"><a href="mailto:To%3Ariscv-port-dev@openjdk.org" target="_blank">To:riscv-port-dev@openjdk.org</a> <<a href="mailto:riscv-port-dev@openjdk.org" target="_blank">riscv-port-dev@openjdk.org</a>></div><div style="clear:both">Subject:Non-zero build crash on kernel 5.17+?</div><div style="clear:both"><br></div>






<div>
<p class="MsoNormal"><span style="font-size:11pt">Hi all,</span></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt">I found that a non-zero build of jdk-20+16 crashes on Ubuntu 22.10 (kernel 5.19) running on QEMU.</span></p>
<p class="MsoNormal"><span style="font-size:11pt">The same build works on Ubuntu 22.04 (kernel 5.15) running on QEMU.</span></p>
<p class="MsoNormal"><span style="font-size:11pt">The error message is as follows.</span></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt"># To suppress the following error report, specify this argument</span></p>
<p class="MsoNormal"><span style="font-size:11pt"># after -XX: or in .hotspotrc:  SuppressErrorAt=/assembler_riscv.cpp:285</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#</span></p>
<p class="MsoNormal"><span style="font-size:11pt"># A fatal error has been detected by the Java Runtime Environment:</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#  Internal Error (/home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/assembler_riscv.cpp:285), pid=907, tid=908</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#  assert(is_unsigned_imm_in_range(imm64, 47, 0) || (imm64 == (int64_t)-1)) failed: bit 47 overflows in address constant</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#</span></p>
<p class="MsoNormal"><span style="font-size:11pt"># JRE version:  (20.0) (slowdebug build )</span></p>
<p class="MsoNormal"><span style="font-size:11pt"># Java VM: OpenJDK 64-Bit Server VM (slowdebug 20-testing-builds.shipilev.net-openjdk-jdk-b212-20220922, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)</span></p>
<p class="MsoNormal"><span style="font-size:11pt"># Problematic frame:</span></p>
<p class="MsoNormal"><span style="font-size:11pt"># V  [libjvm.so+0x39f41c]  Assembler::movptr_with_offset(Register, unsigned char*, int&)+0x96</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#</span></p>
<p class="MsoNormal"><span style="font-size:11pt"># Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/ubuntu/core.907)</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#</span></p>
<p class="MsoNormal"><span style="font-size:11pt"># An error report file with more information is saved as:</span></p>
<p class="MsoNormal"><span style="font-size:11pt"># /home/ubuntu/hs_err_pid907.log</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#</span></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt">Here is the backtrace and local variables seen in gdb.</span></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt">(gdb) bt</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#0  0x00fffffff674941c in Assembler::movptr_with_offset (this=0xfffffff0000e30, Rd=...,</span></p>
<p class="MsoNormal"><span style="font-size:11pt">    addr=0xfffffff71136b8 <SharedRuntime::exception_handler_for_return_address(JavaThread*, unsigned char*)> "9q\006\374\"\370", <incomplete sequence \364\200>, offset=@0xfffffff632f00c: 0)</span></p>
<p class="MsoNormal"><span style="font-size:11pt">    at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/assembler_riscv.cpp:284</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#1  0x00fffffff6f17c5c in MacroAssembler::call_VM_leaf_base (this=0xfffffff0000e30,</span></p>
<p class="MsoNormal"><span style="font-size:11pt">    entry_point=0xfffffff71136b8 <SharedRuntime::exception_handler_for_return_address(JavaThread*, unsigned char*)> "9q\006\374\"\370", <incomplete sequence \364\200>, number_of_arguments=2,</span></p>
<p class="MsoNormal"><span style="font-size:11pt">    retaddr=0x0) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp:568</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#2  0x00fffffff6f17da2 in MacroAssembler::call_VM_leaf (this=0xfffffff0000e30,</span></p>
<p class="MsoNormal"><span style="font-size:11pt">    entry_point=0xfffffff71136b8 <SharedRuntime::exception_handler_for_return_address(JavaThread*, unsigned char*)> "9q\006\374\"\370", <incomplete sequence \364\200>, arg_0=..., arg_1=...)</span></p>
<p class="MsoNormal"><span style="font-size:11pt">    at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp:588</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#3  0x00fffffff7222308 in StubGenerator::generate_forward_exception (this=0xfffffff632f1e8) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:546</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#4  0x00fffffff7231506 in StubGenerator::generate_initial (this=0xfffffff632f1e8) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:3870</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#5  0x00fffffff7231956 in StubGenerator::StubGenerator (this=0xfffffff632f1e8, code=0xfffffff632f3c8, phase=0)</span></p>
<p class="MsoNormal"><span style="font-size:11pt">    at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:3971</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#6  0x00fffffff721faa0 in StubGenerator_generate (code=0xfffffff632f3c8, phase=0) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:3988</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#7  0x00fffffff72322c8 in StubRoutines::initialize1 () at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/stubRoutines.cpp:228</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#8  0x00fffffff72330d2 in stubRoutines_init1 () at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/stubRoutines.cpp:389</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#9  0x00fffffff6c7823a in init_globals () at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/init.cpp:123</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#10 0x00fffffff72bcc34 in Threads::create_vm (args=0xfffffff632f7e0, canTryAgain=0xfffffff632f70b) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/threads.cpp:570</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#11 0x00fffffff6d891ae in JNI_CreateJavaVM_inner (vm=0xfffffff632f838, penv=0xfffffff632f840, args=0xfffffff632f7e0)</span></p>
<p class="MsoNormal"><span style="font-size:11pt">    at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/prims/jni.cpp:3628</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#12 0x00fffffff6d893a8 in JNI_CreateJavaVM (vm=0xfffffff632f838, penv=0xfffffff632f840, args=0xfffffff632f7e0) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/prims/jni.cpp:3714</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#13 0x00fffffff7fb1a44 in InitializeJVM (pvm=0xfffffff632f838, penv=0xfffffff632f840, ifn=0xfffffff632f890)</span></p>
<p class="MsoNormal"><span style="font-size:11pt">    at /home/buildbot/worker/build-jdkX-debian10/build/src/java.base/share/native/libjli/java.c:1457</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#14 0x00fffffff7faef16 in JavaMain (_args=0xffffffffffc0d8) at /home/buildbot/worker/build-jdkX-debian10/build/src/java.base/share/native/libjli/java.c:413</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#15 0x00fffffff7fb50ea in ThreadJavaMain (args=0xffffffffffc0d8) at /home/buildbot/worker/build-jdkX-debian10/build/src/java.base/unix/native/libjli/java_md.c:650</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#16 0x00fffffff7ed7450 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442</span></p>
<p class="MsoNormal"><span style="font-size:11pt">#17 0x00fffffff7f24ed2 in __thread_start () at ../sysdeps/unix/sysv/linux/riscv/clone.S:85</span></p>
<p class="MsoNormal"><span style="font-size:11pt">(gdb) info locals</span></p>
<p class="MsoNormal"><span style="font-size:11pt">imm64 = 0xfffffff71136b8</span></p>
<p class="MsoNormal"><span style="font-size:11pt">imm = 0xfffffff632efb0</span></p>
<p class="MsoNormal"><span style="font-size:11pt">upper = 0xfffffff632efb0</span></p>
<p class="MsoNormal"><span style="font-size:11pt">lower = 0xffffff80000000</span></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt">I suspect that the issue is due to the newer kernels (5.17+) supports sv48, and that increases the bits in the addresses that the assembler needs to handle. See kernel changelog
<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.17" target="_blank">https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.17</a>.</span></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt">To reproduce the issue, I use the following.</span></p>
<p class="MsoNormal"><span style="font-size:11pt">Guest Ubuntu 22.10: <a href="https://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/kinetic-preinstalled-server-riscv64+unmatched.img.xz" target="_blank">
https://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/kinetic-preinstalled-server-riscv64+unmatched.img.xz</a></span></p>
<p class="MsoNormal"><span style="font-size:11pt">Guest Ubuntu 22.04: <a href="https://cdimage.ubuntu.com/releases/22.04.1/release/ubuntu-22.04.1-preinstalled-server-riscv64+unmatched.img.xz" target="_blank">
https://cdimage.ubuntu.com/releases/22.04.1/release/ubuntu-22.04.1-preinstalled-server-riscv64+unmatched.img.xz</a></span></p>
<p class="MsoNormal"><span style="font-size:11pt">JDK slowdebug build: <a href="https://builds.shipilev.net/openjdk-jdk/openjdk-jdk-linux-riscv64-server-slowdebug-gcc8-glibc2.28.tar.xz" target="_blank">
https://builds.shipilev.net/openjdk-jdk/openjdk-jdk-linux-riscv64-server-slowdebug-gcc8-glibc2.28.tar.xz</a> (OpenJDK 64-Bit Server VM (slowdebug build 20-testing-builds.shipilev.net-openjdk-jdk-b212-20220922, mixed mode))</span></p>
<p class="MsoNormal"><span style="font-size:11pt">QEMU: installed via apt on Ubuntu 22.04 host</span></p>
<p class="MsoNormal"><span style="font-size:11pt">QEMU setup: <a href="https://wiki.ubuntu.com/RISC-V" target="_blank">
https://wiki.ubuntu.com/RISC-V</a></span></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt">Sincerely,</span></p>
<p class="MsoNormal"><span style="font-size:11pt">Zixian</span></p>
</div>


</blockquote></div></div></blockquote></div>