Cosmos
Cosmos copied to clipboard
`CPU.GetCPUBrandString()` causes Cosmos CPU Exception despite `CPU.CanReadCPUID()` being a non-zero value
Area of Cosmos - What area of Cosmos are we dealing with?
Cosmos' implementation of CPUID
Expected Behaviour - What do you think that should happen?
Cosmos returns the correct CPU brand string when invoking CPU.GetCPUBrandString().
Actual Behaviour - What unexpectedly happens?
A CPU Exception occurs, with an invalid opcode:
Reproduction - How did you get this error to appear?
A simple usage of the CPU brand function in BeforeRun, checking CanReadCPUID beforehand:
Console.WriteLine(" Gathering SystemInformation");
this._information = new SystemInformation
{
CPUVendor = CPU.GetCPUVendorName(),
MemoryCountMegabytes = CPU.GetAmountOfRAM(),
};
Console.Write(" Checking if we can read CPUID... ");
int canReadCpuIdResult = CPU.CanReadCPUID();
bool canReadCpuId = canReadCpuIdResult != 0;
Console.Write(canReadCpuId ? "Yes!" : "No.");
Console.Write($" Result was {canReadCpuIdResult}.\n");
if (canReadCpuId)
{
this._information.CPUBrand = CPU.GetCPUBrandString();
this._information.EstimatedCycleSpeed = CPU.GetCPUCycleSpeed();
}
else
{
this._information.CPUBrand = "Unknown";
this._information.EstimatedCycleSpeed = -1;
}
Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?
Dev Kit cd69dc2f4b6d8273d6476e3004bcdda7de55af88
QEMU emulator version 8.0.2
.NET SDK:
Version: 7.0.304
Commit: 7e794e2806
Runtime Environment:
OS Name: arch
OS Version:
OS Platform: Linux
RID: arch-x64
Base Path: /usr/share/dotnet/sdk/7.0.304/
Host:
Version: 7.0.7
Architecture: x64
Commit: 5b20af47d9
.NET SDKs installed:
6.0.116 [/usr/share/dotnet/sdk]
7.0.304 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.16 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.7 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Additional notes
- This was previously discussed in Discord: https://discord.com/channels/833970409337913344/1120584024730124418
- I checked for similar issues, coming across #2103 but noting that the issue was resolved over a year ago.
- This doesn't seem to be an emulator/VM bug, as I reproduced the issue on a Dell Latitude E5430.
Still happens on lastest devkit!