Skip to content

Commit

Permalink
add tests for probestack linking
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrk committed Jan 24, 2021
1 parent 745bd9d commit d5fadec
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/char/rust_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#![no_std]
#![feature(allocator_api, global_asm)]
#![feature(test)]

use alloc::boxed::Box;
use core::pin::Pin;
Expand Down Expand Up @@ -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::<RustFile>(cstr!("rust_miscdev"), None)?,
Expand Down
9 changes: 9 additions & 0 deletions drivers/char/rust_example_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#![no_std]
#![feature(allocator_api, global_asm)]
#![feature(test)]

use kernel::prelude::*;

Expand Down Expand Up @@ -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(),
})
Expand Down
9 changes: 9 additions & 0 deletions drivers/char/rust_example_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#![no_std]
#![feature(allocator_api, global_asm)]
#![feature(test)]

use kernel::prelude::*;

Expand Down Expand Up @@ -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(),
})
Expand Down
9 changes: 9 additions & 0 deletions drivers/char/rust_example_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#![no_std]
#![feature(allocator_api, global_asm)]
#![feature(test)]

use kernel::prelude::*;

Expand Down Expand Up @@ -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(),
})
Expand Down

0 comments on commit d5fadec

Please sign in to comment.