2
0
mirror of https://github.com/boostorg/context.git synced 2026-01-19 04:02:17 +00:00

319 Commits

Author SHA1 Message Date
Vyacheslav Chigrin
2179688858 Add information to .eh_frame ELF secion about make_fcontext function. 2025-12-10 13:24:51 +03:00
Zayd Rajab
1be6822473 [AArch64][BTI] Add BTI hint + GNU property to fcontext trampolines (ELF/GAS)
The AArch64 fcontext trampolines (jump_fcontext, make_fcontext, ontop_fcontext)
are indirect-entry-points. On BTI-enforcing systems they must begin with a BTI
or the first resume can trap with SIGILL.

Insert `bti c` (hint #34) at each entry under `__ARM_FEATURE_BTI_DEFAULT`, and
emit `GNU_PROPERTY_AARCH64_FEATURE_1_BTI` from each AArch64 assembly file so
linkers map the DSO with PROT_BTI without requiring -z force-bti.

Scope: ELF/GAS AArch64 trampolines only; +4 bytes per entry

Fixes #308
2025-08-15 22:13:10 +00:00
tkoecker
12280a8b2b fix build of ontop_sparc64_sysv_elf_gas.S
Fix the symbol names used for .size
2025-05-16 12:35:25 +02:00
Dirk Stolle
1775cebd4f Fix several typos 2025-05-01 23:26:37 +02:00
CBBBrother
7f5f436c0f fix tls staack protector on x86_64 2025-02-17 15:00:57 +03:00
Oliver Kowalke
e4c91576d2 Merge pull request #277 from larskanis/fix-arm64-docs
Fix mistakes in documentation on Arm64 on Windows
2024-12-26 08:14:02 +01:00
Oliver Kowalke
ed4f880987 Merge pull request #267 from harishisnow/fix_clickhouse_crash_on_power_pc
Addressing fix for: Clickhouse crash issue on power pc build
2024-12-26 08:06:17 +01:00
Oliver Kowalke
b7ff6fc9f1 Merge pull request #266 from petk/patch-trailing-whitespace
Trim redundant trailing whitespace
2024-12-26 08:04:54 +01:00
Lars Kanis
c46576a703 Fix mistakes in documentation on Arm64 on Windows 2024-12-16 21:22:53 +01:00
Oliver Kowalke
7c80551e16 Merge pull request #273 from rdoeffinger/develop
Convert make_fcontext etc into true C++ symbols
2024-10-27 17:34:44 +01:00
Reimar Döffinger
245904742b Convert make_fcontext etc into true C++ symbols
Also mark the non-mangled fcontext asm function symbols
as hidden visibility
These functions should not be exported as dynamic
symbols by boost, only the namespaced C++ symbols
introduced by this patch should.
2024-10-14 13:23:16 +02:00
Oliver Kowalke
59410dfb78 Revert "Mark fcontext asm functions as hidden visibility"
This reverts commit 7f51f7dea4.
The commit breaks boost.coroutine and boost.fiber.
2024-10-08 21:16:44 +02:00
Reimar Döffinger
7f51f7dea4 Mark fcontext asm functions as hidden visibility
These functions should not be exported as dynamic
symbols if a library uses boost.
2024-10-04 20:40:13 +02:00
Harish Subramanian
a64a2c17ac providing changes for only handling VS63 register 2024-09-11 11:41:24 +05:30
Harish Subramanian
874f46f01b addressing fix for Clickhouse crash issue on power pc build for all CSR registers 2024-09-09 15:54:20 +05:30
Peter Kokot
a62f6a978f Trim redundant trailing whitespace 2024-09-06 05:58:56 +02:00
Oliver Kowalke
5d852fc034 Merge pull request #265 from boostorg/master
Master
2024-08-28 12:45:50 +02:00
Oliver Kowalke
b39e229f7f Merge pull request #259 from arnaud-lb/fix-dup
Remove accidentally duplicated shadow stack handling
2024-08-28 12:41:18 +02:00
Liryna
e878e8edb2 Convert ARM64 armasm to armclang for Windows clang 2024-06-26 18:24:52 +00:00
Andrii Batyiev
38e38cad07 Fix x32 build on x86-64 2024-04-29 14:14:34 +03:00
Arnaud Le Blanc
dc5b59f02b Remove accidentally duplicated shadow stack handling 2024-04-23 13:34:59 +02:00
Claudio Jeker
17945a28a2 Implement the fcontext asm for sparc64
This implements the required asm functions for sparc64_sysv_elf and
was tested on an OpenBSD/sparc64 system.

Jump_fcontext uses an extra C call frame to store the frame-pointer and
return address. Because of this the code is simply a save (to new reg
window), then forcing a window flush and finally switch stack and restore
from there.

Since jump_fcontext() uses a register window and stack frame, make_fcontext()
reserves two call frames on the stack (one for jump_fcontext() and the other
for the callback function).

OpenBSD/sparc64 uses stackghost which prevents userland from overriding the
return-address on the stack. Because of this make_fcontext() uses an extra
trampoline to implement the _exit(0) call if the callback returns.

All tests pass with this on OpenBSD/sparc64 (also the tests for fiber,
coroutine and coroutine2).
2024-02-13 11:16:42 +01:00
David Carlier
a2dd396dd9 fix solaris/illumos build on make/jump assembly directives.
on those platforms, albeit being 64 bits, they produce 32 bits binaries by default.
2024-02-04 08:07:39 +00:00
David Seifert
922e033fa1 Fix x32 build on x86-64 2024-01-23 13:23:29 +01:00
Mohammad Bahoosh
dcf037830b Suppressing -Wsign-conversion warnings 2023-10-28 21:02:03 -08:00
Oliver Kowalke
033ea19511 PPC64 file was accidentally commented out 2023-10-01 16:49:31 +02:00
ltrk2
3bedb2d779 Improve ABI conformance of s390x fcontext 2023-05-15 12:47:56 -07:00
ltrk2
e4e3014f3e Store entry point arguments in fibre's own context (s390x) 2023-05-11 12:14:47 -07:00
Niels Dossche
0eb4263705 Make sure the i386 sysv stack is aligned
The previous fix had a typo in which the wrong offset was used which
meant that the alignment still wasn't correct. Fix this properly now.
2023-01-27 23:36:15 +01:00
Niels Dossche
e286649f08 Make sure the i386 sysv stack is aligned
SysV ABI requires a stack alignment of 16 bytes. Currently, for i386
with SysV ABI, the trampoline function is entered with an unaligned
stack. This causes problems for the context-function that is jumped to
as its stack is also unaligned. This causes a crash for our use-case
because the context function contains an SSE instruction which reads
from the stack. The SSE instruction requires the correct alignment.
Fix it by changing the 0x2c offset to 0x30, such that the stack remains
aligned.
2023-01-25 22:07:30 +01:00
Evan Miller
070d03fc7e Fixes for Darwin PPC32
For make_fcontext, use the diff provided here:

https://github.com/boostorg/context/issues/211#issuecomment-1328154669

For ontop_context, adapt the Linux PPC32 fixes from here:

df8fb6b528

Co-authored-by: George Koehler <kernigh@gmail.com>
2022-12-27 10:47:41 -05:00
Sergey Fedorov
a3b0224b0c Darwin make_ppc32: fix addi in l1 2022-10-06 13:01:18 +08:00
PeterYang12
3484575878 Add shadow stack support for fcontext
Shadow stack is part of Intel's Control-Flow Enforcement Technology.

    Whenever a function is called, the return address is pushed onto both
    the regular stack and the shadow stack. When that function returns, the
    return addresses are popped off both stacks and compared; if they fail
    to match, #CP raised.

    Backport this commit from https://github.com/php/php-src/pull/9283
    With this commit, we create shadow stack with syscall map_shadow_stack
    (no.451) for each fiber context and switch the shadow stack accordingly
    during fcontext switch.

Signed-off-by: PeterYang12 <yuhan.yang@intel.com>
Signed-off-by: chen-hu-97 <hu1.chen@intel.com>
2022-09-29 22:58:22 -07:00
Oliver Kowalke
97a0054999 Merge pull request #205 from apolukhin/antoshkka/stack-protector
Support for stack protection
2022-09-18 16:25:02 +02:00
Antony Polukhin
f96d65bc37 fix again 2022-09-18 11:19:22 +03:00
Antony Polukhin
a6e3302f91 fix 2022-09-18 11:02:23 +03:00
Antony Polukhin
2f0b5034b7 Support for stack protection 2022-09-17 18:38:12 +03:00
Sergey Fedorov
5f7e1f216c powerpc-darwin: does not use TOC on ppc64 2022-09-06 04:44:16 +07:00
Sergey Fedorov
1cdfb35343 powerpc-darwin: fix broken code in make_ppc* assembler 2022-09-06 02:54:06 +07:00
Sergey Fedorov
5f2c355042 powerpc-darwin: fix assembler comment character 2022-09-06 02:47:32 +07:00
dixyes
abf8e04e23 Spport Windows arm64 cpp exception
Windows C++ exception unwinding needs TEB(TIB) stack info matching real
stack.
2022-06-26 09:53:11 +08:00
dixyes
697299ea55 Add windows arm64 fcontext support 2022-06-26 09:51:30 +08:00
PeterYang12
b62a991ee6 Add support for Indirect Branch Tracking (IBT)
Indirect Branch Tracking(IBT) is part of Intel's Control-Flow
Enforcement Technology(CET). IBT is hardware based, forward edge
Control-Flow-Integrity mechanism where any indirect CALL/JMP must
target an ENDBR instruction or suffer #CP.

This commit inserts endbr64 instruction in assembly to support IBT.
2022-05-16 00:15:57 -07:00
Zhang Na
e1001c479e Add support for loongarch64 2022-02-15 17:28:33 +08:00
Clément Chigot
f7272bce6c asm: adjust XCOFF files for AIX assembler
AIX assembler is a bit more strict than GNU assembler. Thus, adjust
the XCOFF asm files to be able to accept both assembler.

For PPC64 jump and make files, most of the work have already been
made recently, only the functions' header needs to be updated.
For PPC64 ontop and PPC32 files, the algorithms where also wrong.
So the whole files have been reworked.

The PPC32 stack layout is based on AIX documentation:
https://www.ibm.com/docs/en/aix/7.2?topic=overview-runtime-process-stack
For PPC64, as it seems to work fine and is already being used in php,
I've kept the current layout based on PPC64 Linux version.

Tested with boost/context, boost/fiber and boost/coroutine2.
Note that the test_sscanf is still failing in ppc32 because of
float precision. (3.13999 is returned instead of 3.14).
2021-11-03 10:54:05 +01:00
Antony Polukhin
732ec07981 restore work with TLS[__PTK_LIBC_DYLD_Unwind_SjLj_Key] on arm aapcs macho 2021-09-24 11:35:23 +03:00
Calvin Buckley
b701608477 Fix 64-bit XCOFF assembly
It should almost exactly match the ELFv1 ABI code now, except with
IBM assembler syntax.

Tested with PHP fibres. Fixes #180
2021-08-11 15:01:03 -03:00
Nikita Kniazev
8425e830ea Cease dependence on Thread
On C++11 static local variables are initialized in thread-safe manner, but even on C++03 it should not be a problem because in our case variables are of trivial types, which means double initialization is not an issue, and they are initialized with the same value in every thread.
2021-06-12 22:23:08 +03:00
Sean Baxter
08fb973e09 Update stack_traits.cpp 2021-06-04 22:27:43 -04:00
Oliver Kowalke
7c451db14a remove execution_context.hpp from contiunation.cpp 2021-06-01 17:42:50 +02:00