Skip to content
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

Test that __rust_probestack can be linked #74

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions drivers/char/rust_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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 a call to
// `compiler_builtins::probestack::__rust_probestack` on x86_64.
// This will verify that we are able to link modules which call
// `__rust_probestack`.
let x: [u64; 1028] = [5; 1028];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let x: [u64; 1028] = [5; 1028];
let x: [u64; 1028] = core::hint::black_box([5; 1028]);

Requires #![feature(test)], but ensures that it isn't optimized out.

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
8 changes: 8 additions & 0 deletions drivers/char/rust_example_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 a call to
// `compiler_builtins::probestack::__rust_probestack` on x86_64.
// This will verify that we are able to link modules which call
// `__rust_probestack`.
let x: [u64; 1028] = [5; 1028];
println!("Large array has length: {}", x.len());

Ok(RustExample2 {
message: "on the heap!".to_owned(),
})
Expand Down
8 changes: 8 additions & 0 deletions drivers/char/rust_example_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 a call to
// `compiler_builtins::probestack::__rust_probestack` on x86_64.
// This will verify that we are able to link modules which call
// `__rust_probestack`.
let x: [u64; 1028] = [5; 1028];
println!("Large array has length: {}", x.len());

Ok(RustExample3 {
message: "on the heap!".to_owned(),
})
Expand Down
8 changes: 8 additions & 0 deletions drivers/char/rust_example_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 a call to
// `compiler_builtins::probestack::__rust_probestack` on x86_64.
// This will verify that we are able to link modules which call
// `__rust_probestack`.
let x: [u64; 1028] = [5; 1028];
println!("Large array has length: {}", x.len());

Ok(RustExample4 {
message: "on the heap!".to_owned(),
})
Expand Down