Skip to content

Commit 97e2806

Browse files
Rollup merge of #144721 - a4lg:riscv-hwprobe-linux-6.16, r=Amanieu
`std_detect`: Linux 6.16 support for RISC-V It adds feature detection of 1 extension (new in `std_detect`). New RISC-V Extension: 1. "Zabha"
2 parents febd8cd + c51e5ce commit 97e2806

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

library/std_detect/src/detect/arch/riscv.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ features! {
7373
/// * Zihintpause: `"zihintpause"`
7474
/// * Zihpm: `"zihpm"`
7575
/// * Zimop: `"zimop"`
76+
/// * Zabha: `"zabha"`
7677
/// * Zacas: `"zacas"`
7778
/// * Zawrs: `"zawrs"`
7879
/// * Zfa: `"zfa"`
@@ -195,6 +196,8 @@ features! {
195196
/// "Zaamo" Extension for Atomic Memory Operations
196197
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zawrs: "zawrs";
197198
/// "Zawrs" Extension for Wait-on-Reservation-Set Instructions
199+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zabha: "zabha";
200+
/// "Zabha" Extension for Byte and Halfword Atomic Memory Operations
198201
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zacas: "zacas";
199202
/// "Zacas" Extension for Atomic Compare-and-Swap (CAS) Instructions
200203
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zam: "zam";

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ use super::super::riscv::imply_features;
1010
use super::auxvec;
1111
use crate::detect::{Feature, bit, cache};
1212

13-
// See <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/prctl.h?h=v6.15>
13+
// See <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/prctl.h?h=v6.16>
1414
// for runtime status query constants.
1515
const PR_RISCV_V_GET_CONTROL: libc::c_int = 70;
1616
const PR_RISCV_V_VSTATE_CTRL_ON: libc::c_int = 2;
1717
const PR_RISCV_V_VSTATE_CTRL_CUR_MASK: libc::c_int = 3;
1818

19-
// See <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/include/uapi/asm/hwprobe.h?h=v6.15>
19+
// See <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/include/uapi/asm/hwprobe.h?h=v6.16>
2020
// for riscv_hwprobe struct and hardware probing constants.
2121

2222
#[repr(C)]
@@ -98,6 +98,7 @@ const RISCV_HWPROBE_EXT_ZVFBFWMA: u64 = 1 << 54;
9898
const RISCV_HWPROBE_EXT_ZICBOM: u64 = 1 << 55;
9999
const RISCV_HWPROBE_EXT_ZAAMO: u64 = 1 << 56;
100100
const RISCV_HWPROBE_EXT_ZALRSC: u64 = 1 << 57;
101+
const RISCV_HWPROBE_EXT_ZABHA: u64 = 1 << 58;
101102

102103
const RISCV_HWPROBE_KEY_CPUPERF_0: i64 = 5;
103104
const RISCV_HWPROBE_MISALIGNED_FAST: u64 = 3;
@@ -138,7 +139,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
138139
// Use auxiliary vector to enable single-letter ISA extensions.
139140
// The values are part of the platform-specific [asm/hwcap.h][hwcap]
140141
//
141-
// [hwcap]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/include/uapi/asm/hwcap.h?h=v6.15
142+
// [hwcap]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/include/uapi/asm/hwcap.h?h=v6.16
142143
let auxv = auxvec::auxv().expect("read auxvec"); // should not fail on RISC-V platform
143144
let mut has_i = bit::test(auxv.hwcap, (b'i' - b'a').into());
144145
#[allow(clippy::eq_op)]
@@ -233,6 +234,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
233234
enable_feature(Feature::zalrsc, test(RISCV_HWPROBE_EXT_ZALRSC));
234235
enable_feature(Feature::zaamo, test(RISCV_HWPROBE_EXT_ZAAMO));
235236
enable_feature(Feature::zawrs, test(RISCV_HWPROBE_EXT_ZAWRS));
237+
enable_feature(Feature::zabha, test(RISCV_HWPROBE_EXT_ZABHA));
236238
enable_feature(Feature::zacas, test(RISCV_HWPROBE_EXT_ZACAS));
237239
enable_feature(Feature::ztso, test(RISCV_HWPROBE_EXT_ZTSO));
238240

library/std_detect/src/detect/os/riscv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub(crate) fn imply_features(mut value: cache::Initializer) -> cache::Initialize
9090
group!(zks == zbkb & zbkc & zbkx & zksed & zksh);
9191
group!(zk == zkn & zkr & zkt);
9292

93-
imply!(zacas => zaamo);
93+
imply!(zabha | zacas => zaamo);
9494
group!(a == zalrsc & zaamo);
9595

9696
group!(b == zba & zbb & zbs);

library/std_detect/tests/cpu-detection.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ fn riscv_linux() {
242242
println!("zalrsc: {}", is_riscv_feature_detected!("zalrsc"));
243243
println!("zaamo: {}", is_riscv_feature_detected!("zaamo"));
244244
println!("zawrs: {}", is_riscv_feature_detected!("zawrs"));
245+
println!("zabha: {}", is_riscv_feature_detected!("zabha"));
245246
println!("zacas: {}", is_riscv_feature_detected!("zacas"));
246247
println!("zam: {}", is_riscv_feature_detected!("zam"));
247248
println!("ztso: {}", is_riscv_feature_detected!("ztso"));

0 commit comments

Comments
 (0)