-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[RISC-V] Read isa
line in /proc/cpuinfo
when hwprobe
not available
#114958
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
Conversation
RISC-V Release-CLR-VF2: 9702 / 9750 (99.51%)
Release-CLR-VF2.md, Release-CLR-VF2.xml, testclr_output.tar.gz Build information and commandsGIT: RISC-V Release-CLR-QEMU: 9701 / 9750 (99.50%)
Release-CLR-QEMU.md, Release-CLR-QEMU.xml, testclr_output.tar.gz Build information and commandsGIT: RISC-V Release-FX-QEMU: 706582 / 721531 (97.93%)
Release-FX-QEMU.md, Release-FX-QEMU.xml, testfx_output.tar.gz Build information and commandsGIT: |
size_t n = 0; | ||
char* buf = NULL; | ||
|
||
assert(cpuInfo != NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linux procfs
is considered optional for number of reasons.
assert(cpuInfo != NULL); | |
if (cpuInfo == NULL) return result; |
(or wrap the handling under != NULL
)
Have we decided what is the .NET baseline kernel version for riscv64? If it is higher than 6.5 for other reasons, we can ignore the |
Hmm not sure, but you're right. And thanks for the reference BTW 👍 So actually, I added this detection through I'll investigate further and closing this PR for now. I'll reopen it if it's clearly needed. Thank you for your time reviewing it! 🙏 @am11 |
@fuad1502, I am also on the same kernel and getting: $ neofetch
##### am11@k1
####### -------
##O#O## OS: Bianbu 2.1 riscv64
####### Host: M1-MUSE-BOOK
########### Kernel: 6.6.63
############# Uptime: 4 days, 1 hour, 13 mins
############### Packages: 2325 (dpkg)
################ Shell: bash 5.2.21
################# Resolution: 1920x1080
##################### Terminal: /dev/pts/1
##################### CPU: Spacemit X60 (8) @ 1.600GHz
################# Memory: 723MiB / 15904MiB
$ cc -xc - <<EOF
#include <stdio.h>
#include <assert.h>
#include <asm/hwprobe.h>
#include <asm/unistd.h>
#include <unistd.h>
enum RiscV64IntrinsicConstants
{
RiscV64IntrinsicConstants_Zba = 0x0001,
RiscV64IntrinsicConstants_Zbb = 0x0002,
};
int main(void){
int result;
struct riscv_hwprobe pairs[1] = {{RISCV_HWPROBE_KEY_IMA_EXT_0, 0}};
if (syscall(__NR_riscv_hwprobe, pairs, 1, 0, NULL, 0) == 0)
{
// Our baseline support is for RV64GC (see #73437)
assert(pairs[0].value & RISCV_HWPROBE_IMA_FD);
assert(pairs[0].value & RISCV_HWPROBE_IMA_C);
if (pairs[0].value & RISCV_HWPROBE_EXT_ZBA)
{
result |= RiscV64IntrinsicConstants_Zba;
}
if (pairs[0].value & RISCV_HWPROBE_EXT_ZBB)
{
result |= RiscV64IntrinsicConstants_Zbb;
}
}
printf("result: %d\n", result);
return 0;
}
EOF
$ ./a.out
result: 3 Please double check the build logs; cmake logs should be showing lines like:
|
Thanks for looking into it! I found that the issue was indeed with our internal build, it turns out we're compiling with Linux 5.4 kernel headers 😅 I think we can safely assume |
hwprobe
was introduced in Linux kernel version 6.4 https://www.kernel.org/doc/html/v6.4/riscv/hwprobe.html (although on version 6.5, it only started supportingZba
,Zbb
, andZbs
detection)isa
line in/proc/cpuinfo
is available from Linux kernel version 6.3 upwards https://www.kernel.org/doc/html/v6.3/riscv/uabi.html (CMIIW)hwprobe
also exports less extensions than/proc/cpuinfo
when first introduced. Should we prioritize/proc/cpuinfo
on kernel version 6.11 and lower (on version 6.11, the extension supported inhwprobe
looks complete https://www.kernel.org/doc/html/v6.11/arch/riscv/hwprobe.html)?TODO:
hwprobe
and/proc/cpuinfo
isa
line support on Linux.Part of #84834, cc @dotnet/samsung