diff --git a/drivers/char/rust_example.rs b/drivers/char/rust_example.rs index 47c4a7f722ef80..6f484d77f82f8d 100644 --- a/drivers/char/rust_example.rs +++ b/drivers/char/rust_example.rs @@ -2,6 +2,7 @@ #![no_std] #![feature(allocator_api, global_asm)] +#![feature(test)] use alloc::boxed::Box; use core::pin::Pin; @@ -52,6 +53,13 @@ impl KernelModule for RustExample { println!(" my_bool: {}", my_bool.read()); println!(" my_i32: {}", my_i32.read()); + // Including this large variable on the stack will trigger + // stack probing on the supported archs. + // This will verify that stack probing does not lead to + // any errors if we need to link `__rust_probestack`. + let x: [u64; 1028] = core::hint::black_box([5; 1028]); + println!("Large array has length: {}", x.len()); + Ok(RustExample { message: "on the heap!".to_owned(), _dev: miscdev::Registration::new_pinned::(cstr!("rust_miscdev"), None)?, diff --git a/drivers/char/rust_example_2.rs b/drivers/char/rust_example_2.rs index b5ffb92870d191..caa1925d08bc90 100644 --- a/drivers/char/rust_example_2.rs +++ b/drivers/char/rust_example_2.rs @@ -2,6 +2,7 @@ #![no_std] #![feature(allocator_api, global_asm)] +#![feature(test)] use kernel::prelude::*; @@ -36,6 +37,14 @@ impl KernelModule for RustExample2 { println!("[2] Parameters:"); println!("[2] my_bool: {}", my_bool.read()); println!("[2] my_i32: {}", my_i32.read()); + + // Including this large variable on the stack will trigger + // stack probing on the supported archs. + // This will verify that stack probing does not lead to + // any errors if we need to link `__rust_probestack`. + let x: [u64; 1028] = core::hint::black_box([5; 1028]); + println!("Large array has length: {}", x.len()); + Ok(RustExample2 { message: "on the heap!".to_owned(), }) diff --git a/drivers/char/rust_example_3.rs b/drivers/char/rust_example_3.rs index c6b867e527e9a9..fa7f52ac527917 100644 --- a/drivers/char/rust_example_3.rs +++ b/drivers/char/rust_example_3.rs @@ -2,6 +2,7 @@ #![no_std] #![feature(allocator_api, global_asm)] +#![feature(test)] use kernel::prelude::*; @@ -36,6 +37,14 @@ impl KernelModule for RustExample3 { println!("[3] Parameters:"); println!("[3] my_bool: {}", my_bool.read()); println!("[3] my_i32: {}", my_i32.read()); + + // Including this large variable on the stack will trigger + // stack probing on the supported archs. + // This will verify that stack probing does not lead to + // any errors if we need to link `__rust_probestack`. + let x: [u64; 1028] = core::hint::black_box([5; 1028]); + println!("Large array has length: {}", x.len()); + Ok(RustExample3 { message: "on the heap!".to_owned(), }) diff --git a/drivers/char/rust_example_4.rs b/drivers/char/rust_example_4.rs index b658c55b4ba80b..99b420eebbac35 100644 --- a/drivers/char/rust_example_4.rs +++ b/drivers/char/rust_example_4.rs @@ -2,6 +2,7 @@ #![no_std] #![feature(allocator_api, global_asm)] +#![feature(test)] use kernel::prelude::*; @@ -36,6 +37,14 @@ impl KernelModule for RustExample4 { println!("[4] Parameters:"); println!("[4] my_bool: {}", my_bool.read()); println!("[4] my_i32: {}", my_i32.read()); + + // Including this large variable on the stack will trigger + // stack probing on the supported archs. + // This will verify that stack probing does not lead to + // any errors if we need to link `__rust_probestack`. + let x: [u64; 1028] = core::hint::black_box([5; 1028]); + println!("Large array has length: {}", x.len()); + Ok(RustExample4 { message: "on the heap!".to_owned(), })