Non-zero build crash on kernel 5.17+?
Ludovic Henry
ludovic at rivosinc.com
Tue Oct 4 10:45:59 UTC 2022
Hello,
Some updates on working around that issue. In order to force QEMU to use
sv48 in place of sv57, you can comment out this line
<https://github.com/qemu/qemu/blob/efbf38d73e5dcc4d5f8b98c6e7a12be1f3b91745/target/riscv/csr.c#L1027>
and
compile your own version of QEMU. There is unfortunately no way currently
to disable sv57 through an option, and Linux will probe the CSR SATP to
know whether the machine supports sv57 while ignoring the device tree
provided by QEMU.
I hope that helps,
Ludovic
On Fri, Sep 23, 2022 at 3:05 PM Ludovic Henry <ludovic at rivosinc.com> wrote:
> Hi,
>
> 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.
>
> Thanks,
> Ludovic
>
> On Fri, Sep 23, 2022 at 1:17 PM Xiaolin Zheng <yunyao.zxl at alibaba-inc.com>
> wrote:
>
>> Hi Zixian,
>>
>> The current backend supports sv48 and below only. Please see [1] for more
>> details.
>>
>> The kernel 5.17 supports sv48 and 5.18 supports sv57. Your address `
>> 0xfffffff71136b8` is a 56-bit address, which is not supported by the
>> backend currently.
>>
>> 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.
>>
>> 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.
>>
>>
>> Thanks,
>> Xiaolin
>>
>> [1]
>> https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp#L910-L914
>>
>> ------------------------------------------------------------------
>> From:Zixian Cai <zixian.cai at anu.edu.au>
>> Send Time:2022年9月23日(星期五) 16:57
>> To:riscv-port-dev at openjdk.org <riscv-port-dev at openjdk.org>
>> Subject:Non-zero build crash on kernel 5.17+?
>>
>> Hi all,
>>
>>
>>
>> I found that a non-zero build of jdk-20+16 crashes on Ubuntu 22.10
>> (kernel 5.19) running on QEMU.
>>
>> The same build works on Ubuntu 22.04 (kernel 5.15) running on QEMU.
>>
>> The error message is as follows.
>>
>>
>>
>> # To suppress the following error report, specify this argument
>>
>> # after -XX: or in .hotspotrc: SuppressErrorAt=/assembler_riscv.cpp:285
>>
>> #
>>
>> # A fatal error has been detected by the Java Runtime Environment:
>>
>> #
>>
>> # Internal Error
>> (/home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/assembler_riscv.cpp:285),
>> pid=907, tid=908
>>
>> # assert(is_unsigned_imm_in_range(imm64, 47, 0) || (imm64 ==
>> (int64_t)-1)) failed: bit 47 overflows in address constant
>>
>> #
>>
>> # JRE version: (20.0) (slowdebug build )
>>
>> # 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)
>>
>> # Problematic frame:
>>
>> # V [libjvm.so+0x39f41c] Assembler::movptr_with_offset(Register,
>> unsigned char*, int&)+0x96
>>
>> #
>>
>> # 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)
>>
>> #
>>
>> # An error report file with more information is saved as:
>>
>> # /home/ubuntu/hs_err_pid907.log
>>
>> #
>>
>> #
>>
>>
>>
>> Here is the backtrace and local variables seen in gdb.
>>
>>
>>
>> (gdb) bt
>>
>> #0 0x00fffffff674941c in Assembler::movptr_with_offset
>> (this=0xfffffff0000e30, Rd=...,
>>
>> addr=0xfffffff71136b8
>> <SharedRuntime::exception_handler_for_return_address(JavaThread*, unsigned
>> char*)> "9q\006\374\"\370", <incomplete sequence \364\200>,
>> offset=@0xfffffff632f00c: 0)
>>
>> at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/assembler_riscv.cpp:284
>>
>> #1 0x00fffffff6f17c5c in MacroAssembler::call_VM_leaf_base
>> (this=0xfffffff0000e30,
>>
>> entry_point=0xfffffff71136b8
>> <SharedRuntime::exception_handler_for_return_address(JavaThread*, unsigned
>> char*)> "9q\006\374\"\370", <incomplete sequence \364\200>,
>> number_of_arguments=2,
>>
>> retaddr=0x0) at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp:568
>>
>> #2 0x00fffffff6f17da2 in MacroAssembler::call_VM_leaf
>> (this=0xfffffff0000e30,
>>
>> entry_point=0xfffffff71136b8
>> <SharedRuntime::exception_handler_for_return_address(JavaThread*, unsigned
>> char*)> "9q\006\374\"\370", <incomplete sequence \364\200>, arg_0=...,
>> arg_1=...)
>>
>> at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp:588
>>
>> #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
>>
>> #4 0x00fffffff7231506 in StubGenerator::generate_initial
>> (this=0xfffffff632f1e8) at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:3870
>>
>> #5 0x00fffffff7231956 in StubGenerator::StubGenerator
>> (this=0xfffffff632f1e8, code=0xfffffff632f3c8, phase=0)
>>
>> at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:3971
>>
>> #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
>>
>> #7 0x00fffffff72322c8 in StubRoutines::initialize1 () at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/stubRoutines.cpp:228
>>
>> #8 0x00fffffff72330d2 in stubRoutines_init1 () at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/stubRoutines.cpp:389
>>
>> #9 0x00fffffff6c7823a in init_globals () at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/init.cpp:123
>>
>> #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
>>
>> #11 0x00fffffff6d891ae in JNI_CreateJavaVM_inner (vm=0xfffffff632f838,
>> penv=0xfffffff632f840, args=0xfffffff632f7e0)
>>
>> at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/prims/jni.cpp:3628
>>
>> #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
>>
>> #13 0x00fffffff7fb1a44 in InitializeJVM (pvm=0xfffffff632f838,
>> penv=0xfffffff632f840, ifn=0xfffffff632f890)
>>
>> at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/java.base/share/native/libjli/java.c:1457
>>
>> #14 0x00fffffff7faef16 in JavaMain (_args=0xffffffffffc0d8) at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/java.base/share/native/libjli/java.c:413
>>
>> #15 0x00fffffff7fb50ea in ThreadJavaMain (args=0xffffffffffc0d8) at
>> /home/buildbot/worker/build-jdkX-debian10/build/src/java.base/unix/native/libjli/java_md.c:650
>>
>> #16 0x00fffffff7ed7450 in start_thread (arg=<optimized out>) at
>> ./nptl/pthread_create.c:442
>>
>> #17 0x00fffffff7f24ed2 in __thread_start () at
>> ../sysdeps/unix/sysv/linux/riscv/clone.S:85
>>
>> (gdb) info locals
>>
>> imm64 = 0xfffffff71136b8
>>
>> imm = 0xfffffff632efb0
>>
>> upper = 0xfffffff632efb0
>>
>> lower = 0xffffff80000000
>>
>>
>>
>> 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
>> https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.17.
>>
>>
>>
>> To reproduce the issue, I use the following.
>>
>> Guest Ubuntu 22.10:
>> https://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/kinetic-preinstalled-server-riscv64+unmatched.img.xz
>>
>> Guest Ubuntu 22.04:
>> https://cdimage.ubuntu.com/releases/22.04.1/release/ubuntu-22.04.1-preinstalled-server-riscv64+unmatched.img.xz
>>
>> JDK slowdebug build:
>> https://builds.shipilev.net/openjdk-jdk/openjdk-jdk-linux-riscv64-server-slowdebug-gcc8-glibc2.28.tar.xz
>> (OpenJDK 64-Bit Server VM (slowdebug build
>> 20-testing-builds.shipilev.net-openjdk-jdk-b212-20220922, mixed mode))
>>
>> QEMU: installed via apt on Ubuntu 22.04 host
>>
>> QEMU setup: https://wiki.ubuntu.com/RISC-V
>>
>>
>>
>> Sincerely,
>>
>> Zixian
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/riscv-port-dev/attachments/20221004/66063d45/attachment-0001.htm>
More information about the riscv-port-dev
mailing list