File tree 4 files changed +35
-0
lines changed
4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
#![ no_std]
4
4
#![ feature( allocator_api, global_asm) ]
5
+ #![ feature( test) ]
5
6
6
7
use alloc:: boxed:: Box ;
7
8
use core:: pin:: Pin ;
@@ -52,6 +53,13 @@ impl KernelModule for RustExample {
52
53
println ! ( " my_bool: {}" , my_bool. read( ) ) ;
53
54
println ! ( " my_i32: {}" , my_i32. read( ) ) ;
54
55
56
+ // Including this large variable on the stack will trigger
57
+ // stack probing on the supported archs.
58
+ // This will verify that stack probing does not lead to
59
+ // any errors if we need to link `__rust_probestack`.
60
+ let x: [ u64 ; 1028 ] = core:: hint:: black_box ( [ 5 ; 1028 ] ) ;
61
+ println ! ( "Large array has length: {}" , x. len( ) ) ;
62
+
55
63
Ok ( RustExample {
56
64
message : "on the heap!" . to_owned ( ) ,
57
65
_dev : miscdev:: Registration :: new_pinned :: < RustFile > ( cstr ! ( "rust_miscdev" ) , None ) ?,
Original file line number Diff line number Diff line change 2
2
3
3
#![ no_std]
4
4
#![ feature( allocator_api, global_asm) ]
5
+ #![ feature( test) ]
5
6
6
7
use kernel:: prelude:: * ;
7
8
@@ -36,6 +37,14 @@ impl KernelModule for RustExample2 {
36
37
println ! ( "[2] Parameters:" ) ;
37
38
println ! ( "[2] my_bool: {}" , my_bool. read( ) ) ;
38
39
println ! ( "[2] my_i32: {}" , my_i32. read( ) ) ;
40
+
41
+ // Including this large variable on the stack will trigger
42
+ // stack probing on the supported archs.
43
+ // This will verify that stack probing does not lead to
44
+ // any errors if we need to link `__rust_probestack`.
45
+ let x: [ u64 ; 1028 ] = core:: hint:: black_box ( [ 5 ; 1028 ] ) ;
46
+ println ! ( "Large array has length: {}" , x. len( ) ) ;
47
+
39
48
Ok ( RustExample2 {
40
49
message : "on the heap!" . to_owned ( ) ,
41
50
} )
Original file line number Diff line number Diff line change 2
2
3
3
#![ no_std]
4
4
#![ feature( allocator_api, global_asm) ]
5
+ #![ feature( test) ]
5
6
6
7
use kernel:: prelude:: * ;
7
8
@@ -36,6 +37,14 @@ impl KernelModule for RustExample3 {
36
37
println ! ( "[3] Parameters:" ) ;
37
38
println ! ( "[3] my_bool: {}" , my_bool. read( ) ) ;
38
39
println ! ( "[3] my_i32: {}" , my_i32. read( ) ) ;
40
+
41
+ // Including this large variable on the stack will trigger
42
+ // stack probing on the supported archs.
43
+ // This will verify that stack probing does not lead to
44
+ // any errors if we need to link `__rust_probestack`.
45
+ let x: [ u64 ; 1028 ] = core:: hint:: black_box ( [ 5 ; 1028 ] ) ;
46
+ println ! ( "Large array has length: {}" , x. len( ) ) ;
47
+
39
48
Ok ( RustExample3 {
40
49
message : "on the heap!" . to_owned ( ) ,
41
50
} )
Original file line number Diff line number Diff line change 2
2
3
3
#![ no_std]
4
4
#![ feature( allocator_api, global_asm) ]
5
+ #![ feature( test) ]
5
6
6
7
use kernel:: prelude:: * ;
7
8
@@ -36,6 +37,14 @@ impl KernelModule for RustExample4 {
36
37
println ! ( "[4] Parameters:" ) ;
37
38
println ! ( "[4] my_bool: {}" , my_bool. read( ) ) ;
38
39
println ! ( "[4] my_i32: {}" , my_i32. read( ) ) ;
40
+
41
+ // Including this large variable on the stack will trigger
42
+ // stack probing on the supported archs.
43
+ // This will verify that stack probing does not lead to
44
+ // any errors if we need to link `__rust_probestack`.
45
+ let x: [ u64 ; 1028 ] = core:: hint:: black_box ( [ 5 ; 1028 ] ) ;
46
+ println ! ( "Large array has length: {}" , x. len( ) ) ;
47
+
39
48
Ok ( RustExample4 {
40
49
message : "on the heap!" . to_owned ( ) ,
41
50
} )
You can’t perform that action at this time.
0 commit comments