21 Commits

Author SHA1 Message Date
Trevor Gross
c6b434e5a3 Revert "Temporarily use define_rust_probestack;"
<https://github.com/rust-lang/rust/issues/126984> has been resolved.
Remove the workaround that was introduced to suppress it.

This reverts commit 254edbcad4cfd6a8af32e3297c1037d7984c3c49.
2024-09-28 18:22:22 -04:00
beetrees
086a1c33eb
Temporarily use define_rust_probestack; 2024-07-01 07:42:22 +01:00
Amanieu d'Antras
4abfecabef Import the asm! macro from core::arch
It is going to be removed from the prelude due to the decision in
https://github.com/rust-lang/rust/issues/87228
2021-12-09 23:57:26 +00:00
Amanieu d'Antras
fdbeb187ec Add missing .att_syntax from #414 2021-05-02 21:29:00 +01:00
Amanieu d'Antras
68df0eb817 Mark global_asm! code with .att_syntax
global_asm! will soon change to use Intel syntax by default.
2021-04-10 19:19:21 +01:00
Joseph Richey
5c294cedc0
Move from an "asm" flag to a "no-asm" feature flag (#386)
* Use a no-asm feature instead of an asm feature

This works better as core/alloc/std have trouble supporting default
featues in this crate.

Signed-off-by: Joe Richey <joerichey@google.com>

* Have no-asm disable arm assembly intrinsics

Signed-off-by: Joe Richey <joerichey@google.com>
2020-11-09 09:24:25 -06:00
Xiaoyu Lu
0a957ae73a Add uefi arch x86 probestack support
1. In UEFI x86 arch, probestack need triple underscore.

2.  In UEFI, probestack function do things like _chkstk(in MSVC).
    MSVC x32's _chkstk and cygwin/mingw's _alloca adjust %esp themselves
    MSVC x64's __chkstk and cygwin/mingw's ___chkstk_ms do not adjust
    %rsp themselves.
    But current probestack doesn't adjust esp. And LLVM doesn't generate
    sub %eax, %esp after probestack. So we adjust esp in probestack like
    MSVC x32's _chkstk.
2020-08-14 16:26:37 +08:00
jethrogb
96e3a08719
Manually patch ret instruction for LVI (#359)
Co-authored-by: Jethro Beekman <jethro@fortanix.com>
2020-06-01 10:55:42 -05:00
Tyler Mandry
6677b55fcb
Set probestack visibility to hidden on ELF targets (#340) 2020-02-11 22:21:12 -08:00
Adam Schwalm
328332003d Add separate rust_probestack definition for uefi (#335)
This is necessary because the Mach-O definition must have the
triple underscore, but the UEFI one must not.
2020-01-06 10:22:30 -06:00
Runji Wang
304028b2ed Fix compile error on x86_64-unknown-uefi target (#331)
* fix compile error on x86_64-unknown-uefi target

* Fix tests on nightly
2019-12-10 09:02:14 -08:00
Tyler Mandry
d511d48b97 Add control flow information to __rust_probestack (#328) 2019-12-06 08:51:42 -06:00
Dan Aloni
84e8cc74c5 probestack: add frame pointers for easier traceback
This turns the following backtrace,

```
>> bt
 #0  0x0000555555576f73 in __rust_probestack () at /cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.14/src/probestack.rs:55
Backtrace stopped: Cannot access memory at address 0x7fffff7fedf0
```

To this:

```
>>> bt
 #0  0x0000555555574e47 in __rust_probestack ()
 #1  0x00005555555595ba in test::main ()
 #2  0x00005555555594f3 in std::rt::lang_start::{{closure}} ()
 #3  0x0000555555561ae3 in std::panicking::try::do_call ()
 #4  0x000055555556595a in __rust_maybe_catch_panic ()
 #5  0x000055555555af9b in std::rt::lang_start_internal ()
 #6  0x00005555555594d5 in std::rt::lang_start ()
 #7  0x000055555555977b in main ()
```
2019-07-24 10:18:30 +03:00
Alex Crichton
b2cfc3a4f1 Run rustfmt over everything 2019-05-14 14:40:38 -07:00
Masaki Hara
bf7b7b9109 Explain why we need extra check in probestack. 2018-05-28 13:29:35 +09:00
Masaki Hara
247819f3a0 Fix segfault on probestack with dynamic alloca. 2018-05-27 23:28:17 +09:00
Dan Gohman
3bd28c8b6d Add "volatile" and "memory" clobber to asm! that doesn't fall through.
Use the "volatile" option and the "memory" clobber on inline asm that does
things like return directly, to reduce the chances of compilers rearranging
the code.
2017-11-15 12:49:10 -08:00
Matt Ickstadt
81fe6a9654 Don't compile probestack functions during testing 2017-09-15 18:13:06 -05:00
Alex Crichton
2fa53c4b67 Don't mangle probes all the time 2017-07-07 20:35:14 -07:00
Alex Crichton
f4e92e379c Tweak definition of probestack functions
It looks like the old `__rust_probestack` routine is incompatible with newer
linux kernels. My best guess for this is that the kernel's auto-growth logic is
failing to trigger, causing what looks like a legitimate segfault to get
delivered. My best guess for why *that's* happening is that the faulting address
is below `%rsp`, whereas previously all faulting stack addresses were above
`%rsp`. The probestack routine does not modify `%rsp` as it's probing the stack,
and presumably newer kernels are interpreting this as a legitimate violation.

This commit tweaks the probestack routine to instead update `%rsp` incrementally
as probing happens. The ABI of the function, however, requires that `%rsp`
isn't changed as part of the function so it's restored at the end to the
previous value.
2017-07-07 10:16:03 -07:00
Alex Crichton
f771aac37a Add __rust_probestack intrinsic
Will be required for rust-lang/rust#42816
2017-07-06 06:58:32 -07:00