Mathieu Desnoyers [Fri, 23 Feb 2024 19:49:09 +0000 (14:49 -0500)]
Update rseq critical section identifiers to match pseudo-code
Apply the following mapping:
rseq_cmpeqv_storev -> rseq_load_cbne_store__ptr
rseq_addv -> rseq_load_add_store__ptr
rseq_cmpnev_storeoffp_load -> rseq_load_cbeq_store_add_load_store__ptr
rseq_offset_deref_addv -> rseq_load_add_load_add_store__ptr
rseq_cmpeqv_cmpeqv_storev -> rseq_load_cbne_load_cbne_store__ptr
rseq_cmpeqv_trystorev_storev -> rseq_load_cbne_store_store__ptr
rseq_cmpeqv_trymemcpy_storev -> rseq_load_cbne_memcpy_store__ptr
Summary of the identifier convention:
- Begin with an "rseq_" prefix,
- Followed by the pseudo-code,
- Followed by __ and the type (or eventually types) on which the API
applies (similar to the approach taken for C++ mangling).
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I59f251bcf177779ee5f8eb18c629dcd8bf1d633a
Mathieu Desnoyers [Fri, 23 Feb 2024 19:48:28 +0000 (14:48 -0500)]
Add rseq critical section pseudocode documentation
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic7bd7df3566401562a41ffc8112fe95d740c0016
Michael Jeanson [Fri, 23 Feb 2024 15:38:46 +0000 (10:38 -0500)]
tests: add unregistered and no syscall tests
Add tests to validate the state of the public symbols when no
registration has occured and when the rseq syscall is unavailable.
The no syscall test uses seccomp to deny access to rseq, libseccomp is
added as an optionnal build dependency.
Change-Id: I0bf6249fa13bd39af80c21a9d2892cd132644e69
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Thu, 22 Feb 2024 23:16:13 +0000 (18:16 -0500)]
fix: always set the rseq offset and flags
Even when the rseq syscall is unavailable, set the __rseq_offset to the
correct value as application or library code might try to check the
registration status by reading the cpu_id.
Change-Id: I8f579af236e17a45dfb71c3310bc41a9c17652fd
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Thu, 22 Feb 2024 18:25:37 +0000 (13:25 -0500)]
Add 'teardown' parameter to RSEQ_ASM_DEFINE_ABORT on all arch
For consistency, add the 'teardown' parameter to the
RSEQ_ASM_DEFINE_ABORT macro on architectures where it was missing.
Change-Id: I2c4bc46fc0f4a4e4ba0f704950753bf6485794d3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 21 Feb 2024 23:14:15 +0000 (18:14 -0500)]
Add comments to rseq_init()
Change-Id: Ie81eb51d0892e7f84db5b57476c8b14c3a6f5940
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Thu, 2 Nov 2023 18:16:02 +0000 (14:16 -0400)]
doc: fix typo in rseq(2) man page
Change-Id: I52573c813418fd6d4961e3780cfb7c054f5519f2
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Mon, 17 Apr 2023 18:10:20 +0000 (14:10 -0400)]
Update autotools archive macros
Change-Id: I2e200e6c5e9b14e2cfeeda6319f00a4d1795f6f2
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mathieu Desnoyers [Thu, 22 Feb 2024 15:42:08 +0000 (10:42 -0500)]
Clarify logic of RSEQ_ASM*_CMP* macros
The RSEQ_ASM*_CMP* macros come from the x86 implementation which has
"RSEQ_ASM_CMP_CPU_ID()" and static inline functions such as
"rseq_cmpeqv_storev()". The meaning of the "cmp" here is that the
critical section does _not_ abort (does not branch) if the comparison
matches.
But I understand how the ASM helpers that were contributed for other
architectures such as "RSEQ_ASM_OP_CMPEQ()", with the same semantic
of "do not branch to abort if the comparison matches" can be misleading
for someone used to reading assembler on pretty much any architecture,
where the conditional branch is expected to be taken if the condition
matches. So what I have here in librseq is backwards.
Fortunately, librseq is still just a master branch (no releases yet),
and the copy in the Linux kernel selftests is internal to that selftest,
so there are no stable API expectations at this stage.
So I don't think the semantic of e.g. "rseq_cmpeqv_storev()" is
misleading: it proceeds to do the store if the comparison matches.
However, the ASM macros would benefit from a logic flip.
Introduce this in a way that will allow users of the API to catch the
change at compile-time.
This commit applies the following remapping of the macros for added
clarity:
RSEQ_ASM_OP_CMPNE becomes RSEQ_ASM_OP_CBEQ (compare and branch if equal)
RSEQ_ASM_OP_CMPEQ becomes RSEQ_ASM_OP_CBNE (compare and branch if not equal)
RSEQ_ASM_CMP_CPU_ID becomes RSEQ_ASM_CBNE_CPU_ID (compare and branch if cpu id is not equal)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I13bff7e22569b11565a23aca87cf571431d57106
Mathieu Desnoyers [Thu, 22 Feb 2024 15:37:38 +0000 (10:37 -0500)]
Document alignment of rseq_abi for allocated size
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie78f475a2d6f8756b166db45d96367104871c2a8
Mathieu Desnoyers [Wed, 10 Jan 2024 19:20:11 +0000 (14:20 -0500)]
Fix: do not skip !allowed_cpus for mm_cid
Indexing with mm_cid is incompatible with skipping disallowed cpumask.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I138882eef8a5a447e82dddeca9df73047987545f
Mathias Stearn [Tue, 9 Jan 2024 09:32:22 +0000 (10:32 +0100)]
Add arm64 headers to list of headers to be installed
Currently these aren't being installed leading to compile failures on
arm64 when trying to include rseq.h after a `make install`.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id8bb911ad4157e710ee2731436c92756f73cc1be
Mathieu Desnoyers [Wed, 25 Oct 2023 16:09:59 +0000 (12:09 -0400)]
riscv: Fix __always_inline causes duplicate inline
In file included from /usr/include/features.h:503,
from /usr/include/bits/libc-header-start.h:33,
from /usr/include/stdint.h:26,
from /usr/lib64/gcc/riscv64-suse-linux/13/include/stdint.h:9,
from ../../../tests/unit/arch-mo.c:5,
from ../../../tests/unit/arch-mo-cxx.cpp:5:
../../../include/rseq/rseq-riscv-bits.h:9:15: error: duplicate 'inline'
9 | static inline __always_inline
| ^~~~~~~~~~~~~~~
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iabf16e221e6a84ac31163d58c7e6edf2e87c5d18
Michael Jeanson [Mon, 12 Jun 2023 19:38:59 +0000 (15:38 -0400)]
Add missing copyright headers
Change-Id: Icb6343e541608ec00b0c86c6f6c7231abffce25e
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mathieu Desnoyers [Thu, 4 May 2023 14:34:28 +0000 (10:34 -0400)]
Remove whiteline
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I745c5e1daef3575e1a5201e0232f451c0f832c64
Mathieu Desnoyers [Thu, 4 May 2023 14:32:58 +0000 (10:32 -0400)]
Introduce rseq_scalar_type_to_expr to eliminate code duplication
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6fd0aa556b4f486db5d5fb86fd78e3cb1ff9c35b
Gerrit Klein [Wed, 26 Apr 2023 21:44:56 +0000 (23:44 +0200)]
fix: compiler warning `-Wswitch-enum`
Fixes warning "enumeration value ‘XXXX’ not handled in switch
[-Wswitch-enum]" which was observed on gcc 11.3.0 on Ubuntu 22.04 LTS
Linux 6.3.0 x86-64. This warning was enabled by the flag `-Wswitch-enum`
(see:
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wswitch-enum)
Signed-off-by: Gerrit Klein <therealthingy95@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I86cde0be01bf32cb5f6ea0ad313001bba717a9ff
Gerrit Klein [Wed, 26 Apr 2023 21:28:18 +0000 (23:28 +0200)]
fix: compiler warning `-Wswitch-default`
Fixes warning "switch missing default case [-Wswitch-default]" which was
observed on gcc 11.3.0 on Ubuntu 22.04 LTS Linux 6.3.0 x86-64. This
warning was enabled by the flag `-Wswitch-default` (see:
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wswitch-default)
Signed-off-by: Gerrit Klein <therealthingy95@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iad356fd94b0b964a49c382c32a7d193b4ad43d35
Mathieu Desnoyers [Wed, 26 Apr 2023 13:22:00 +0000 (09:22 -0400)]
Re-introduce union for rseq_cs ptr
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8a2a9ec606e9e578a8e9370ee13a340a768c7132
Mathieu Desnoyers [Wed, 26 Apr 2023 12:42:02 +0000 (08:42 -0400)]
Fix: make dist missing header files
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If888ede3080a971dd927d7e475ae3361691bfcae
Mathieu Desnoyers [Tue, 25 Apr 2023 23:28:07 +0000 (19:28 -0400)]
Fix: percpu ops mm_cid tests
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9f114f1af1febd7f646d4771e858d6784273402e
Mathieu Desnoyers [Tue, 25 Apr 2023 23:12:52 +0000 (19:12 -0400)]
Skip mm_cid tests when unavailable
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I53e9d8f3c654b4fe8d5fc5275984f6340f8bc872
Mathieu Desnoyers [Tue, 25 Apr 2023 22:08:33 +0000 (18:08 -0400)]
parametrized test: Report/abort on negative concurrency ID
Report and abort when a negative concurrency ID value is observed by the
spinlock test.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ied1e3dafcd882c1071bcc432c7a5102ca77c4316
Mathieu Desnoyers [Tue, 25 Apr 2023 21:55:05 +0000 (17:55 -0400)]
Implement parametrized mm_cid test
Adapt to the rseq.h API changes introduced by commits
"selftests/rseq: <arch>: Template memory ordering and percpu access mode".
Build a new param_test_mm_cid, param_test_mm_cid_benchmark, and
param_test_mm_cid_compare_twice executables to test the new "mm_cid"
rseq field.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I36405e733876abd7d4f04f07e256e7029c2ea1d2
Mathieu Desnoyers [Tue, 25 Apr 2023 16:13:33 +0000 (12:13 -0400)]
Implement basic percpu ops mm_cid test
Adapt to the rseq.h API changes introduced by commits
"selftests/rseq: <arch>: Template memory ordering and percpu access mode".
Build a new basic_percpu_ops_mm_cid_test to test the new "mm_cid" rseq
field.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I35faa59281b0c7c0d0a449352a45a2d2b0df480d
Mathieu Desnoyers [Tue, 25 Apr 2023 16:02:24 +0000 (12:02 -0400)]
riscv: Template memory ordering and percpu access mode
Introduce a rseq-riscv-bits.h template header which is internally included
to generate the static inline functions covering:
- relaxed and release memory ordering,
- per-cpu-id and per-mm-cid per-cpu data access.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia88fd435f0593f31f31eec5cd8cd8099b1cb8af8
Mathieu Desnoyers [Tue, 25 Apr 2023 16:00:34 +0000 (12:00 -0400)]
s390: Template memory ordering and percpu access mode
Introduce a rseq-s390-bits.h template header which is internally included
to generate the static inline functions covering:
- relaxed and release memory ordering,
- per-cpu-id and per-mm-cid per-cpu data access.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I61b84bef1ebb280f7e04c99f66cd823635780560
Mathieu Desnoyers [Tue, 25 Apr 2023 15:57:06 +0000 (11:57 -0400)]
ppc: Template memory ordering and percpu access mode
Introduce a rseq-ppc-bits.h template header which is internally included
to generate the static inline functions covering:
- relaxed and release memory ordering,
- per-cpu-id and per-mm-cid per-cpu data access.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia2587647c56692f05672fa678779e37e7618d0a0
Mathieu Desnoyers [Tue, 25 Apr 2023 15:55:08 +0000 (11:55 -0400)]
mips: Template memory ordering and percpu access mode
Introduce a rseq-mips-bits.h template header which is internally
included to generate the static inline functions covering:
- relaxed and release memory ordering,
- per-cpu-id and per-mm-cid per-cpu data access.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5dc6a9bc28d6d9a3d85e5ccd871ad5de9d210f91
Mathieu Desnoyers [Tue, 25 Apr 2023 15:52:27 +0000 (11:52 -0400)]
arm64: Template memory ordering and percpu access mode
Introduce a rseq-arm64-bits.h template header which is internally
included to generate the static inline functions covering:
- relaxed and release memory ordering,
- per-cpu-id and per-mm-cid per-cpu data access.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I4d0ae931549d6f61ea2b2f8183a4297db97c3144
Mathieu Desnoyers [Tue, 25 Apr 2023 15:47:43 +0000 (11:47 -0400)]
arm: Template memory ordering and percpu access mode
Introduce a rseq-arm-bits.h template header which is internally included
to generate the static inline functions covering:
- relaxed and release memory ordering,
- per-cpu-id and per-mm-cid per-cpu data access.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I062d49375e1a14efaac8e16f6cc065df2cf9d26c
Mathieu Desnoyers [Tue, 25 Apr 2023 15:43:18 +0000 (11:43 -0400)]
x86: Template memory ordering and percpu access mode
Introduce a rseq-x86-bits.h template header which is internally included
to generate the static inline functions covering:
- relaxed and release memory ordering,
- per-cpu-id and per-mm-cid per-cpu data access.
This introduces changes to the rseq.h selftests API which require to
update the rseq selftest programs. Similar API/templating changes need
to be done for other architectures.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If6889ccebedda2f9bc3b1abe7faad1ba626473c3
Mathieu Desnoyers [Tue, 25 Apr 2023 15:36:36 +0000 (11:36 -0400)]
Implement rseq numa node id field selftest
Test the NUMA node id extension rseq field. Compare it against the value
returned by the getcpu(2) system call while pinned on a specific core.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia01752b2bdd3ab9bf5ef4f2aef12bd1704169e7a
Mathieu Desnoyers [Tue, 25 Apr 2023 15:26:59 +0000 (11:26 -0400)]
rseq.h: implement mm_cid and node_id APIs
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic82b240e654702416936d612a03d8675f9fb869c
Mathieu Desnoyers [Tue, 25 Apr 2023 15:25:04 +0000 (11:25 -0400)]
Update rseq.c to query ELF auxvec
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I562b07aac2c7277eb8be3a31782d402e1d693be1
Mathieu Desnoyers [Tue, 25 Apr 2023 15:23:38 +0000 (11:23 -0400)]
Cleanup: rseq.h: add extra space around __VA_ARGS__
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iec19b59c40b513be33e5ab3207d947c05037adb0
Mathieu Desnoyers [Tue, 25 Apr 2023 15:22:41 +0000 (11:22 -0400)]
Add mm_cid and numa node id to rseq ABI header
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6def7df36e25d47027b3274cf325ce1beb841b75
Mathieu Desnoyers [Tue, 25 Apr 2023 15:18:11 +0000 (11:18 -0400)]
Remove RSEQ_SKIP_FASTPATH code
This code is not currently build by the test Makefile, adds complexity,
and is not overall useful considering that the abort handling loops to
retry the fast-path.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2bf5ead4c0314bb0f28de63d9e6b2a2943c59aa2
therealthingy [Wed, 19 Apr 2023 09:43:09 +0000 (11:43 +0200)]
Fix: `void *` arithmetic compiler warning
Fixes warning "pointer of type ‘void *’ used in subtraction [-Wpointer-arith]"
which was observed on gcc 11.3.0 on Ubuntu 22.04 LTS Linux 6.3.0 RC7 x86-64.
This warning was enabled by the flag `-Wpedantic`.
Link: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wpointer-arith
Signed-off-by: Gerrit Klein <therealthingy95@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Icfcf1d39bcde3730bf38c9ec6ed1521ed4503625
Mathieu Desnoyers [Fri, 21 Apr 2023 14:58:37 +0000 (10:58 -0400)]
All arch: use rseq_unqual_scalar_typeof in load-acquire
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I08f8aedf09ac37fa9b06640a494f20cfbcfeb557
Mathieu Desnoyers [Fri, 21 Apr 2023 14:56:25 +0000 (10:56 -0400)]
c++: compiler: use remove_cv and remove_reference in rseq_unqual_scalar_typeof
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I4c278af941c4e17fbef1b14bf97820100790b6f1
Mathieu Desnoyers [Fri, 21 Apr 2023 14:18:45 +0000 (10:18 -0400)]
rseq_arm64: use rseq_unqual_scalar_typeof in load-acquire
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1cdb0b776f5c81d3cca8bb9fbd03f9549bf40d77
Mathieu Desnoyers [Fri, 21 Apr 2023 14:08:23 +0000 (10:08 -0400)]
Revert "compiler: C++: simplify rseq_unqual_scalar_typeof implementation"
This reverts commit
38f60c8d69e147b5997f850e4f163c36b2e1c91a.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mathieu Desnoyers [Fri, 21 Apr 2023 14:08:17 +0000 (10:08 -0400)]
Revert "compiler: c++: use decltype"
This reverts commit
51e83f8f967435d40541b7ae07b932e5cb1c0d47.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mathieu Desnoyers [Fri, 21 Apr 2023 13:12:21 +0000 (09:12 -0400)]
compiler: c++: use decltype
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I23e4d035029efd9bab6ca2b1bba13146c5eb0375
Mathieu Desnoyers [Fri, 21 Apr 2023 12:54:19 +0000 (08:54 -0400)]
compiler: C++: simplify rseq_unqual_scalar_typeof implementation
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I55b57c217e4338ebeb4947c3452de1422fe5f10c
Mathieu Desnoyers [Thu, 20 Apr 2023 21:36:22 +0000 (17:36 -0400)]
rseq-arm64: Fix buggy load-acquire/store-release macros
The arm64 load-acquire/store-release macros from the Linux kernel rseq
selftests are buggy. Remplace them by a working implementation.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I84cf01cb0fabee89f76cc8d608d203c975397037
Mathieu Desnoyers [Thu, 20 Apr 2023 21:35:29 +0000 (17:35 -0400)]
compiler: implement rseq_unqual_scalar_typeof
Allow defining variables and cast with a typeof which removes the
volatile and const qualitiers.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibe7068e2c307ed47a2eb6db891e717fb7db47282
Mathieu Desnoyers [Thu, 20 Apr 2023 21:34:49 +0000 (17:34 -0400)]
Use __asm__ __volatile__ in rseq_after_asm_goto for c11 compatibility
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I63cde85aeaf5efd03e613c255f31f1091c649790
Mathieu Desnoyers [Thu, 20 Apr 2023 21:33:49 +0000 (17:33 -0400)]
architecture headers: add extra parentheses around macro parameters
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I34a68a8f420ce993b4d6ab21e3c1b86ad5ea4113
Mathieu Desnoyers [Mon, 10 Apr 2023 17:40:34 +0000 (13:40 -0400)]
Tests: Introduce arch-mo unit tests
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibef415f2c9d2c9356c00b11870057f74f89d75d5
Gary Gee [Fri, 14 Apr 2023 08:21:24 +0000 (10:21 +0200)]
Fix: gcc extension compiler warning
Use __VA_ARGS__ rather than GNU args... in macros for improved compiler
compatibility.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie17e73019b1afae721a2270b0b43197c8dca8b88
Mathieu Desnoyers [Fri, 14 Apr 2023 07:42:02 +0000 (09:42 +0200)]
Initialize librseq from `rseq_register_current_thread`
Invoke rseq_init() explicitly from rseq_register_current_thread to make
sure the library is already initialized if thread registration is done
before the library constructor is executed.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6c808ff846cd280522c3b8d50c0c64ca587261ee
Michael Jeanson [Mon, 28 Feb 2022 21:50:31 +0000 (16:50 -0500)]
Implement the REUSE specification for licensing and copyright
See "https://reuse.software/tutorial/", running the linter now returns
this :
$ reuse lint
* Bad licenses:
* Deprecated licenses:
* Licenses without file extension:
* Missing licenses:
* Unused licenses:
* Used licenses: BSD-2-Clause, FSFAP, GPL-2.0-or-later, GPL-3.0-or-later, LicenseRef-Autoconf-exception-macro, Linux-man-pages-copyleft, Linux-syscall-note, MIT
* Read errors: 0
* Files with copyright information: 52 / 52
* Files with license information: 52 / 52
Congratulations! Your project is compliant with version 3.0 of the REUSE Specification :-)
Change-Id: Ifa9f7bc1cbdce204dd8bad4b8978d90b0d7bb90a
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mathieu Desnoyers [Mon, 6 Feb 2023 18:02:01 +0000 (13:02 -0500)]
Relicense librseq to MIT
For simplicity, relicense all librseq (header files, library
implementation and tests) to MIT.
Header files were previously dual-licensed LGPL2.1/MIT, which is
somewhat redundant with MIT.
rseq.c was licensed under LGPL2.1. Relicence it to MIT to facilitate its
integration into statically built applications.
In order to facilitate eventual code sharing between tests and the
library implementation, relicence the tests from LGPL2.1 to MIT.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: Ie819e1527ddffce64e4fe76024e2728e8a723c25
Mathieu Desnoyers [Tue, 10 Jan 2023 19:52:44 +0000 (14:52 -0500)]
rseq man page: remove _Nullable from rseq argument
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I7f19334065d588a0bf4be1c0bde2d6e70e6c2926
Mathieu Desnoyers [Tue, 10 Jan 2023 16:53:44 +0000 (11:53 -0500)]
rseq(2) man page: Update following round of feedback and linting
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I025fe0834370700a479f6b6b38941f0ae55c38b6
Mathieu Desnoyers [Fri, 6 Jan 2023 19:17:23 +0000 (14:17 -0500)]
Update rseq.2 man page based on comments
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5a9848efa217a77ac2905f6ecdc93b80051194c3
Mathieu Desnoyers [Fri, 6 Jan 2023 17:07:20 +0000 (12:07 -0500)]
Update rseq man page
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3489828167982430093834ac9877c6d90e1c9733
Mathieu Desnoyers [Mon, 31 Oct 2022 14:45:32 +0000 (10:45 -0400)]
Allowing querying whether libc support rseq
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I903ca816e3ebbaf9c4fff55431b50f58d0090a8c
Michael Jeanson [Mon, 4 Apr 2022 19:58:37 +0000 (15:58 -0400)]
Add RISC-V rseq support
Change-Id: If6a365a9d003ea9c0e54973aa5d931bd80d33218
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Mon, 13 Jun 2022 15:37:41 +0000 (15:37 +0000)]
fix: check if libc rseq support is registered
When checking for libc rseq support in the library constructor, don't
only depend on the symbols presence, check that the registration was
completed.
This targets a scenario where the libc has rseq support but it is not
wired for the current architecture in 'bits/rseq.h', we want to fallback
to our internal registration mechanism.
Change-Id: I662e537a6511fd4fd9e0650feb17e9c72ec39ddc
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mathieu Desnoyers [Wed, 2 Feb 2022 16:11:58 +0000 (11:11 -0500)]
Use ptrdiff_t for rseq_offset
glibc changes the type of __rseq_offset from int to ptrdiff_t before
the official 2.35 release. Adapt to this change.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iaaef60957cf33f5536817fa92136239fe9e9ab74
Mathieu Desnoyers [Tue, 1 Feb 2022 03:29:53 +0000 (22:29 -0500)]
Cleanup: x86: remove leftover comment
This comment is not relevant anymore with the userspace ABI introduced
by glibc 2.35.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5b54942d84bb12ac0fe2c2246e871e86d51d3af9
Mathieu Desnoyers [Thu, 20 Jan 2022 20:11:45 +0000 (15:11 -0500)]
x86-32: use %gs segment selector for accessing rseq thread area
Rather than use rseq_get_abi() and pass its result through a register to
the inline assembler, directly access the per-thread rseq area through a
memory reference combining the %gs segment selector, the constant offset
of the field in struct rseq, and the rseq_offset value (in a register).
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibd6fac4f2f80774ab74ae495cd0f688d789f36b8
Mathieu Desnoyers [Thu, 20 Jan 2022 19:36:33 +0000 (14:36 -0500)]
x86-64: use %fs segment selector for accessing rseq thread area
Rather than use rseq_get_abi() and pass its result through a register to
the inline assembler, directly access the per-thread rseq area through a
memory reference combining the %fs segment selector, the constant offset
of the field in struct rseq, and the rseq_offset value (in a register).
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia0c93d32b9b36ee1ef6a737a8a5321498fc8c3bc
Mathieu Desnoyers [Mon, 24 Jan 2022 15:17:02 +0000 (10:17 -0500)]
Remove configure check for rseq.h
Not needed anymore, using own copy.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iec27260a112b55bc7540156b41810406795bd1c2
Mathieu Desnoyers [Mon, 24 Jan 2022 15:10:29 +0000 (10:10 -0500)]
Remove unused ARRAY_SIZE macro
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ifa1002ff1458ced26f764660a7f4dc6eb8e259ce
Mathieu Desnoyers [Mon, 24 Jan 2022 14:48:35 +0000 (09:48 -0500)]
Update header copyright dates
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I86ba7cc5fc899ae741374e23211af2f92115987e
Mathieu Desnoyers [Sun, 23 Jan 2022 19:07:54 +0000 (14:07 -0500)]
Introduce rseq-abi.h
Introduce our own header for the rseq kernel ABI, so we do not depend on
Linux kernel headers.
Use this header's rseq_cs.arch.ptr field as accessor for the rseq_cs ptr
on 32-bit.
Remove the extra/ directory because the copy of the Linux kernel headers
is not needed anymore.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0170f2bcaa7defd3a0d3f9a38115bc7d321ddde2
Mathieu Desnoyers [Fri, 21 Jan 2022 22:10:25 +0000 (17:10 -0500)]
Fix: work-around Linux kernel rseq.h uapi endianness issue
Introduce RSEQ_CS_PTR32 to detect and work-around endianness issue for
the rseq_cs ptr32 vs padding fields on little endian 32-bit
architectures.
This does not affect the kernel implementation because the ptr32 field
is not used by the kernel.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Idee8daa16efba8a86655a1eab555f65e0fcea4ca
Mathieu Desnoyers [Fri, 21 Jan 2022 20:47:12 +0000 (15:47 -0500)]
Fix: use long rather than int for offsets
Fixes build issue on x86-64 where the assembler expects a 64-bit
register as input. Use long type across all architectures.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9537acf1269e5d3c0ed156e5f93a422ad5608a1b
Mathieu Desnoyers [Fri, 21 Jan 2022 20:33:09 +0000 (15:33 -0500)]
ppc: remove incomplete undef list
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8f17fc89f34fd671d72a9bb5bcc12ca0bed1ca81
Mathieu Desnoyers [Fri, 21 Jan 2022 20:17:33 +0000 (15:17 -0500)]
Fix: use int rather than off_t for offsets
off_t can be a 64-bit type on 32-bit systems, leading to issues on
32-bit big endian systems (ppc32) where the inline assembler expects a
32-bit register.
There is no point in using off_t here.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9936a1d8e9b64a51f3e1491f1a23204f1cd9c120
Mathieu Desnoyers [Fri, 21 Jan 2022 20:13:14 +0000 (15:13 -0500)]
mips: use rseq_cs ptr 32-bit field
On big endian MIPS architectures, the padding field is before the 32-bit
ptr32 field. Access specifically to the 32-bit ptr32 field rather than
padding. It does not change the behavior on little endian.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I798e7b64b22b9c6484fc37c3a6b903b6ca1194f3
Mathieu Desnoyers [Fri, 21 Jan 2022 20:10:26 +0000 (15:10 -0500)]
arm64: refer to rseq_cs.ptr field
Similarly to other architectures.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I61c17b4874b71ee361666734b6ac68ff591c33fe
Mathieu Desnoyers [Fri, 21 Jan 2022 20:08:31 +0000 (15:08 -0500)]
s390/s390x: refer to rseq_cs pointer field
Does not make any different on little endian architecture, but makes it
clearer in case this code is ever ported to a big endian architecture.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6aa9b0fa4eb7ed55556dbff889104970bcc29944
Mathieu Desnoyers [Fri, 21 Jan 2022 20:05:37 +0000 (15:05 -0500)]
arm: refer to 32-bit pointer field for rseq_cs ptr
This makes no technical difference on little-endian, but is clearer in
case this code is ever used as reference for a port to a big endian
32-bit architecture.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iaf77c2a1b8e6d8f08be0d26ecb84686a417a07d6
Mathieu Desnoyers [Fri, 21 Jan 2022 15:37:55 +0000 (10:37 -0500)]
Fix: ppc32: wrong rseq_cs 32-bit field pointer field on big endian
Update the ptr32 field, not padding.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I7066e7f87ac068d729aca6a11f6e9ba233b04279
Mathieu Desnoyers [Fri, 21 Jan 2022 15:32:35 +0000 (10:32 -0500)]
Fix: ppc32: do not produce cmpdi invalid instruction
Introduce RSEQ_CMP_LONG_INT to fix this.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I02e216edde9ceed14777db2789e7297118503683
Mathieu Desnoyers [Thu, 20 Jan 2022 20:10:22 +0000 (15:10 -0500)]
Fix: provide membarrier_private_expedited_rseq_available on all architectures
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I59afb18ba3687587b2712c3b076b170515d255bf
Mathieu Desnoyers [Mon, 17 Jan 2022 19:10:15 +0000 (14:10 -0500)]
Test for membarrier private expedited rseq availability
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib24ee6e84f2614b614650f391e7312121f26ab17
Mathieu Desnoyers [Mon, 17 Jan 2022 18:01:57 +0000 (13:01 -0500)]
Fix: membarrier flags for kernels headers < 5.10
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0c31e77a97d62140f162e058a975d47c849c5782
Mathieu Desnoyers [Mon, 17 Jan 2022 17:39:56 +0000 (12:39 -0500)]
Test MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ
Based on Google-internal RSEQ work done by Paul Turner and Andrew
Hunter.
This patch adds a selftest for MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ.
The test quite often fails without the previous patch in this
patchset, but consistently passes with it.
[ Contribution from: Peter Oskolkov <posk@google.com>. ]
[ Modified by Mathieu Desnoyers to use rseq APIs for atomic load/store
and memory barriers, so it compiles in C++ and with clang. ]
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib10d52e6e933cda2df2f10c29775a79045e4425c
Mathieu Desnoyers [Mon, 17 Jan 2022 17:39:06 +0000 (12:39 -0500)]
x86_64: Add rseq_offset_deref_addv()
This patch adds rseq_offset_deref_addv() function to
rseq-x86.h, to be used in a selftest in the next patch in the patchset.
Once an architecture adds support for this function they should define
"RSEQ_ARCH_HAS_OFFSET_DEREF_ADDV".
[ Contribution from Peter Oskolkov <posk@google.com>. ]
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia32b27c909a7e41b4262dca3e86b6fb83d0b3bee
Mathieu Desnoyers [Wed, 5 Jan 2022 17:16:31 +0000 (12:16 -0500)]
Fix: Warnings about #if checks of undefined tokens
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If7e7f5a6a725e792fce54fee591ba880bc3766a6
Mathieu Desnoyers [Tue, 21 Dec 2021 18:47:35 +0000 (13:47 -0500)]
Fix: work-around asm goto compiler bugs
gcc and clang each have their own compiler bugs with respect to asm
goto. Implement a work-around for compiler versions known to have those
bugs.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic745eb61163e90f668fb03707f3013e8981fb5fe
Mathieu Desnoyers [Tue, 21 Dec 2021 19:15:50 +0000 (14:15 -0500)]
Remove arm/mips asm goto compiler work-around
The arm and mips work-around for asm goto size guess issues are not
properly documented, and lack reference to specific compiler versions,
upstream compiler bug tracker entry, and reproducer.
I can only find a loosely documented patch in my original LKML rseq post
refering to gcc < 7 on ARM, but it does not appear to be sufficient to
track the exact issue. Also, I am not sure MIPS really has the same
limitation.
Therefore, remove the work-around until we can properly document this.
Link: https://lore.kernel.org/lkml/20171121141900.18471-17-mathieu.desnoyers@efficios.com/
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib4b151234e2255e26d26c149b8051ae024d39153
Michael Jeanson [Wed, 15 Dec 2021 22:34:56 +0000 (17:34 -0500)]
fix: dead initialization reported by scan-build
Change-Id: I7f3735f6f6332e1ba66be480ea4a7dfc5d9f84a9
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 15 Dec 2021 17:14:18 +0000 (12:14 -0500)]
Add debug output to basic_percpu_ops_test
Change-Id: Ie881e24b37b5f7debd5f98ba8d753452d31c1a36
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 15 Dec 2021 16:19:08 +0000 (11:19 -0500)]
configure: enable extended compiler warnings
Import the compiler warning flag detection system from liburcu and
enable extended compiler warnings.
Change-Id: I13bfbaed702c28e2816b13b78fb006462d6d5f92
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Michael Jeanson [Wed, 15 Dec 2021 19:53:52 +0000 (14:53 -0500)]
Build and run tests as C++ programs
Build and run all tests as C++ programs in addition to C. This helps
get confidence that rseq, when used from a C++ program, behaves well.
Change-Id: I68d35d9cadcb859aaa6be4a5c620a6c21075c238
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mathieu Desnoyers [Wed, 15 Dec 2021 17:13:34 +0000 (12:13 -0500)]
param test: Only provide rseq_gettid if BENCHMARK is not defined
Fixes:
param_test.c:20:21: warning: unused function 'rseq_gettid' [-Wunused-function]
static inline pid_t rseq_gettid(void)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I32a14d526263f29034366a9326b0237450088649
Mathieu Desnoyers [Wed, 15 Dec 2021 15:56:52 +0000 (10:56 -0500)]
ppc rseq thread pointer: add extended asm
It appears that using "register void *__result asm ("r2")" is not sufficient
to guarantee that the compiler will indeed use this register. It's documented
as being just a hint that the compiler is free to optimize away. [1]
However, when used as input or output operands when calling Extended
asm, the use of the register is forced, which is our intent:
"The only supported use for this feature is to specify registers for input
and output operands when calling Extended asm (see Extended Asm). This may
be necessary if the constraints for a particular machine don't provide sufficient
control to select the desired register. To force an operand into a register,
create a local variable and specify the register name after the variable's
declaration. Then use the local variable for the asm operand and specify
any constraint letter that matches the register: [...]"
Link: https://gcc.gnu.org/onlinedocs/gcc-6.1.0/gcc/Local-Register-Variables.html
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I30ba3cc163a6e52cee5df0ba6806a4a5f9ec97d6
Mathieu Desnoyers [Tue, 14 Dec 2021 20:30:20 +0000 (15:30 -0500)]
Introduce rseq-generic-thread-pointer.h
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie1cf34d64626babd5d81bad5b1f00de88173f1b6
Mathieu Desnoyers [Tue, 14 Dec 2021 18:39:14 +0000 (13:39 -0500)]
rseq thread pointer: extern C
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibd91f0a8c831b5080a52a5e3bdab2358758068f7
Mathieu Desnoyers [Tue, 14 Dec 2021 18:27:06 +0000 (13:27 -0500)]
Introduce RSEQ_GET_ABI_OVERRIDE
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I17c2a2f15b4e45cb95785ff03424a662ca74bbd2
Mathieu Desnoyers [Tue, 14 Dec 2021 18:24:54 +0000 (13:24 -0500)]
Add missing rseq thread pointer headers to makefile
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0aecd00cc91dde3b99083d12516ca8aa1a76c55f
Mathieu Desnoyers [Tue, 14 Dec 2021 18:23:55 +0000 (13:23 -0500)]
Introduce rseq-thread-pointer.h
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I89469b2af7da6159ae3348747caab3a33d3b6118
Mathieu Desnoyers [Mon, 13 Dec 2021 15:40:54 +0000 (10:40 -0500)]
Update librseq to co-exist with glibc rseq integration
Update librseq to co-exist with the rseq integration merged within the
glibc 2.35 release cycle.
librseq exposes its own "rseq_offset, rseq_size, rseq_flags" ABI.
Query for glibc rseq ABI (__rseq_offset, __rseq_size, __rseq_flags)
using dlsym() in a librseq library constructor. If those are found,
copy their values into rseq_offset, rseq_size, and rseq_flags.
Else, if those glibc symbols are not found, handle rseq registration
ourselves and use our own IE-model TLS to implement the rseq ABI
per-thread storage.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1220cb5c31e823e9cddf211ec56fee03b729b137
This page took 0.043964 seconds and 4 git commands to generate.