Comments (10)
A guess is that some kernel structures changed in v5.10 and now, when using the bindings, we have crossed the stack size threshold in some function, thus calling the probe.
from linux.
I think this might be related to some actual errors I'm seeing:
ERROR: modpost: "__rust_probestack" [drivers/char/rust_example_4.ko] undefined!
(see the failed runs here: https://github.com/adamrk/linux/pull/1/checks?check_run_id=1711541791).
The symbol is defined in rust/complier_builtins.o
and vmlinux
:
$ objdump --syms rust/vmlinux | rg probestack
ffffffff81801393 l d .text.__rust_probestack 0000000000000000 .text.__rust_probestack
ffffffff81801393 g F .text.__rust_probestack 0000000000000039 .hidden __rust_probestack
Could this issue be the .hidden
attribute? That seems to be explicitly set in the definition.
I'm happy to dig into this some more, but I'm kind of stuck at this point so any suggestions would be helpful.
from linux.
Looks like the modpost
error isn't directly related. Opened #73 instead.
from linux.
Maybe the issue here is just that .text.__rust_probestack
is a non-standard section? Making this change to vmlinux.lds.h takes care of the warning and seems to work fine, but it doesn't seem correct to add logic there just for this special case:
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index b2b3d81b1535..42d46683f188 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -590,7 +590,7 @@
#define TEXT_TEXT \
ALIGN_FUNCTION(); \
*(.text.hot .text.hot.*) \
- *(TEXT_MAIN .text.fixup) \
+ *(TEXT_MAIN .text.fixup .text.__rust_probestack) \
*(.text.unlikely .text.unlikely.*) \
*(.text.unknown .text.unknown.*) \
NOINSTR_TEXT \
Looks like __rust_probstack
is intentionally put in a separate section (source), but I'm not sure why. Maybe if we end up copying needed parts compiler_builtins
into the tree (one of the options in #69) we can change it to store __rust_probestack
in the regular .text
section?
Or is there a way to add a separate linker script file that specifically handles this?
from linux.
The separate section was added as part of moving from a naked function to global_asm!
in rust-lang/compiler-builtins#328 to add CFI information to help unwinding inside a debugger. The separate section matches how rustc compiles with -Zfunction-sections=yes
by default.
Does Linux have it's own probestack function? You may be able to alias __rust_probestack
to it and completely avoid linking to compiler-builtins. Instead using whatever Linux uses for providing gcc/LLVM compiler intrinsics. Alternatively you could wait for rust-lang/rust#80838 to land and switch to inline asm stack probes.
from linux.
AFAICS both GCC and Clang generate the probing inline by default, so we should likely wait for rust-lang/rust#80838.
Having said that, I don't see stack clash protection used nor proposed for the kernel yet, in fact I see a related patch that required disabling it explicitly -- @nickdesaulniers @kees?
from linux.
Having said that, I don't see stack clash protection used nor proposed for the kernel yet, in fact I see a related patch that required disabling it explicitly
Maybe a userspace centric feature that can be disabled?
ld: warning: orphan section
.text.__rust_probestack' from
drivers/char/rust_example/rust_example.o' being placed in section `.text.__rust_probestack'
ERROR: modpost: "__rust_probestack" [drivers/char/rust_example_4.ko] undefined!
So looks like a missing function (symbol) AND missplaced section? Adding that section makes sense if __rust_probestack
is required; not sure what that would look like in the kernel.
ld: warning: orphan section
.eh_frame' from
drivers/char/rust_example/rust_example.o' being placed in section `.eh_frame'
In C compilers, that's controlled by -fno-asynchronous-unwind-info
which we generally use in the kernel, except for one unwinder that 32b ARM uses (by default). There should be a corresponding flag for rustc
(or, if not, go make it!).
EDIT: sorry for closing/reopened. "Fat fingers"
from linux.
In C compilers, that's controlled by -fno-asynchronous-unwind-info which we generally use in the kernel, except for one unwinder that 32b ARM uses (by default). There should be a corresponding flag for rustc (or, if not, go make it!).
This unwind info is not generated by the compiler. It is part of the assembly that implements __rust_probestack
. The compiler doesn't have any control over this.
So looks like a missing function (symbol) AND missplaced section? Adding that section makes sense if __rust_probestack is required; not sure what that would look like in the kernel.
Same applies here.
Maybe a userspace centric feature that can be disabled?
I believe the target spec has an option to disable stackprobes.
from linux.
I think this is resolved with the latest rustc version changes.
from linux.
Yeah, when compiled with a high enough LLVM (11.0.1), we should now be getting inlined stack probes now since #85. The CI compiles with 11.1.0 at the moment.
However, the warnings went away before, since #80 was merged, since there was no more compiler_builtins
.
from linux.
Related Issues (20)
- out of tree kernel module build is somehow broken HOT 2
- `try_from_foreign()` HOT 2
- Other "good first issues"
- Error updating bindgen HOT 1
- Coding Guidelines document renders unordered list inside blockquote
- Remove unneeded `kernel::prelude::*`s from doctests HOT 6
- Consider column information for `dbg!` (matching 1.76.0's) HOT 1
- Memory ordering model policy/plan HOT 2
- Introduce link for C header mention
- Improper rendering of table cell in Arch Support page HOT 7
- Integrating Rust with C Kernel Modules HOT 6
- How do I compile a Linux kernel for the aarch64 platform HOT 1
- Example on Character Devices? HOT 2
- Replace `kernel::str::CStr` by `core::ffi::CStr` HOT 8
- Move proc-macro documentation into the `kernel` crate HOT 4
- make `impl_has_work` compatible with more complex generics HOT 1
- make `InPlaceInit` compatible with `Arc` HOT 4
- Rust CI wanted features & bugfixes HOT 2
- Build out-of-tree kernel module "hello world" HOT 2
- Writing an linux kernel module in Rust HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linux.