-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
fix: SIGILL caused by rdcycle prohibited by kernel on RISC-V #10901
Conversation
CC-ing @adamretter : I'm not sure whether your SSH access to our Unmatched board still remains or not X( Let me know if you have difficulties logging-in to the board. Thanks! |
CI |
@XieJiSS Yes, I am still able to access the RISC-V machine. I have added this one into our backlog here at EB and prioritised it (cc @alanpaxton) |
Hi @XieJiSS - Adam has set me up on the RISC-V box and I have got some code built, but I'm struggling to understand what I need to run to reproduce the problem in the unfixed main, and hence verify the fix in your PR. I'm not really clear where toku_time gets used in rocksdb ? |
Hi @alanpaxton, personally I'm not really sure about where In short: I used The original proposed implementation (the Some screenshots of my test result: |
Just as a reminder - this would be fixed automatically in (not yet released) newer Linux versions, and the kernel patch are expected to be backported to previous versions. I've listed pros and cons about switching from Thanks! |
Hi @XieJiSS thanks for the explanation. I can build on the RISC-V box - main has your build PR applied, and I needed a |
If rdcycle didn't trigger an SIGILL, then you are probably on an older version of the kernel - consider that the RISC-V box is a Ubuntu, this is highly possible |
EDIT: Seems like systemd-nspawn works as syscall level and hence does not simulate a new kernel. I'll contact you later and let's see whether I can help you get access to some Arch Linux dev boards :) |
Sorry for the lag. Arch Linux board resources are quite tight these days, but I managed to start a qemu-system with Arch Linux rootfs + linux 6.0.x kernel, which IMO is suitable for debugging & testing of this problem. I'll provide a tutorial ASAP. |
Thanks for doing that. I have a couple of things to finish off atm but I plan to get back to this in the near future. |
BTW my colleague also managed to get a new RISC-V board, but he's been caught by COVID. Probably after the Spring Festival (lunar new year) he can get back to work and flash the board so that we can access it via SSH to do some development or testing. @alanpaxton Can I use |
@XieJiSS yes, those are current ssh keys |
@XieJiSS Is this still an issue for you? We have build of RocksJava for RISC-V now and have access to both emulated and physical RISC-V hardware. |
I think QEMU has recently released a version with emulated /proc/cpuinfo in usermode, and the kernel has reverted the offending commit which causes rdcycle to SIGILL. So maybe we can close this for now? |
Hello,
This issue is probably caused by the PMU driver explicitly disallowing userland access to the
mcycle
register viardcycle
/rdcycleh
.Let me clarify a little bit:
mcycle
is too accurate that might leak info to side-channel attacks, so they disabled userland access tomcycle
by adding a commit to the kernel. As a result,rdcycle
causes SIGILL now. We can observe this behavior happening on SiFive Unmatched boards.rdcycle
tordtime
. However, the Google Benchmark library remains unchanged (as of now, 20221030).rdcycle
in userland, which was applied 17 days ago. Since this patch is only accepted recently, I hope it can land in linux 6.2? As of our version of linux, which is linux 6.0.2,rdcycle
is not working yet.So, pros of switching to
rdtime
:mtime
register is promised to increase at a fixed speed, whilemcycle
's increment speed may vary. See comments by Anup in this link.rdcycle
is now part of theZicntr
extension, which is not yet ratified as of 2022-10. RISC-V, despite used by a growing group of users, is still an evolving ISA, so details ofrdcycle
may change in the future. Should we consider this at software level? Sounds more like something that compilers should worry about.And cons:
rdcycle
.rdcycle
has a higher resolution.See-also this thread: http://lists.infradead.org/pipermail/linux-riscv/2022-September/018862.html