Skip to content

Commit d19dfa0

Browse files
committed
RISC-V: Linux: Imply Zicntr from the IMA base behavior
As the author confirmed as in: <https://lists.infradead.org/pipermail/linux-riscv/2025-May/070844.html>, runtime detection of the Zicntr extension (as in the Linux kernel 6.15) is currently (and technically) redundant on the current base IMA behavior (although can be meaningful if new base behavior is added). This commit implies the Zicntr extension from the base IMA behavior.
1 parent 8798895 commit d19dfa0

File tree

1 file changed

+4
-6
lines changed
  • crates/std_detect/src/detect/os/linux

1 file changed

+4
-6
lines changed

crates/std_detect/src/detect/os/linux/riscv.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,16 @@ pub(crate) fn detect_features() -> cache::Initializer {
197197
// Query whether "I" base and extensions "M" and "A" (as in the ISA
198198
// manual version 2.2) are enabled. "I" base at that time corresponds
199199
// to "I", "Zicsr", "Zicntr" and "Zifencei" (as in the ISA manual version
200-
// 20240411) and we chose to imply "Zicsr" and "Zifencei" (not "Zicntr")
201-
// because there will be a separate RISCV_HWPROBE_EXT_ZICNTR constant to
202-
// determine existence of the "Zicntr" extension in Linux 6.15 (as of rc1).
203-
// "fence.i" ("Zifencei") is conditionally valid on the Linux userland
204-
// (when CMODX is enabled).
205-
// This is a requirement of `RISCV_HWPROBE_KEY_IMA_EXT_0`-based tests.
200+
// 20240411).
201+
// This is a current requirement of
202+
// `RISCV_HWPROBE_KEY_IMA_EXT_0`-based tests.
206203
let has_ima = (out[0].key != -1) && (out[0].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA != 0);
207204
if !has_ima {
208205
break 'hwprobe;
209206
}
210207
has_i |= has_ima;
211208
enable_feature(Feature::zicsr, has_ima);
209+
enable_feature(Feature::zicntr, has_ima);
212210
enable_feature(Feature::zifencei, has_ima);
213211
enable_feature(Feature::m, has_ima);
214212
enable_feature(Feature::a, has_ima);

0 commit comments

Comments
 (0)