-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RISC-V NativeAOT port #106223
Comments
cc @dotnet/samsung, @filipnavara If someone wants take over, let me know. I can also give ssh access to riscv computer (bianbu OS, Debian derivative) if needed for testing. 👍 |
Some assertions are failing at build-time in AsmOffset* and llvm-libunwind due to the sizes of various structs. llvm-libunwind is getting 96 bytes size difference in Also, I've used the register names we have in coreclr/pal. Some of them might not be needed, but I'm not sure since llvm-libunwind uses different names X1,X2,X3.. while coreclr/pal is using T1,T2,T3.. so I used the latter and handled the mapping in |
Applied changes from #106225. FWIW, this is my workflow: # on macOS arm64
$ cd runtime
$ docker run -e ROOTFS_DIR=/crossrootfs/riscv64 -v$(pwd):/runtime -w /runtime --rm \
--platform linux/arm64 -it ubuntu
$ eng/common/native/install-dependencies.sh
$ apt install -y debootstrap
$ eng/common/cross/build-rootfs.sh riscv64 noble --skipunmount --rootfsdir /crossrootfs/riscv64
$ src/coreclr/build-runtime.sh -cross -riscv64
# once nativeaot runtime ^ starts building in silo, we can try a full build
# rm -rf artifacts
# ./build.sh clr+libs+packs -cross --arch riscv64 currently it is not getting too far 😅
|
I tried to compile your branch and I ended up pretty much at the same spot. Currently away from computer, but this should be easy to fix… |
@filipnavara, have you had a chance to check out the assertion failures? No rush—just wondering if there are any blockers or details we need to sort out. Thanks! 👍 |
Unfortunately no, still tackling some things for .NET 9 release and few other hack projects that I want to get done for the .NET 10 timeframe. I hope to eventually look into it but it’s currently not a priority, sorry. |
Ok, no worries, I'll also take a look when I get a chance. Was hoping to get some feedback from @viewizard et al. on register naming since it's not immediately clear to which convention is preferred at present day (and given llvm-libunwind has its own which is obviously different than HP-libunwind, coreclr VM and PAL). 😅 |
Here are some of my ideas, and I'm not sure if they're helpful. |
Thanks @sunlijun-610, https://github.com/am11/runtime/tree/feature/nativeaot/riscv64-port has the changes. Currently, the size of |
Thanks! About the does_fit assertion failure in llvm-libunwind UnwindCursor.hpp, I think it's no need to add |
Bulk of change is merged and SDK is enabling it dotnet/sdk#45852. Last year, .NET 9 preview 1 was released on Feb. 13, so in a month or so, runtime's global.json will pick up the RID. ATM it throws unsupported platform error with PublishAot=true. |
#111273 is a baby step to get the bits working. After that update, next issue is: root@0900f1880a04:/app1# /runtime/artifacts/bin/coreclr/linux.arm64.Debug/ilc-published/ilc @app1.ilc.rsp
ILC: /runtime/src/coreclr/jit/emitriscv64.cpp:1630
ILC: Assertion failed 'isValidSimm32(addr - (ssize_t)dst)' in 'System.ObsoleteAttribute:.ctor(System.String,ubyte):this' during 'Emit code' (IL size 21; hash 0x817d7d95; FullOpts)
ILC: /runtime/src/coreclr/jit/emitriscv64.cpp:1630
ILC: Assertion failed 'isValidSimm32(addr - (ssize_t)dst)' in 'Internal.CompilerGenerated.<Module>:DynamicInvoke(ulong,byref,byref,ulong):byref' during 'Emit code' (IL size 50; hash 0xc1e09f14; FullOpts)
ILC: /runtime/src/coreclr/jit/emitriscv64.cpp:1630
ILC: Assertion failed 'isValidSimm32(addr - (ssize_t)dst)' in 'System.Runtime.CompilerServices.NullableAttribute:.ctor(ubyte):this' during 'Emit code' (IL size 23; hash 0x1237d66e; FullOpts)
Aborted while we are waiting for the upcoming SDK 10 preview 1 to be picked up in runtime global.json (a month away), I found a way to test things locally.
Under lldb(lldb) r
Process 40540 launched: '/runtime/artifacts/bin/coreclr/linux.arm64.Debug/ilc-published/ilc' (aarch64)
ILC: /runtime/src/coreclr/jit/emitriscv64.cpp:1630
ILC: Assertion failed 'isValidSimm32(addr - (ssize_t)dst)' in 'System.ObsoleteAttribute:.ctor(System.String,ubyte):this' during 'Emit code' (IL size 21; hash 0x817d7d95; FullOpts)
ILC: /runtime/src/coreclr/jit/emitriscv64.cpp:1630
ILC: Assertion failed 'isValidSimm32(addr - (ssize_t)dst)' in 'Internal.CompilerGenerated.<Module>:DynamicInvoke(ulong,byref,byref,ulong):byref' during 'Emit code' (IL size 50; hash 0xc1e09f14; FullOpts)
ILC: /runtime/src/coreclr/jit/emitriscv64.cpp:1630
ILC: Assertion failed 'isValidSimm32(addr - (ssize_t)dst)' in 'System.Runtime.CompilerServices.NullableAttribute:.ctor(ubyte):this' during 'Emit code' (IL size 23; hash 0x1237d66e; FullOpts)
ILC: /runtime/src/coreclr/jit/emitriscv64.cpp:1630
Process 40540 stopped
* thread #1, name = 'ilc', stop reason = signal SIGTRAP
frame #0: 0x0000ffffe46480a8 libclrjit_unix_riscv64_arm64.so`DBG_DebugBreak at debugbreak.S:7
4 #include "unixasmmacros.inc"
5
6 LEAF_ENTRY DBG_DebugBreak, _TEXT
-> 7 EMIT_BREAKPOINT
8 ret
9 LEAF_END_MARKED DBG_DebugBreak, _TEXT
10
thread #23, name = '.NET TP Worker', stop reason = signal SIGTRAP
frame #0: 0x0000ffffe46480a8 libclrjit_unix_riscv64_arm64.so`DBG_DebugBreak at debugbreak.S:7
4 #include "unixasmmacros.inc"
5
6 LEAF_ENTRY DBG_DebugBreak, _TEXT
-> 7 EMIT_BREAKPOINT
8 ret
9 LEAF_END_MARKED DBG_DebugBreak, _TEXT
10
thread #25, name = '.NET TP Worker', stop reason = signal SIGTRAP
frame #0: 0x0000ffffe46480a8 libclrjit_unix_riscv64_arm64.so`DBG_DebugBreak at debugbreak.S:7
4 #include "unixasmmacros.inc"
5
6 LEAF_ENTRY DBG_DebugBreak, _TEXT
-> 7 EMIT_BREAKPOINT
8 ret
9 LEAF_END_MARKED DBG_DebugBreak, _TEXT
10
warning: This version of LLDB has no plugin for the language "assembler". Inspection of frame variables will be limited.
(lldb) bt
* thread #1, name = 'ilc', stop reason = signal SIGTRAP
* frame #0: 0x0000ffffe46480a8 libclrjit_unix_riscv64_arm64.so`DBG_DebugBreak at debugbreak.S:7
frame #1: 0x0000ffffe45ecc8c libclrjit_unix_riscv64_arm64.so`::DebugBreak() at debug.cpp:406:9 [opt]
frame #2: 0x0000ffffe4391a20 libclrjit_unix_riscv64_arm64.so`assertAbort(why="isValidSimm32(addr - (ssize_t)dst)", file="/runtime/src/coreclr/jit/emitriscv64.cpp", line=1630) at error.cpp:288:9 [opt]
frame #3: 0x0000ffffe45c4608 libclrjit_unix_riscv64_arm64.so`emitter::emitOutputCall(this=0x0000aaaaaaf4ee08, ig=<unavailable>, dst="\x97\U00000003", id=0x0000aaaaaaf6beec, code=<unavailable>) at emitriscv64.cpp:1630:9 [opt]
frame #4: 0x0000ffffe45c87c4 libclrjit_unix_riscv64_arm64.so`emitter::emitOutputInstr(insGroup*, emitter::instrDesc*, unsigned char**) [inlined] emitter::emitOutputInstr_OptsC(this=0x0000aaaaaaf4ee08, dst="\x97\U00000003", id=0x0000aaaaaaf6beec, ig=0x0000aaaaaaf6bce0, size=<unavailable>) at emitriscv64.cpp:3235:12 [opt]
frame #5: 0x0000ffffe45c8760 libclrjit_unix_riscv64_arm64.so`emitter::emitOutputInstr(this=0x0000aaaaaaf4ee08, ig=0x0000aaaaaaf6bce0, id=0x0000aaaaaaf6beec, dp=0x0000ffffffffad68) at emitriscv64.cpp:3293:20 [opt]
frame #6: 0x0000ffffe438aa14 libclrjit_unix_riscv64_arm64.so`emitter::emitIssue1Instr(this=0x0000aaaaaaf4ee08, ig=0x0000aaaaaaf6bce0, id=0x0000aaaaaaf6beec, dp=0x0000ffffffffad68) at emit.cpp:4346:10 [opt]
frame #7: 0x0000ffffe438beb0 libclrjit_unix_riscv64_arm64.so`emitter::emitEndCodeGen(this=0x0000aaaaaaf4ee08, comp=0x0000aaaaaaf4db28, contTrkPtrLcls=<unavailable>, fullyInt=<unavailable>, fullPtrMap=<unavailable>, xcptnsCount=3898893764, prologSize=0x0000aaaaaaf4edb4, epilogSize=<unavailable>, codeAddr=0x0000ffffffffbb88, codeAddrRW=0x0000aaaaaaf4ed78, coldCodeAddr=0x0000aaaaaaf4ed90, coldCodeAddrRW=0x0000aaaaaaf4ed98, consAddr=0x0000aaaaaaf4eda0, consAddrRW=0x0000aaaaaaf4eda8, instrCount=0x0000ffffffffae24) at emit.cpp:7314:43 [opt]
frame #8: 0x0000ffffe43543e0 libclrjit_unix_riscv64_arm64.so`CodeGen::genEmitMachineCode(this=0x0000aaaaaaf4e9b8) at codegencommon.cpp:2113:23 [opt]
frame #9: 0x0000ffffe435fcf0 libclrjit_unix_riscv64_arm64.so`CodeGenPhase::DoPhase(this=<unavailable>) at codegen.h:1727:9 [opt]
frame #10: 0x0000ffffe4547c4c libclrjit_unix_riscv64_arm64.so`Phase::Run(this=0x0000ffffffffaed0) at phase.cpp:61:26 [opt]
frame #11: 0x0000ffffe4353e88 libclrjit_unix_riscv64_arm64.so`CodeGen::genGenerateCode(void**, unsigned int*) [inlined] DoPhase(_codeGen=0x0000aaaaaaf4e9b8, _phase=PHASE_EMIT_CODE, _action=<unavailable>) at codegen.h:1741:11 [opt]
frame #12: 0x0000ffffe4353e5c libclrjit_unix_riscv64_arm64.so`CodeGen::genGenerateCode(this=0x0000aaaaaaf4e9b8, codePtr=0x0000ffffffffbb88, nativeSizeOfCode=<unavailable>) at codegencommon.cpp:1774:5 [opt]
frame #13: 0x0000ffffe43704a0 libclrjit_unix_riscv64_arm64.so`Compiler::compCompile(this=0x0000aaaaaaf4db28, methodCodePtr=<unavailable>, methodCodeSize=<unavailable>, compileFlags=0x0000ffffffffbbb0) at compiler.cpp:5266:14 [opt]
frame #14: 0x0000ffffe4373eec libclrjit_unix_riscv64_arm64.so`Compiler::compCompileHelper(this=0x0000aaaaaaf4db28, classPtr=<unavailable>, compHnd=<unavailable>, methodInfo=<unavailable>, methodCodePtr=0x0000ffffffffbb88, methodCodeSize=0x0000ffffffffbf88, compileFlags=0x0000ffffffffbbb0) at compiler.cpp:7247:5 [opt]
frame #15: 0x0000ffffe437230c libclrjit_unix_riscv64_arm64.so`Compiler::compCompile(CORINFO_MODULE_STRUCT_*, void**, unsigned int*, JitFlags*) [inlined] Compiler::compCompile(CORINFO_MODULE_STRUCT_*, void**, unsigned int*, JitFlags*)::$_0::operator()(this=<unavailable>, __JITpParam=<unavailable>) const at compiler.cpp:6435:28 [opt]
frame #16: 0x0000ffffe43722f4 libclrjit_unix_riscv64_arm64.so`Compiler::compCompile(this=0x0000aaaaaaf4db28, classPtr=0x4000000000420128, methodCodePtr=0x0000ffffffffbb88, methodCodeSize=0x0000ffffffffbf88, compileFlags=0x0000ffffffffbbb0) at compiler.cpp:6454:5 [opt]
frame #17: 0x0000ffffe4374e74 libclrjit_unix_riscv64_arm64.so`jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*) [inlined] jitNativeCode(this=<unavailable>, __JITpParam=<unavailable>)::$_0::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::__JITParam*) const::'lambda'(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::$_0::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::__JITParam*) const::__JITParam*)::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::$_0::operator()(jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::__JITParam*) const::__JITParam*) const at compiler.cpp:7898:32 [opt]
frame #18: 0x0000ffffe4374d20 libclrjit_unix_riscv64_arm64.so`jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*) [inlined] jitNativeCode(CORINFO_METHOD_STRUCT_*, CORINFO_MODULE_STRUCT_*, ICorJitInfo*, CORINFO_METHOD_INFO*, void**, unsigned int*, JitFlags*, void*)::$_0::operator()(this=<unavailable>, __JITpParam=<unavailable>) const at compiler.cpp:7922:9 [opt]
frame #19: 0x0000ffffe4374d10 libclrjit_unix_riscv64_arm64.so`jitNativeCode(methodHnd=0x4000000000420120, classPtr=0x4000000000420128, compHnd=0x0000ffffffffbc90, methodInfo=0x0000ffffffffbfa8, methodCodePtr=0x0000ffffffffbb88, methodCodeSize=0x0000ffffffffbf88, compileFlags=0x0000ffffffffbbb0, inlineInfoPtr=0x0000000000000000) at compiler.cpp:7924:5 [opt]
frame #20: 0x0000ffffe437feec libclrjit_unix_riscv64_arm64.so`CILJit::compileMethod(this=<unavailable>, compHnd=0x0000ffffffffbc90, methodInfo=0x0000ffffffffbfa8, flags=<unavailable>, entryAddress=0x0000ffffffffbf90, nativeSizeOfCode=0x0000ffffffffbf88) at ee_il_dll.cpp:291:14 [opt]
frame #21: 0x0000ffffeefcf0c4 libjitinterface_arm64.so`JitCompileMethod(ppException=0x0000ffffffffbf98, pJit=0x0000ffffe4688958, thisHandle=0x0000ffffffffbfa0, callbacks=0x0000aaaaaaf4b810, methodInfo=0x0000ffffffffbfa8, flags=4294967295, entryAddress=0x0000ffffffffbf90, nativeSizeOfCode=0x0000ffffffffbf88) at jitwrapper.cpp:36:22
frame #22: 0x0000fffff2215644
frame #23: 0x0000fffff221230c
frame #24: 0x0000fffff2211e64
frame #25: 0x0000fffff22118b0
frame #26: 0x0000fffff220ef9c
frame #27: 0x0000fffff1ae29a0
frame #28: 0x0000fffff1b85da8
frame #29: 0x0000ffffef32d2e0
frame #30: 0x0000ffffef34f31c
frame #31: 0x0000ffffef35ce6c
frame #32: 0x0000ffffef35bb80
frame #33: 0x0000ffffef34d0f4
frame #34: 0x0000fffff1b89070
frame #35: 0x0000fffff1ae1a88
frame #36: 0x0000fffff1b8b8a4
frame #37: 0x0000fffff1b897e8
frame #38: 0x0000fffff220ee84
frame #39: 0x0000fffff220eb8c
frame #40: 0x0000fffff1ae0b58
frame #41: 0x0000fffff01d57ac
frame #42: 0x0000fffff220cf40
frame #43: 0x0000fffff220ce3c
frame #44: 0x0000fffff0180c0c
frame #45: 0x0000fffff017b060
frame #46: 0x0000fffff017a940
frame #47: 0x0000fffff017a768
frame #48: 0x0000fffff0161eb8
frame #49: 0x0000fffff749c9e8 libcoreclr.so`___lldb_unnamed_symbol9959 + 132
frame #50: 0x0000fffff730bd60 libcoreclr.so`___lldb_unnamed_symbol4754 + 768
frame #51: 0x0000fffff7202d14 libcoreclr.so`___lldb_unnamed_symbol861 + 756
frame #52: 0x0000fffff720306c libcoreclr.so`___lldb_unnamed_symbol863 + 272
frame #53: 0x0000fffff722a00c libcoreclr.so`___lldb_unnamed_symbol1538 + 652
frame #54: 0x0000fffff71efcd8 libcoreclr.so`coreclr_execute_assembly + 168
frame #55: 0x0000fffff793ad70 libhostpolicy.so`___lldb_unnamed_symbol532 + 856
frame #56: 0x0000fffff793bd44 libhostpolicy.so`corehost_main + 340
frame #57: 0x0000fffff79af578 libhostfxr.so`___lldb_unnamed_symbol379 + 1188
frame #58: 0x0000fffff79ae898 libhostfxr.so`___lldb_unnamed_symbol377 + 760
frame #59: 0x0000fffff79a9114 libhostfxr.so`hostfxr_main_startupinfo + 208
frame #60: 0x0000aaaaaaab73b0 ilc`___lldb_unnamed_symbol227 + 960
frame #61: 0x0000aaaaaaab76e0 ilc`___lldb_unnamed_symbol229 + 184
frame #62: 0x0000fffff7a284c4 libc.so.6`___lldb_unnamed_symbol3097 + 116
frame #63: 0x0000fffff7a28598 libc.so.6`__libc_start_main + 152 |
#111317 fixes ilc object file writing. The next step is to figure out the linker failure: root@0900f1880a04:/app1$ "clang" "obj/Release/net10.0/linux-riscv64/native/app1.o" \
-o "bin/Release/net10.0/linux-riscv64/native/app1" \
-Wl,--version-script=obj/Release/net10.0/linux-x64/native/app1.exports \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/ilc-published/libSystem.Native.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/ilc-published/libSystem.Globalization.Native.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/ilc-published/libSystem.IO.Compression.Native.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/ilc-published/libSystem.Net.Security.Native.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/ilc-published/libSystem.Security.Cryptography.Native.OpenSsl.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/aotsdk/libbootstrapper.o \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/aotsdk/libRuntime.WorkstationGC.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/aotsdk/libeventpipe-disabled.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/aotsdk/libstandalonegc-disabled.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/aotsdk/libaotminipal.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/aotsdk/libstdc++compat.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/ilc-published/libz.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/ilc-published/libbrotlienc.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/ilc-published/libbrotlidec.a \
/runtime/artifacts/bin/coreclr/linux.riscv64.Checked/ilc-published/libbrotlicommon.a \
--sysroot="/crossrootfs/riscv64" --target=riscv64-linux-gnu -g \
-Wl,--export-dynamic -gz=zlib -fuse-ld=lld -Wl,-rpath,'$ORIGIN' -Wl,--build-id=sha1 -Wl,--as-needed -pthread \
-ldl -lrt -lm -pie -Wl,-pie -Wl,-z,relro -Wl,-z,now -Wl,--eh-frame-hdr -Wl,--discard-all -Wl,--gc-sections
ld.lld: error: unknown relocation (3) against symbol System_Console_System_ConsoleKeyInfo____GetFieldHelper
ld.lld: error: unknown relocation (3) against symbol _lsda0System_Console_System_ConsoleKeyInfo____GetFieldHelper
ld.lld: error: unknown relocation (3) against symbol S_P_CoreLib_System_AttributeUsageAttribute____GetFieldHelper
ld.lld: error: unknown relocation (3) against symbol _lsda0System_Console_System_ConsoleKeyInfo____GetFieldHelper
ld.lld: error: unknown relocation (3) against symbol S_P_CoreLib_System_CLSCompliantAttribute____GetFieldHelper
... I changed 0x3 in ntimage.h and ilc to 0x2, but this relocation 3 error is not going away. Not sure yet where it's coming from. 😅 |
That would be |
With #111735, it gets us a little far on our helloworld journey. Next issue is: # also put a breakpoint in RhpInterfaceDispatchSlow since the PC gets corrupted and it disconnects the chain
Thread 1 "app1" received signal SIGSEGV, Segmentation fault.
S_P_CoreLib_System_Runtime_CachedInterfaceDispatch__RhResolveDispatchWorker (pObject=..., cell=0x2aaac73790 <S_P_CoreLib_System_Runtime_CachedInterfaceDispatch__RhpCidResolve>, cellInfo=...)
at /runtime/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CachedInterfaceDispatch.cs:128
128 MethodTable* pInstanceType = pObject.GetMethodTable();
(gdb) bt
#0 S_P_CoreLib_System_Runtime_CachedInterfaceDispatch__RhResolveDispatchWorker (pObject=..., cell=0x2aaac73790 <S_P_CoreLib_System_Runtime_CachedInterfaceDispatch__RhpCidResolve>, cellInfo=...)
at /runtime/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CachedInterfaceDispatch.cs:128
#1 0x0000002aaac73810 in S_P_CoreLib_System_Runtime_CachedInterfaceDispatch__RhpCidResolve_Worker (pObject=..., pCell=183253809040) at /runtime/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CachedInterfaceDispatch.cs:28
#2 0x0000002aaac737b0 in S_P_CoreLib_System_Runtime_CachedInterfaceDispatch__RhpCidResolve (callerTransitionBlockParam=-6138604891393753078, pCell=183253809040)
at /runtime/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CachedInterfaceDispatch.cs:21
#3 0x0000002aaac12782 in RhpUniversalTransition_DebugStepTailCall () at /runtime/src/coreclr/nativeaot/Runtime/riscv64/UniversalTransition.S:179 There is probably still some register mapping need work in StubDispatch.S UniversalTransition.S. I fixed some by comparing the relationship between callee (JIT'd or C++) and caller in arm64 and those of riscv64, now the call to transition method goes through but fails most likely some arg mapping is off. |
Regarding the workflow #106223 (comment), I have switched to all debug configs. For rebuilds, we can make it faster. e.g. if we make a change in # repeat step
$ /runtime/build.sh -arch riscv64 -cross -s clr.nativeaotruntime -c Debug -p:StageOneBuild=true --keepnativesymbols true
$ cp /runtime/artifacts/bin/coreclr/linux.riscv64.Debug/arm64/libclrjit_unix_riscv64_arm64.so /runtime/artifacts/bin/coreclr/linux.arm64.Debug/ilc-published If it's src/coreclr/tools, the StageTwo. Every now and then, I do a clean rebuild just in case. |
The multi-threading issues are going to be pain to debug. We should probably start by fixing There's also this thing which was fixed recently for ARM64 (#106219): --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64Emitter.cs
+++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64Emitter.cs
@@ -25,6 +25,11 @@ public void EmitBreak()
Builder.EmitUInt(0x00100073);
}
+ public void EmitFENCE()
+ {
+ Builder.EmitUInt(0x0ff0000f);
+ }
+
public void EmitLI(Register regDst, int offset)
{
Debug.Assert((offset >= -2048) && (offset <= 2047));
diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64ReadyToRunGenericHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64ReadyToRunGenericHelperNode.cs
index 584b37e53a7..9514c05cb93 100644
--- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64ReadyToRunGenericHelperNode.cs
+++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64ReadyToRunGenericHelperNode.cs
@@ -75,6 +75,7 @@ protected sealed override void EmitCode(NodeFactory factory, ref RiscV64Emitter
// We need to trigger the cctor before returning the base. It is stored at the beginning of the non-GC statics region.
encoder.EmitADDI(encoder.TargetRegister.Arg3, encoder.TargetRegister.Arg0, -NonGCStaticsNode.GetClassConstructorContextSize(factory.Target));
encoder.EmitLD(encoder.TargetRegister.Arg2, encoder.TargetRegister.Arg3, 0);
+ encoder.EmitFENCE();
encoder.EmitRETIfZero(encoder.TargetRegister.Arg2);
encoder.EmitMOV(encoder.TargetRegister.Arg1, encoder.TargetRegister.Result);
@@ -106,6 +107,7 @@ protected sealed override void EmitCode(NodeFactory factory, ref RiscV64Emitter
encoder.EmitADDI(encoder.TargetRegister.Arg2, encoder.TargetRegister.Arg2, -NonGCStaticsNode.GetClassConstructorContextSize(factory.Target));
encoder.EmitLD(encoder.TargetRegister.Arg3, encoder.TargetRegister.Arg2, 0);
+ encoder.EmitFENCE();
encoder.EmitRETIfZero(encoder.TargetRegister.Arg3);
encoder.EmitMOV(encoder.TargetRegister.Arg1, encoder.TargetRegister.Result); |
I made an attempt to fix the multi-threaded issues and had some luck with running --- a/src/coreclr/nativeaot/Runtime/riscv64/WriteBarriers.S
+++ b/src/coreclr/nativeaot/Runtime/riscv64/WriteBarriers.S
@@ -303,6 +303,7 @@ LEAF_END RhpAssignRef, _TEXT
// t0, t1, t2, t6: trashed
//
LEAF_ENTRY RhpCheckedLockCmpXchg
+ fence
LOCAL_LABEL(CmpXchgRetry):
// Load the current value at the destination address.
@@ -342,13 +343,15 @@ LEAF_END RhpCheckedLockCmpXchg
//
// On exit:
// a0: original value of objectref
-// t1: trashed
-// t3, t6, t4: trashed
+// t1, t2, t6: trashed
//
LEAF_ENTRY RhpCheckedXchg
+ fence
- ld t1, 0(a0)
- sd a1, 0(a0)
+RhpCheckedXchgRetry:
+ lr.d t1, 0(a0)
+ sc.d t2, a1, 0(a0)
+ bnez t2, RhpCheckedXchgRetry // if store conditional failed, retry
DoCardsXchg:
// We have successfully updated the value of the objectref so now we need a GC write barrier. I'll commit it as WIP. You should review it carefully. |
|
Running UnitTests a few times gave me:
another run:
|
Ah, I had to delete
sometimes:
and sometimes:
|
I believe that the bug affecting
I can reproduce those. Apparently my previous run used |
With
although, there is enough: $ free -m
total used free shared buff/cache available
Mem: 15904 938 14305 4 890 14966
Swap: 0 0 0 |
A P/Invoke test is failing. (gdb) b PInvokeNative.cpp:341
(gdb) b PInvoke.cs:702
(gdb) r
Thread 1 "PInvoke" hit Breakpoint 4, ReversePInvoke_Int (fnPtr=0x3ff7fbe000) at /runtime/src/tests/nativeaot/SmokeTests/PInvoke/PInvokeNative.cpp:341
341 return fnPtr(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) == 55;
(gdb) c
Continuing.
Thread 1 "PInvoke" hit Breakpoint 6, PInvoke_PInvokeTests_Program__Sum (a=-136619912, b=2, c=3, d=4, e=5, f=-136620160, g=7, h=8, i=9, j=10) at /runtime/src/tests/nativeaot/SmokeTests/PInvoke/PInvoke.cs:702
702 return a + b + c + d + e + f + g + h + i + j;
(gdb) bt
#0 PInvoke_PInvokeTests_Program__Sum (a=-136619912, b=2, c=3, d=4, e=5, f=-136620160, g=7, h=8, i=9, j=10) at /runtime/src/tests/nativeaot/SmokeTests/PInvoke/PInvoke.cs:702
#1 0x0000002aaaf99638 in Internal_CompilerGenerated__Module___<ReverseOpenStaticDelegateStub>PInvoke_PInvokeTests_Program_Delegate_Int () at /runtime/src/coreclr/nativeaot/Common/src/System/Collections/Generic/LowLevelDictionary.cs:289
#2 0x0000003ff7fd1800 in ReversePInvoke_Int (fnPtr=0x3ff7fbe000) at /runtime/src/tests/nativeaot/SmokeTests/PInvoke/PInvokeNative.cpp:341
#3 0x0000002aaad05cf0 in PInvoke_PInvokeTests_Program__ReversePInvoke_Int ()
#4 0x0000002aaad0c484 in PInvoke_PInvokeTests_Program__TestDelegate () at /runtime/src/tests/nativeaot/SmokeTests/PInvoke/PInvoke.cs:636
#5 0x0000002aaad0a9c4 in PInvoke_PInvokeTests_Program__Main () at /runtime/src/tests/nativeaot/SmokeTests/PInvoke/PInvoke.cs:339
#6 0x0000002aaafa04d4 in __managed__Main () at /runtime/src/coreclr/nativeaot/Common/src/System/Collections/Generic/LowLevelDictionary.cs:289
#7 0x0000002aaac5483a in main (argc=1, argv=0x3ffffff138) at /runtime/src/coreclr/nativeaot/Bootstrap/main.cpp:225
|
At least some of the PInvoke parameter trashing happens in At
(also, |
Thanks! I've pushed a fix. When we will switch to tlsdesc in the future, these prolog/epilog won't be needed (as linker magic due to tlsdesc preserves it). I kept the old version because it requires "everything new" libc,binutils-bfd,lld etc. from 2024. In a year or so, we can bump the baseline and switch to tlsdesc. |
Note that to be completely safe we should save all (FWIW I am running up-to-date Ubuntu STS so I should have all the packages necessary for the TLSDESC to work.) |
Bianbu 2.1 (based on Ubuntu 24.04) is using linux 6.6, they are upstreaming their driver patches to linux, so hopefully I will be able to switch the distro soon (or they will switch to kernel 6.8 or above + the newer libc with TLSDESC 🙂). SpacemiT K1 SoC is also used in other devices (Milk-V https://github.com/milkv-jupiter/jupiter-bianbu-build and boards), so I hope people will extract the patches in other distros rather quickly. We can also sync with @tomeksowi et al. on baseline versions after the port completion. |
Pushed a7 (a0 is preserved at call-sites). PInvoke tests are passing. 👍 |
This one is sometimes stuck and from second terminal, strace -p shows it's waiting for futex sync: $ strace -p 89552
strace: Process 89552 attached
futex(0x2ac8e17904, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY
(nothing afterwards) and gdb -p: Attaching to process 89552
[New LWP 97850]
[New LWP 97196]
[New LWP 97025]
[New LWP 95070]
[New LWP 93241]
[New LWP 89556]
[New LWP 89554]
[New LWP 89553]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/riscv64-linux-gnu/libthread_db.so.1".
0x0000003fb635c742 in __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x2ac8e17904) at ./nptl/futex-internal.c:57
warning: 57 ./nptl/futex-internal.c: No such file or directory
(gdb) bt
#0 0x0000003fb635c742 in __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x2ac8e17904) at ./nptl/futex-internal.c:57
#1 __futex_abstimed_wait_common (futex_word=futex_word@entry=0x2ac8e17904, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0, cancel=cancel@entry=true) at ./nptl/futex-internal.c:87
#2 0x0000003fb635c77c in __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x2ac8e17904, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0) at ./nptl/futex-internal.c:139
#3 0x0000003fb635e7ac in __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x2ac8e178b0, cond=0x2ac8e178d8) at ./nptl/pthread_cond_wait.c:503
#4 ___pthread_cond_wait (cond=0x2ac8e178d8, mutex=0x2ac8e178b0) at ./nptl/pthread_cond_wait.c:627
#5 0x0000002ac865956a in SystemNative_LowLevelMonitor_Wait (monitor=0x2ac8e178b0) at /runtime/src/native/libs/System.Native/pal_threading.c:153
#6 0x0000002ac89b3af0 in S_P_CoreLib_Interop_Sys__LowLevelMonitor_Wait ()
at /runtime/artifacts/obj/coreclr/nativeaot/System.Private.CoreLib/linux.riscv64.Debug/generated/Microsoft.Interop.LibraryImportGenerator/Microsoft.Interop.LibraryImportGenerator/LibraryImports.g.cs:2524
#7 0x0000002ac88adacc in S_P_CoreLib_System_Threading_LowLevelMonitor__WaitCore (this=...) at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelMonitor.Unix.cs:44
#8 0x0000002ac88ad77c in S_P_CoreLib_System_Threading_LowLevelMonitor__Wait (this=...) at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelMonitor.cs:91
#9 0x0000002ac89e5394 in S_P_CoreLib_System_Threading_WaitSubsystem_ThreadWaitInfo__Wait (this=..., timeoutMilliseconds=-1, interruptible=true, isSleep=false, lockHolder=...)
at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.ThreadWaitInfo.Unix.cs:322
#10 0x0000002ac89e7b74 in S_P_CoreLib_System_Threading_WaitSubsystem_WaitableObject__Wait_Locked (this=..., waitInfo=..., timeoutMilliseconds=-1, interruptible=true, prioritize=false, lockHolder=...)
at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.WaitableObject.Unix.cs:368
#11 0x0000002ac89e76f0 in S_P_CoreLib_System_Threading_WaitSubsystem_WaitableObject__Wait (this=..., waitInfo=..., timeoutMilliseconds=-1, interruptible=true, prioritize=false)
at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.WaitableObject.Unix.cs:320
#12 0x0000002ac88c1aa8 in S_P_CoreLib_System_Threading_WaitSubsystem__Wait_0 (waitableObject=..., timeoutMilliseconds=-1, interruptible=true, prioritize=false)
at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.Unix.cs:339
#13 0x0000002ac88c19a0 in S_P_CoreLib_System_Threading_WaitSubsystem__Wait (handle=272382796208, timeoutMilliseconds=-1, interruptible=true) at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.Unix.cs:327
#14 0x0000002ac88bc6e0 in S_P_CoreLib_System_Threading_WaitHandle__WaitOneCore (handle=272382796208, millisecondsTimeout=-1, useTrivialWaits=false) at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.Unix.cs:11
#15 0x0000002ac88bab58 in S_P_CoreLib_System_Threading_WaitHandle__WaitOneNoCheck (this=..., millisecondsTimeout=-1, useTrivialWaits=false, associatedObject=..., waitSource=Unknown)
at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs:183
#16 0x0000002ac88ba67c in S_P_CoreLib_System_Threading_WaitHandle__WaitOne (this=..., millisecondsTimeout=-1) at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs:104
#17 0x0000002ac88a5864 in S_P_CoreLib_System_Threading_Thread__JoinInternal (this=..., millisecondsTimeout=-1) at /runtime/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Unix.cs:82
#18 0x0000002ac88a4768 in S_P_CoreLib_System_Threading_Thread__Join (this=..., millisecondsTimeout=-1) at /runtime/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.cs:327
#19 0x0000002ac88a6ac8 in S_P_CoreLib_System_Threading_Thread__Join_0 (this=...) at /runtime/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs:540
#20 0x0000002ac8a6f174 in UnitTests_ThreadTest__ExpectPassed (testName=..., expectedPassed=10000) at /runtime/src/tests/nativeaot/SmokeTests/UnitTests/BasicThreading.cs:328
#21 0x0000002ac8a70748 in UnitTests_ThreadTest__TestConcurrentIsBackgroundProperty () at /runtime/src/tests/nativeaot/SmokeTests/UnitTests/BasicThreading.cs:448
#22 0x0000002ac8a71798 in UnitTests_ThreadTest__Run () at /runtime/src/tests/nativeaot/SmokeTests/UnitTests/BasicThreading.cs:605
#23 0x0000002ac8a6dddc in UnitTests_BasicThreading__Run () at /runtime/src/tests/nativeaot/SmokeTests/UnitTests/BasicThreading.cs:25
#24 0x0000002ac8acaad4 in S_P_CoreLib_System_Func_1<Int32>__InvokeOpenStaticThunk () at /runtime/src/libraries/System.Private.CoreLib/src/System/Array.Enumerators.cs:111
#25 0x0000002ac8a81394 in UnitTests_Program____Main___g__RunTest_0_0 (t=..., name=...) at /runtime/src/tests/nativeaot/SmokeTests/UnitTests/Main.cs:23
#26 0x0000002ac8a80e40 in UnitTests_Program___Main__ (args=...) at /runtime/src/tests/nativeaot/SmokeTests/UnitTests/Main.cs:7
#27 0x0000002ac8b8a30c in __managed__Main () at /runtime/src/libraries/System.Private.CoreLib/src/System/ValueTuple.cs:793
#28 0x0000002ac8669684 in main (argc=1, argv=0x3ffa116178) at /runtime/src/coreclr/nativeaot/Bootstrap/main.cpp:225 When I run it with |
That was happening to me before I made the (Interrupting the syscall likely forced a loop in |
Interesting, I have Overall status of smoke tests is looking much better now, exceptions are:
I think we can send a PR after resolving 1. I haven't done any testing with Release build yet, but we can cover it after this phase is over (during the AOT libs tests 🙂). |
I've started looking into it but haven't made much progress. From time to time I can make it crash inside the method table check (first pointer in object) with null value. One time it happened I dumped the pointer address and traced it back on the stack:
It was saved in the frame 7 on the stack. The value on the stack at
This should have been reported during the GC, yet somehow the object was collected and overwritten with zeroes. (On second thought, I didn't try tracing back in the JIT dump if there was a moment where it was not reported correctly before it was written to the stack location.) |
The garbage value I observed was loaded from stack to register at this instruction:
The only time that stack location is referenced is in
Ah, nevermind, I see it now - |
I think the instruction masks in May be worth checking. We cannot unwind prologs properly, or rather unwind to wrong functions or apply incorrect GC info, so if this was indeed incorrect it could explain some of the crashes in the heavily multi-threaded/GC tests. Here's what I think the constants should be:
(I didn't actually check it yet. Also, it's missing the "addi sp, sp, imm" pattern.) |
I ended up with this patch for diff --git a/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp b/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp
index a1e2e507df8..80b15694ece 100644
--- a/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp
+++ b/src/coreclr/nativeaot/Runtime/unix/UnixNativeCodeManager.cpp
@@ -699,22 +699,23 @@ int UnixNativeCodeManager::IsInProlog(MethodInfo * pMethodInfo, PTR_VOID pvAddre
#elif defined(TARGET_RISCV64)
// store pair with signed offset
-// 0100 00xx xxxxxxxx xxxx xxxx xxxx xxxx
-#define STW_PAIR_BITS 0x04000000
-#define STW_PAIR_MASK 0xFC000000
+#define STW_PAIR_BITS 0x00003023
+#define STW_PAIR_MASK 0x0000707F
-// add fp, sp, x
-// addi fp, sp, x
-// 0000 0001 100x xxxx xxxx xxxx 0000 0000
-#define ADD_FP_SP_BITS 0x01C00000
-#define ADD_FP_SP_MASK 0xFFFFE000
-
-#define STW_PAIR_RS1_MASK 0xF80
-#define STW_PAIR_RS1_SP 0xF80
-#define STW_PAIR_RS1_FP 0xF00
-#define STW_PAIR_RS2_MASK 0xF00
-#define STW_PAIR_RS2_FP 0xF00
-#define STW_PAIR_RS2_RA 0xF40
+// add[i] fp, sp, x
+#define ADD_FP_SP_BITS 0x00010413
+#define ADD_FP_SP_MASK 0x000FFFFF
+
+// add[i] sp, sp, x
+#define ADD_SP_SP_BITS 0x00010113
+#define ADD_SP_SP_MASK 0x000FFFFF
+
+#define STW_PAIR_RS1_MASK 0xF8000
+#define STW_PAIR_RS1_SP 0x10000
+#define STW_PAIR_RS1_FP 0x40000
+#define STW_PAIR_RS2_MASK 0x1F00000
+#define STW_PAIR_RS2_FP 0x800000
+#define STW_PAIR_RS2_RA 0x100000
UnixNativeMethodInfo * pNativeMethodInfo = (UnixNativeMethodInfo *)pMethodInfo;
ASSERT(pNativeMethodInfo != NULL);
@@ -740,7 +741,7 @@ int UnixNativeCodeManager::IsInProlog(MethodInfo * pMethodInfo, PTR_VOID pvAddre
{
establishedFp = true;
}
- else
+ else if ((instr & ADD_SP_SP_MASK) != ADD_SP_SP_BITS)
{
// JIT generates other patterns into the prolog that we currently don't
// recognize (saving unpaired register, stack pointer adjustments). We It doesn't fix the DynamicGenerics prolog by itself but it should still be reviewed for correctness. UPD: |
Should we apply it to the branch? |
I pushed it, but it certainly deserves extra scrutiny. |
So far testing has not reveled any regression/difference. Two other types of failures in DynamicGenerics:
Aside from |
I found some bugs in the GC hijacking assembly code. Trying to fix that and I'll report back. |
Here's my current diff. It doesn't fix it but it changes the failure mode quite a lot, so it may be on the right track. Firstly, diff --git a/src/coreclr/nativeaot/Runtime/riscv64/GcProbe.S b/src/coreclr/nativeaot/Runtime/riscv64/GcProbe.S
index 019199d548b..fc25713938e 100644
--- a/src/coreclr/nativeaot/Runtime/riscv64/GcProbe.S
+++ b/src/coreclr/nativeaot/Runtime/riscv64/GcProbe.S
@@ -44,7 +44,7 @@
# Perform the rest of the PInvokeTransitionFrame initialization.
sd \threadReg, OFFSETOF__PInvokeTransitionFrame__m_pThread(sp) # Thread * (unused by stackwalker)
- sd \BITMASK, (OFFSETOF__PInvokeTransitionFrame__m_pThread + 8)(sp) # Save the register bitmask passed in by caller
+ sd \BITMASK, OFFSETOF__PInvokeTransitionFrame__m_Flags(sp) # Save the register bitmask passed in by caller
addi \trashReg, sp, PROBE_FRAME_SIZE # Recover value of caller's SP
sd \trashReg, 0x78(sp) # Save caller's SP
@@ -100,14 +100,13 @@
NESTED_ENTRY RhpGcProbeHijack, _TEXT, NoHandler
FixupHijackedCallstack
- PREPARE_EXTERNAL_VAR_INDIRECT_W RhpTrapThreads, a3
- andi t3, a3, 1 << TrapThreadsFlags_TrapThreads_Bit
+ PREPARE_EXTERNAL_VAR_INDIRECT_W RhpTrapThreads, t3
+ andi t3, t3, 1 << TrapThreadsFlags_TrapThreads_Bit
bnez t3, LOCAL_LABEL(WaitForGC)
jr ra
LOCAL_LABEL(WaitForGC):
- li t6, (DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_A0 + PTFF_SAVE_A1 + PTFF_THREAD_HIJACK_HI)
- or t3, t3, t6
+ li t3, (DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_A0 + PTFF_SAVE_A1 + (PTFF_THREAD_HIJACK_HI << 32))
tail C_FUNC(RhpWaitForGC)
NESTED_END RhpGcProbeHijack
diff --git a/src/coreclr/nativeaot/Runtime/unix/unixasmmacrosloongarch64.inc b/src/coreclr/nativeaot/Runtime/unix/unixasmmacrosloongarch64.inc
index b78210c8f85..535d7ca303c 100644
--- a/src/coreclr/nativeaot/Runtime/unix/unixasmmacrosloongarch64.inc
+++ b/src/coreclr/nativeaot/Runtime/unix/unixasmmacrosloongarch64.inc
@@ -198,7 +198,7 @@ C_FUNC(\Name):
#define PTFF_SAVE_R4 0x00000800
#define PTFF_SAVE_R5 0x00001000
#define PTFF_SAVE_ALL_PRESERVED 0x000001FF // NOTE: r23-r31
-#define PTFF_THREAD_HIJACK_HI 0x00000002 // upper 32 bits of the PTFF_THREAD_HIJACK
+#define PTFF_THREAD_HIJACK_HI 0x00000001 // upper 32 bits of the PTFF_THREAD_HIJACK
#define DEFAULT_FRAME_SAVE_FLAGS (PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_SP)
|
I pushed the above change with few minor tweaks. There's still something way off though... I am pretty sure that I got trashed registers again because To get further, here's a debugging trick: --- a/src/coreclr/nativeaot/Runtime/riscv64/GcProbe.S
+++ b/src/coreclr/nativeaot/Runtime/riscv64/GcProbe.S
@@ -101,6 +101,7 @@
//
NESTED_ENTRY RhpGcProbeHijack, _TEXT, NoHandler
FixupHijackedCallstack
+ ret
PREPARE_EXTERNAL_VAR_INDIRECT_W RhpTrapThreads, t3
andi t3, t3, 1 << TrapThreadsFlags_TrapThreads_Bit We can skip the GC check in the hijack. It currently still fails which means that the hijacking trashes the state. This could either be the hijacking machinery, or |
Aaargh, |
I think |
Congrats! 🎉 I tested it, it passes on device and qemu. Also, UnitTests suite is also passing now on my device consistently. Opened #112736. |
This is to track the progress of nativeaot port on riscv64 architecture.
WIP initial translation (based on @sunlijun-610's LA64 port):
main...am11:runtime:feature/nativeaot/riscv64-port
The text was updated successfully, but these errors were encountered: