Sync aug24 release/8.0-tizen (#595) accepted/tizen_unified_toolchain accepted/tizen_unified_x accepted/tizen_unified_x_asan tizen_dev accepted/tizen/unified/toolchain/20241004.101213 accepted/tizen/unified/x/20240913.014835 accepted/tizen/unified/x/asan/20241013.235448
authorTimur Mustafin/Advanced System SW Lab /SRR/Staff Engineer/Samsung Electronics <t.mustafin@partner.samsung.com>
Thu, 12 Sep 2024 06:56:46 +0000 (09:56 +0300)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 12 Sep 2024 06:56:46 +0000 (09:56 +0300)
commitddb8e3e11839e56692b8097dc1df7cf5aa54df70
treee5f623965dacaf9957225b8d311ee5c7656a5c73
parent8eabbfb486323ee44fec27f4f396234bef49891e
Sync aug24 release/8.0-tizen (#595)

* [RISC-V] Add crossgen2 for riscv64 (#95188)

* Add crossgen2 for riscv64

* Fix review comments

* Fix review

* [RISC-V] Enable R2RDump (#97156)

* [RISC-V] Fix errors in crosgen2 for risc-v (#97368)

* [RISC-V] Fix crossgen2

* [RISC-V] Fix typo in codegen

* [RISC-V] Update assert to support all rel insts

* [RISC-V] Fix helper function call

* [RISC-V] Update GetRISCV64PassStructInRegisterFlags

* [RISC-V] Fix int arg reg passing for float type

A failure during crossgen2 SPC.dll
`System.Diagnostics.Tracing.NativeRuntimeEventSource:LogThreadPoolWorkerThreadAdjustmentStats(double,double,double,double,double,double,double,double,double,ushort,ushort)`

* [RISC-V] Update EPILOG_WITH_TRANSITION_BLOCK_RETURN

* [RISC-V] Update indentation in dump

* [RISC-V] Fix stubs

* [RISC-V] Fix virtualcallstubcpu

* [RISC-V] Update a comment

* [RISC-V] Update RO data block

* [RISC-V] Fix data overwrites

* [RISC-V] Fix typo

* [RISC-V] Fix register number of A3

* [RISC-V] Code Formatting

* [RISC-V] Fix format and typos

* Revert "[RISC-V] Fix int arg reg passing for float type"

This reverts commit 381858cb2335782d66e8a6439db9c6f053adff21.

* [RISC-V] Fix a typo in a comment

* [RISC-V] Fix error when arg type and arg reg mismatch

* [RISC-V] Rename according to review

* [LoongArch64] Remove LA64 specific handling for unspilling

* Enable riscv64 R2R in installer (#96941)

* [RISC-V] R2RDump to handle System.Private.CoreLib (#98849)

* Add missing codes for RISC-V to enable R2RDump'ing unwind and gcInfo

* Handle decode failures from coredistools in R2RDump instead of getting stuck in an infinite loop

* Remove unused dll import DumpCodeBlock

* [RISC-V] Enable crossgen for corelib (#99436)

* [RISC-V] Fix alignment for vector types (#99589)

For vector256 and vector512, set possible max alignment value.

Reference
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc

* Update Architecture to unknown machine (#101038)

* Update Architecture to unknown machine

* Update src/tools/illink/src/linker/Linker.Steps/OutputStep.cs

Suggested by @am11. Thank you.

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
---------

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
* [RISC-V] Simplify flags for passing struct in registers (#100080)

* [RISC-V] Fix struct info value in crossgen2

* [RISC-V] Fix assertion in crossgen

Asserts in `./Interop/StructMarshalling/PInvoke/MarshalStructAsLayoutExp/MarshalStructAsLayoutExp.sh`
Error message is
`Assertion failed 'roundUp(structSize, TARGET_POINTER_SIZE) == roundUp(loadExtent, TARGET_POINTER_SIZE)' in 'Managed:MarshalStructAsParam_AsExpByVal(int)' during 'Morph - Global' (IL size 2208; hash 0x9fd9734a; MinOpts)`
Copied missed codes of GetRiscV64PassStructInRegiste in vm to crossgen2

* Check size in GetRiscV64PassStructInRegisterFlags early, use named constant

* Simplify managed branch of GetRiscV64PassStructInRegisterFlags

* Fix assert IsPrimitiveType for 2nd field

* Handle empty structs

* Apply FIELD_SIZE_IS8 flags only when there's at least one float

* Handle empty array struct elements

* Enregister any field type <= 8 bytes, not just primitives; i.e. pointers and refs are also OK

* Simplify native layout branch of GetRiscV64PassStructInRegisterFlags

* Rewrite native branch to look at only at native layout info

* Calculate flags already in GetFlattenedFieldTypes to avoid returning fake CorElementTypes from native branch

* Ignore empty structs during field flattenting because RISC-V calling convention tells us to

* Simplify crossgen2 GetRISCV64PassStructInRegisterFlags, make C++ and C# versions of this method look more alike

* Remove early exit if nFields == 0 because it wasn't doing much, the loop won't do any work if there's no fields

* Return early from HasImpliedRepeatedFields. GetApproxFieldDescListRaw() is null on empty structs, which crashes pFieldStart->GetFieldType()

* Cleanup GetRiscV64PassStructInRegisterFlags call sites

* Stackalloc field types to avoid GC allocations

---------

Co-authored-by: Dong-Heon Jung <clamp03@gmail.com>
* [RISC-V] Add quirks for riscv to R2RDump (#101683)

* [RISC-V] Add quirks for riscv

* [RISC-V] minimize code

* [LoongArch64] Fix the `ArgIteratorTemplate::GetNextOffset()` return argOfs for 'ELEMENT_TYPE_VALUETYPE' which is flattened liking struct{Arr[], float}. (#103108)

* [LoongArch64] Fix the `ArgIteratorTemplate::GetNextOffset()` return argOfs for 'ELEMENT_TYPE_VALUETYPE' which is flattened liking struct{Arr[], float}.
* The 'ELEMENT_TYPE_VALUETYPE' is marked to 'TYPE_GC_OTHER' and the first flattened element Arr[] should GC.
* This also fixed the assert failure "!CREATE_CHECK_STRING(pMT && pMT->Validate())" under GC=8 of MarshalStructAsLayoutSeq.sh.

* Update callingconvention.h

delete redundancy condition.

* Fix ArgIteratorTemplate::GetNextOffset() for struct{Arr[], float} (#103125)

* fix ping with TTL on Linux (#99875)

* fix ping with TTL on Linux

* feedback

* feedback

* [RISC-V] Set proper options for connected IPv6 raw socket (#103127)

Before this change we get following failure from PingTest.SendPingWithIPAddres:

System.Net.NetworkInformation.PingException : An exception occurred during a Ping request.\n---- System.Net.Sockets.SocketException : Protocol not available
   at System.Net.NetworkInformation.Ping.Send(IPAddress address, Int32 timeout, Byte[] buffer, PingOptions options) in /runtime/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.cs:line 411
   at System.Net.NetworkInformation.Ping.Send(IPAddress address, Int32 timeout, Byte[] buffer) in /runtime/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.cs:line 319
   at System.Net.NetworkInformation.Ping.Send(IPAddress address, Int32 timeout) in /runtime/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.cs:line 258
   at System.Net.NetworkInformation.Tests.PingTest.<>c__DisplayClass12_0.<SendPingWithIPAddress>b__0(Ping ping) in /runtime/src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs:line 149
   at System.Net.NetworkInformation.Tests.PingTest.SendPing(Func`2 sendPing, Action`1 pingResultValidator) in /runtime/src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs:line 628
   at System.Net.NetworkInformation.Tests.PingTest.SendBatchPing(Func`2 sendPing, Action`1 pingResultValidator) in /runtime/src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs:line 611
   at System.Net.NetworkInformation.Tests.PingTest.SendPingWithIPAddress(AddressFamily addressFamily) in /runtime/src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs:line 148
   at InvokeStub_PingTest.SendPingWithIPAddress(Object, Span`1)

In this patch we fix setsockopt error by adding extra handling of IPv6 case.

* Fix sending ICMP echo request when host is unreachable (#103158)

Before this change we get following failure from PingTest.SendPingToExternalHostWithLowTtlTest:

 System.Net.NetworkInformation.PingException : An exception occurred during a Ping request.
      ---- System.Net.Sockets.SocketException : No route to host
      Stack Trace:
        /runtime/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.cs(729,0): at System.Net.NetworkInformation.Ping.SendPingAsyncInternal[TArg](TArg getAddressArg, Func`3 getAddress, Int32 timeout, Byte[] buffer, PingOptions options, CancellationToken cancellationToken)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs(743,0): at System.Net.NetworkInformation.Tests.PingTest.SendPingToExternalHostWithLowTtlTest()
        --- End of stack trace from previous location ---
        ----- Inner Stack Trace -----
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs(1395,0): at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs(1097,0): at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ReceiveFromAsync(Socket socket, CancellationToken cancellationToken)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs(423,0): at System.Net.Sockets.Socket.ReceiveFromAsync(Memory`1 buffer, SocketFlags socketFlags, EndPoint remoteEndPoint, CancellationToken cancellationToken)
        /runtime/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.RawSocket.cs(334,0): at System.Net.NetworkInformation.Ping.SendIcmpEchoRequestOverRawSocketAsync(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
        /runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs(38,0): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
           at System.Net.NetworkInformation.Ping.SendIcmpEchoRequestOverRawSocketAsync(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
        /runtime/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.Unix.cs(32,0): at System.Net.NetworkInformation.Ping.SendPingAsyncCore(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
        /runtime/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.cs(721,0): at System.Net.NetworkInformation.Ping.SendPingAsyncInternal[TArg](TArg getAddressArg, Func`3 getAddress, Int32 timeout, Byte[] buffer, PingOptions options, CancellationToken cancellationToken)
        /runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(292,0): at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncS

In this patch we add HostUnreachable handling to SendIcmpEchoRequestOverRawSocketAsync
and fix getting empty message from error queue.

* Fix alloc-dealloc mismatch in GC (#102929)

* Fix alloc-dealloc mismatch

* Fix few more alloc-dealloc mismatch in GC

* [RISC-V] Disable EnableWriteXorExecute by default on riscv64 architectue (#103408)

* Disable EnableWriteXorExecute by default on riscv64 architectue

On riscv64 architectue any dotnet process that loads corossgened assembly
without DOTNET_EnableWriteXorExecute=0 environment variable set
crashes with "Segmentation fault" error.

For example System.Private.CoreLib.dll is compiled with crossgen2 by default
during build phase so this crash applies to any processes that loads it.

Setting EnableWriteXorExecute=0 disables this options on riscv64 architecure
and prevents these crashes.

Co-authored-by: Dong-Heon Jung <clamp03@gmail.com>
* Add a link to an issue about re-enabling WriteXorExecute on riscv64 arch.

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
---------

Co-authored-by: Dong-Heon Jung <clamp03@gmail.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
* Fix nonvolatile context restoration (#101709)

* Fix nonvolatile context restoration

There is a possibility of a race between the
ClrRestoreNonVolatileContext and an async signal handling (like
the one we use for runtime suspension). If the signal kicks in after
we've loaded Rsp, but before we jumped to the target address, the
context we are loading the registers from could get overwritten by the
signal handler stack. So the ClrRestoreNonVolatileContext would end up
jumping into a wrong target address.

The fix is to load the target address into a register before loading the
Rsp and then jumping using the register.

* Fix arm and x86

* [RISC-V] Fix context restoration as #101709 describes (#101865)

* [RISCV-V] Fix context restoration as 101709

* Feedback

* [x64][SysV] Classify empty structs for passing like padding (#103799)

The current implementation barred a struct containing empty struct fields from enregistration. This did not match the [System V ABI](https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf) which says "NO_CLASS This class is used as initializer in the algorithms. It will be used for padding and **empty structures** and unions". It also does not match the behavior of GCC & Clang on Linux.

* [RISC-V] Fix coreclr test readytorun/coreroot_determinism/coreroot_determinism/coreroot_determinism.sh (#104140)

To make test passing we increase TimeoutMilliseconds to 30 min.

* Fix alpine-riscv64 build (#104920)

* [RISC-V] Fix System.Net.Sockets.Tests on Qemu (#104094)

* [RISC-V] Fix System.Net.Sockets.Tests on Qemu

Before this change there are 8 failures from System.Net.Sockets.Tests with following reports:

root@69fa7050f168:/runtime/artifacts/bin/System.Net.Sockets.Tests/Release/net9.0-unix# /runtime/artifacts/bin/testhost/net9.0-linux-Release-riscv64/dotnet  exec --runtimeconfig System.Net.Sockets.Tests.runtimeconfig.json --depsfile  System.Net.Sockets.Tests.deps.json  xunit.console.dll System.Net.Sockets.Tests.dll -xml testResults.xml -nologo -notrait category=nonnetcoreapptests -notrait category=nonlinuxtests -notrait category=failing -maxthreads 32
  Discovering: System.Net.Sockets.Tests (method display = ClassAndMethod, method display options = None)
  Discovered:  System.Net.Sockets.Tests (found 1672 of 1820 test cases)
  Starting:    System.Net.Sockets.Tests (parallel test collections = on [32 threads], stop on fail = off)
    System.Net.Sockets.Tests.CreateSocket.Ctor_Raw_NotSupported_ExpectedError [SKIP]
      Condition(s) not met: "NotSupportsRawSockets"
    System.Net.Sockets.Tests.KeepAliveTest.Socket_Get_KeepAlive_Time_AsByteArray_OptionLengthZero_Failure [FAIL]
      System.Net.Sockets.SocketException : Bad address
      Stack Trace:
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3737,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3728,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(2145,0): at System.Net.Sockets.Socket.GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionLength)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Sockets/tests/FunctionalTests/KeepAliveTest.cs(136,0): at System.Net.Sockets.Tests.KeepAliveTest.Socket_Get_KeepAlive_Time_AsByteArray_OptionLengthZero_Failure()

           at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
        /runtime/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs(57,0): at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
    System.Net.Sockets.Tests.ArgumentValidation.Connect_ConnectTwice_NotSupported(invalidatingAction: 1) [FAIL]
      System.Net.Sockets.SocketException : Protocol not available
      Stack Trace:
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3737,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3728,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3466,0): at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue, Boolean silent)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(1966,0): at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Sockets/tests/FunctionalTests/ArgumentValidationTests.cs(809,0): at System.Net.Sockets.Tests.ArgumentValidation.Connect_ConnectTwice_NotSupported(Int32 invalidatingAction)
           at InvokeStub_ArgumentValidation.Connect_ConnectTwice_NotSupported(Object, Span`1)
           at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    System.Net.Sockets.Tests.SocketOptionNameTest.MulticastInterface_Set_AnyInterface_Succeeds [FAIL]
      System.Net.Sockets.SocketException : Unknown socket error
      Stack Trace:
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3737,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3728,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3479,0): at System.Net.Sockets.Socket.SetMulticastOption(SocketOptionName optionName, MulticastOption MR)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(2021,0): at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Object optionValue)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.cs(96,0): at System.Net.Sockets.Tests.SocketOptionNameTest.MulticastInterface_Set_Helper(Int32 interfaceIndex)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.cs(71,0): at System.Net.Sockets.Tests.SocketOptionNameTest.MulticastInterface_Set_AnyInterface_Succeeds()
        --- End of stack trace from previous location ---
    System.Net.Sockets.Tests.KeepAliveTest.Socket_Get_KeepAlive_Time_AsByteArray_BufferNullOrTooSmall_Failure(buffer: null) [FAIL]
      System.Net.Sockets.SocketException : Bad address
      Stack Trace:
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3737,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3728,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(2121,0): at System.Net.Sockets.Socket.GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Byte[] optionValue)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Sockets/tests/FunctionalTests/KeepAliveTest.cs(156,0): at System.Net.Sockets.Tests.KeepAliveTest.Socket_Get_KeepAlive_Time_AsByteArray_BufferNullOrTooSmall_Failure(Byte[] buffer)

           at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
        /runtime/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs(178,0): at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
    System.Net.Sockets.Tests.KeepAliveTest.Socket_Get_KeepAlive_Time_AsByteArray_BufferNullOrTooSmall_Failure(buffer: []) [FAIL]
      System.Net.Sockets.SocketException : Bad address
      Stack Trace:
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3737,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3728,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(2121,0): at System.Net.Sockets.Socket.GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Byte[] optionValue)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Sockets/tests/FunctionalTests/KeepAliveTest.cs(156,0): at System.Net.Sockets.Tests.KeepAliveTest.Socket_Get_KeepAlive_Time_AsByteArray_BufferNullOrTooSmall_Failure(Byte[] buffer)
           at InvokeStub_KeepAliveTest.Socket_Get_KeepAlive_Time_AsByteArray_BufferNullOrTooSmall_Failure(Object, Span`1)
           at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    System.Net.Sockets.Tests.SocketOptionNameTest.MulticastOption_CreateSocketSetGetOption_GroupAndInterfaceIndex_SetSucceeds_GetThrows [FAIL]
      System.Net.Sockets.SocketException : Unknown socket error
      Stack Trace:
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3737,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3728,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3479,0): at System.Net.Sockets.Socket.SetMulticastOption(SocketOptionName optionName, MulticastOption MR)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(2021,0): at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Object optionValue)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.cs(61,0): at System.Net.Sockets.Tests.SocketOptionNameTest.MulticastOption_CreateSocketSetGetOption_GroupAndInterfaceIndex_SetSucceeds_GetThrows()

           at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
        /runtime/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs(57,0): at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
    System.Net.Sockets.Tests.SocketOptionNameTest.MulticastInterface_Set_IPv6_AnyInterface_Succeeds [FAIL]
      System.Net.Sockets.SocketException : Protocol not available
      Stack Trace:
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3737,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3728,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3466,0): at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue, Boolean silent)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(1966,0): at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.cs(199,0): at System.Net.Sockets.Tests.SocketOptionNameTest.MulticastInterface_Set_IPv6_Helper(Int32 interfaceIndex)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.cs(129,0): at System.Net.Sockets.Tests.SocketOptionNameTest.MulticastInterface_Set_IPv6_AnyInterface_Succeeds()
        --- End of stack trace from previous location ---
    System.Net.Sockets.Tests.ArgumentValidation.ConnectAsync_ConnectTwice_NotSupported(invalidatingAction: 1) [FAIL]
      System.Net.Sockets.SocketException : Protocol not available
      Stack Trace:
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3737,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3728,0): at System.Net.Sockets.Socket.UpdateStatusAfterSocketOptionErrorAndThrowException(SocketError error, String callerName)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(3466,0): at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue, Boolean silent)
        /runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs(1966,0): at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue)
        /home/d.jurczak2/runtime/src/libraries/System.Net.Sockets/tests/FunctionalTests/ArgumentValidationTests.cs(842,0): at System.Net.Sockets.Tests.ArgumentValidation.ConnectAsync_ConnectTwice_NotSupported(Int32 invalidatingAction)
           at InvokeStub_ArgumentValidation.ConnectAsync_ConnectTwice_NotSupported(Object, Span`1)
           at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  Finished:    System.Net.Sockets.Tests
=== TEST EXECUTION SUMMARY ===
   System.Net.Sockets.Tests  Total: 2874, Errors: 0, Failed: 8, Skipped: 1, Time: 139.280s

Those failures are caused by Qemu's buggy and/or implementation defined behavior like:
https://gitlab.com/qemu-project/qemu/-/issues/2410
https://gitlab.com/qemu-project/qemu/-/issues/2390
https://gitlab.com/qemu-project/qemu/-/issues/1837

In this patch we add couple of workarounds to make all System.Net.Sockets.Tests passing.

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
* [RISC-V] Fix passing float and uint arguments in VM (#105021)

* Add tests

* Fix passing float and uint arguments in VM

* Change test lib name so it doesn't clash with managed DLL on Windows

* Disable execution of two WorkingSet tests on QEMU (#105689)

System.Diagnostics.Tests.ProcessTests.TestMaxWorkingSet()
System.Diagnostics.Tests.ProcessTests.TestMinWorkingSet()

These two corefx tests fail because on QEMU the file /proc/pid/stat
contains incorrect values.

See issue #105686 for details.

* Fix _LOGALLOC define (#106023)

* [RISC-V][LoongArch64] HijackFrame::UpdateRegDisplay restore A0 (#106018)

* [RISC-V] Fix Reg Order for Float Registers (#105930)

* [RISC-V] Fix coreroot_determinism in release build

Initialize regOrder and put all floating registers in REG_VAR_ORDER_FLT

* [RISC-V] Update GetLocalFloatingPointValue for RISC-V

* [RISC-V] System.Console CancelKeyPressTests.ExitDetectionNotBlockedByHandler increase timeout (#106119)

* Increase timeout to prevent failure of CancelKeyPressTests.ExitDetectionNotBlockedByHandler on Debug RISC-V

* Make WaitFailTestTimeoutSeconds static, move it closer to where it's used

* [RISC-V] JitDisasmWithGC: Output any delta in GC info (#106196)

* [RISC-V] Add GetRegOffsInCONTEXT() implementation (fix for `clrstack -p` SOS command). (#106277)

* [RISC-V] Fix GenerateResolveStub (#106562)

Fix to allow use of fast cached way.

* Fix alloc-dealloc mismatch (#106957)

* [Tizen] Fix build cause SDK does not know Riscv64

On reverting this #97021 should be picked.

---------

Co-authored-by: Aleksandr Shaurtaev <38426614+ashaurtaev@users.noreply.github.com>
Co-authored-by: Tomasz SowiƄski <tomeksowi@gmail.com>
Co-authored-by: Dong-Heon Jung <clamp03@gmail.com>
Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: SzpejnaDawid <166010737+SzpejnaDawid@users.noreply.github.com>
Co-authored-by: Xu Liangyu <xuliangyu@loongson.cn>
Co-authored-by: Tomas Weinfurt <tweinfurt@yahoo.com>
Co-authored-by: yurai007 <dawid_jurek@vp.pl>
Co-authored-by: Gleb Balykov <g.balykov@samsung.com>
Co-authored-by: rzsc <160726116+rzsc@users.noreply.github.com>
Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
Co-authored-by: t-mustafin <66252296+t-mustafin@users.noreply.github.com>
Co-authored-by: Mikhail Kurinnoi <m.kurinnoi@samsung.com>
119 files changed:
eng/targetingpacks.targets
src/coreclr/crossgen-corelib.proj
src/coreclr/debug/daccess/daccess.cpp
src/coreclr/debug/daccess/stack.cpp
src/coreclr/debug/di/rsthread.cpp
src/coreclr/gc/gc.cpp
src/coreclr/gc/gc.h
src/coreclr/inc/clrconfigvalues.h
src/coreclr/inc/log.h
src/coreclr/jit/emitriscv64.cpp
src/coreclr/jit/lsra.h
src/coreclr/jit/targetriscv64.h
src/coreclr/pal/src/arch/arm/context2.S
src/coreclr/pal/src/arch/i386/context2.S
src/coreclr/pal/src/arch/riscv64/context2.S
src/coreclr/tools/Common/CommandLineHelpers.cs
src/coreclr/tools/Common/Compiler/DependencyAnalysis/AssemblyStubNode.cs
src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectDataBuilder.cs
src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs
src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_RiscV64/AddrMode.cs [new file with mode: 0644]
src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_RiscV64/Register.cs [new file with mode: 0644]
src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64Emitter.cs [new file with mode: 0644]
src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_RiscV64/TargetRegisterMap.cs [new file with mode: 0644]
src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs
src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs
src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs
src/coreclr/tools/Common/JitInterface/RISCV64PassStructInRegister.cs
src/coreclr/tools/Common/JitInterface/SystemVStructClassificator.cs
src/coreclr/tools/Common/TypeSystem/Common/TargetArchitecture.cs
src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMInitialInterfaceDispatchStubNode.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64JumpStubNode.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64ReadyToRunGenericHelperNode.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64ReadyToRunHelperNode.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64TentativeMethodNode.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64UnboxingStubNode.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj
src/coreclr/tools/aot/ILCompiler.Diagnostics/ILCompiler.Diagnostics.csproj
src/coreclr/tools/aot/ILCompiler.Diagnostics/PerfMapWriter.cs
src/coreclr/tools/aot/ILCompiler.Diagnostics/ReadyToRunDiagnosticsConstants.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ArgIterator.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodGCInfoNode.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/Target_RiscV64/ImportThunk.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TransitionBlock.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunMetadataFieldLayoutAlgorithm.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/RelocationHelper.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/SectionBuilder.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TargetExtensions.cs
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcSlotTable.cs
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcTransition.cs
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/DebugInfo.cs
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/GCInfoTypes.cs
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunMethod.cs
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/RiscV64/Registers.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/RiscV64/UnwindInfo.cs [new file with mode: 0644]
src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/TransitionBlock.cs
src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs
src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs
src/coreclr/tools/aot/crossgen2/crossgen2.props
src/coreclr/tools/r2rdump/CoreDisTools.cs
src/coreclr/tools/r2rdump/Program.cs
src/coreclr/tools/r2rdump/R2RDump.csproj
src/coreclr/vm/amd64/Context.asm
src/coreclr/vm/argdestination.h
src/coreclr/vm/callhelpers.cpp
src/coreclr/vm/callingconvention.h
src/coreclr/vm/invokeutil.cpp
src/coreclr/vm/loongarch64/profiler.cpp
src/coreclr/vm/loongarch64/stubs.cpp
src/coreclr/vm/methodtable.cpp
src/coreclr/vm/riscv64/cgencpu.h
src/coreclr/vm/riscv64/stubs.cpp
src/coreclr/vm/riscv64/virtualcallstubcpu.hpp
src/coreclr/vm/stubmgr.cpp
src/coreclr/vm/stubmgr.h
src/coreclr/vm/util.cpp
src/installer/pkg/projects/netcoreappRIDs.props
src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Crossgen2.sfxproj
src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props
src/libraries/Common/src/Interop/Unix/System.Native/Interop.IOVector.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReceiveSocketError.cs [new file with mode: 0644]
src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs
src/libraries/System.Console/tests/CancelKeyPress.Unix.cs
src/libraries/System.Console/tests/CancelKeyPress.cs
src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs
src/libraries/System.Net.Ping/src/System.Net.Ping.csproj
src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.RawSocket.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/ArgumentValidationTests.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/KeepAliveTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.cs
src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEHeaderBuilder.cs
src/native/libs/Common/pal_config.h.in
src/native/libs/System.Native/entrypoints.c
src/native/libs/System.Native/pal_networking.c
src/native/libs/System.Native/pal_networking.h
src/native/libs/configure.cmake
src/tasks/Crossgen2Tasks/ResolveReadyToRunCompilers.cs
src/tests/JIT/Directed/PrimitiveABI/CMakeLists.txt [new file with mode: 0644]
src/tests/JIT/Directed/PrimitiveABI/PrimitiveABI.c [new file with mode: 0644]
src/tests/JIT/Directed/PrimitiveABI/PrimitiveABI.cs [new file with mode: 0644]
src/tests/JIT/Directed/PrimitiveABI/PrimitiveABI.csproj [new file with mode: 0644]
src/tests/JIT/Directed/StructABI/CMakeLists.txt
src/tests/JIT/Directed/StructABI/EmptyStructs.cpp [new file with mode: 0644]
src/tests/JIT/Directed/StructABI/EmptyStructs.cs [new file with mode: 0644]
src/tests/JIT/Directed/StructABI/EmptyStructs.csproj [new file with mode: 0644]
src/tests/profiler/native/eltprofiler/slowpatheltprofiler.cpp
src/tests/profiler/native/gcprofiler/gcprofiler.cpp
src/tests/profiler/native/getappdomainstaticaddress/getappdomainstaticaddress.cpp
src/tests/profiler/native/handlesprofiler/handlesprofiler.cpp
src/tests/profiler/native/handlesprofiler/handlesprofiler.h
src/tests/profiler/native/profiler.cpp
src/tests/profiler/native/rejitprofiler/rejitprofiler.cpp
src/tests/readytorun/coreroot_determinism/Program.cs
src/tools/illink/src/linker/Linker.Steps/OutputStep.cs