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 for probestack linking errors #83

Merged
merged 1 commit into from
Jan 25, 2021
Merged
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
8 changes: 8 additions & 0 deletions drivers/char/rust_example.rs
Original file line number Diff line number Diff line change
@@ -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::<RustFile>(cstr!("rust_miscdev"), None)?,
9 changes: 9 additions & 0 deletions drivers/char/rust_example_2.rs
Original file line number Diff line number Diff line change
@@ -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(),
})
9 changes: 9 additions & 0 deletions drivers/char/rust_example_3.rs
Original file line number Diff line number Diff line change
@@ -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(),
})
9 changes: 9 additions & 0 deletions drivers/char/rust_example_4.rs
Original file line number Diff line number Diff line change
@@ -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(),
})