Introduce common generic header file
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 29 Feb 2024 14:55:05 +0000 (09:55 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 29 Feb 2024 14:55:05 +0000 (09:55 -0500)
Move:

-  RSEQ_ASM_DEFINE_TABLE,
- __RSEQ_ASM_DEFINE_TABLE,
- RSEQ_ASM_DEFINE_EXIT_POINT.

to a generic common header file now that those are exact copy across all
architectures.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1f27e8889b13d263467a1bab92b272cc80aa0743

include/Makefile.am
include/rseq/arch/aarch64.h
include/rseq/arch/arm.h
include/rseq/arch/generic/common.h [new file with mode: 0644]
include/rseq/arch/mips.h
include/rseq/arch/ppc.h
include/rseq/arch/riscv.h
include/rseq/arch/s390.h
include/rseq/arch/x86.h

index dd540feefc7c5d161a80338cfd45bee44522d175..bc27c398e5b0063935daf9a16bec5adebff8ca43 100644 (file)
@@ -6,6 +6,7 @@ nobase_include_HEADERS = \
        rseq/arch/aarch64.h \
        rseq/arch/arm/bits.h \
        rseq/arch/arm.h \
+       rseq/arch/generic/common.h \
        rseq/arch/generic/thread-pointer.h \
        rseq/arch/mips/bits.h \
        rseq/arch/mips.h \
index e2ae825878af7c932f96706b5487a8740e7d5873..cd1d4de5404d49b44924e8c87dc8222888567c70 100644 (file)
@@ -115,64 +115,8 @@ do {                                                                               \
 #define RSEQ_ASM_TMP_REG       "x15"
 #define RSEQ_ASM_TMP_REG_2     "x14"
 
-/* Only used in RSEQ_ASM_DEFINE_TABLE. */
-#define __RSEQ_ASM_DEFINE_TABLE(label, version, flags, start_ip,               \
-                               post_commit_offset, abort_ip)                   \
-       "       .pushsection    __rseq_cs, \"aw\"\n"                            \
-       "       .balign 32\n"                                                   \
-       __rseq_str(label) ":\n"                                                 \
-       "       " RSEQ_ASM_U32(__rseq_str(version)) "\n"                        \
-       "       " RSEQ_ASM_U32(__rseq_str(flags)) "\n"                          \
-       "       " RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n"                   \
-       "       " RSEQ_ASM_U64_PTR(__rseq_str(post_commit_offset)) "\n"         \
-       "       " RSEQ_ASM_U64_PTR(__rseq_str(abort_ip)) "\n"                   \
-       "       .popsection\n\t"                                                \
-       "       .pushsection __rseq_cs_ptr_array, \"aw\"\n"                     \
-       "       " RSEQ_ASM_U64_PTR(__rseq_str(label) "b") "\n"                  \
-       "       .popsection\n"
-
-/*
- * Define an rseq critical section structure of version 0 with no flags.
- *
- *  @label:
- *    Local label for the beginning of the critical section descriptor
- *    structure.
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @post_commit_ip:
- *    Pointer to the instruction after the last instruction of the sequence of
- *    consecutive assembly instructions.
- *  @abort_ip:
- *    Pointer to the instruction where to move the execution flow in case of
- *    abort of the sequence of consecutive assembly instructions.
- */
-#define RSEQ_ASM_DEFINE_TABLE(label, start_ip, post_commit_ip, abort_ip)       \
-       __RSEQ_ASM_DEFINE_TABLE(label, 0x0, 0x0, start_ip,                      \
-                               (post_commit_ip) - (start_ip), abort_ip)
-
-/*
- * Define the @exit_ip pointer as an exit point for the sequence of consecutive
- * assembly instructions at @start_ip.
- *
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @exit_ip:
- *    Pointer to an exit point instruction.
- *
- * Exit points of a rseq critical section consist of all instructions outside
- * of the critical section where a critical section can either branch to or
- * reach through the normal course of its execution. The abort IP and the
- * post-commit IP are already part of the __rseq_cs section and should not be
- * explicitly defined as additional exit points. Knowing all exit points is
- * useful to assist debuggers stepping over the critical section.
- */
-#define RSEQ_ASM_DEFINE_EXIT_POINT(start_ip, exit_ip)                          \
-       "       .pushsection __rseq_exit_point_array, \"aw\"\n"                 \
-       "       " RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n"                   \
-       "       " RSEQ_ASM_U64_PTR(__rseq_str(exit_ip)) "\n"                    \
-       "       .popsection\n"
+/* Common architecture support macros. */
+#include "rseq/arch/generic/common.h"
 
 /*
  * Define a critical section abort handler.
index 6030d4f3dc70c5dcdfad6b54274de147145fa78b..d675c973f61dc793d06fc884bb5dccb96f871710 100644 (file)
@@ -107,64 +107,8 @@ do {                                                                       \
 
 #define RSEQ_ASM_U32(x)                        ".word " x
 
-/* Only used in RSEQ_ASM_DEFINE_TABLE. */
-#define __RSEQ_ASM_DEFINE_TABLE(label, version, flags, start_ip,       \
-                               post_commit_offset, abort_ip)           \
-               ".pushsection __rseq_cs, \"aw\"\n\t"                    \
-               ".balign 32\n\t"                                        \
-               __rseq_str(label) ":\n\t"                               \
-               RSEQ_ASM_U32(__rseq_str(version)) "\n\t"                \
-               RSEQ_ASM_U32(__rseq_str(flags)) "\n\t"                  \
-               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
-               RSEQ_ASM_U64_PTR(__rseq_str(post_commit_offset)) "\n\t" \
-               RSEQ_ASM_U64_PTR(__rseq_str(abort_ip)) "\n\t"           \
-               ".popsection\n\t"                                       \
-               ".pushsection __rseq_cs_ptr_array, \"aw\"\n\t"          \
-               RSEQ_ASM_U64_PTR(__rseq_str(label) "b") "\n\t"          \
-               ".popsection\n\t"
-
-/*
- * Define an rseq critical section structure of version 0 with no flags.
- *
- *  @label:
- *    Local label for the beginning of the critical section descriptor
- *    structure.
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @post_commit_ip:
- *    Pointer to the instruction after the last instruction of the sequence of
- *    consecutive assembly instructions.
- *  @abort_ip:
- *    Pointer to the instruction where to move the execution flow in case of
- *    abort of the sequence of consecutive assembly instructions.
- */
-#define RSEQ_ASM_DEFINE_TABLE(label, start_ip, post_commit_ip, abort_ip) \
-       __RSEQ_ASM_DEFINE_TABLE(label, 0x0, 0x0, start_ip,              \
-                               (post_commit_ip) - (start_ip), abort_ip)
-
-/*
- * Define the @exit_ip pointer as an exit point for the sequence of consecutive
- * assembly instructions at @start_ip.
- *
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @exit_ip:
- *    Pointer to an exit point instruction.
- *
- * Exit points of a rseq critical section consist of all instructions outside
- * of the critical section where a critical section can either branch to or
- * reach through the normal course of its execution. The abort IP and the
- * post-commit IP are already part of the __rseq_cs section and should not be
- * explicitly defined as additional exit points. Knowing all exit points is
- * useful to assist debuggers stepping over the critical section.
- */
-#define RSEQ_ASM_DEFINE_EXIT_POINT(start_ip, exit_ip)                  \
-               ".pushsection __rseq_exit_point_array, \"aw\"\n\t"      \
-               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
-               RSEQ_ASM_U64_PTR(__rseq_str(exit_ip)) "\n\t"            \
-               ".popsection\n\t"
+/* Common architecture support macros. */
+#include "rseq/arch/generic/common.h"
 
 /*
  * Store the address of the critical section descriptor structure at
diff --git a/include/rseq/arch/generic/common.h b/include/rseq/arch/generic/common.h
new file mode 100644 (file)
index 0000000..a34e286
--- /dev/null
@@ -0,0 +1,70 @@
+/* SPDX-License-Identifier: MIT */
+/* SPDX-FileCopyrightText: 2024 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> */
+
+/*
+ * rseq/arch/generic/common.h: Common architecture support macros.
+ */
+
+#ifndef _RSEQ_GENERIC_COMMON_H
+#define _RSEQ_GENERIC_COMMON_H
+
+/* Only used in RSEQ_ASM_DEFINE_TABLE. */
+#define __RSEQ_ASM_DEFINE_TABLE(label, version, flags,                 \
+                               start_ip, post_commit_offset, abort_ip) \
+               ".pushsection __rseq_cs, \"aw\"\n\t"                    \
+               ".balign 32\n\t"                                        \
+               __rseq_str(label) ":\n\t"                               \
+               RSEQ_ASM_U32(__rseq_str(version)) "\n\t"                \
+               RSEQ_ASM_U32(__rseq_str(flags)) "\n\t"                  \
+               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
+               RSEQ_ASM_U64_PTR(__rseq_str(post_commit_offset)) "\n\t" \
+               RSEQ_ASM_U64_PTR(__rseq_str(abort_ip)) "\n\t"           \
+               ".popsection\n\t"                                       \
+               ".pushsection __rseq_cs_ptr_array, \"aw\"\n\t"          \
+               RSEQ_ASM_U64_PTR(__rseq_str(label) "b") "\n\t"          \
+               ".popsection\n\t"
+
+/*
+ * Define an rseq critical section structure of version 0 with no flags.
+ *
+ *  @label:
+ *    Local label for the beginning of the critical section descriptor
+ *    structure.
+ *  @start_ip:
+ *    Pointer to the first instruction of the sequence of consecutive assembly
+ *    instructions.
+ *  @post_commit_ip:
+ *    Pointer to the instruction after the last instruction of the sequence of
+ *    consecutive assembly instructions.
+ *  @abort_ip:
+ *    Pointer to the instruction where to move the execution flow in case of
+ *    abort of the sequence of consecutive assembly instructions.
+ */
+#define RSEQ_ASM_DEFINE_TABLE(label, start_ip, post_commit_ip, abort_ip) \
+       __RSEQ_ASM_DEFINE_TABLE(label, 0x0, 0x0, start_ip,              \
+                               (post_commit_ip) - (start_ip), abort_ip)
+
+/*
+ * Define the @exit_ip pointer as an exit point for the sequence of consecutive
+ * assembly instructions at @start_ip.
+ *
+ *  @start_ip:
+ *    Pointer to the first instruction of the sequence of consecutive assembly
+ *    instructions.
+ *  @exit_ip:
+ *    Pointer to an exit point instruction.
+ *
+ * Exit points of a rseq critical section consist of all instructions outside
+ * of the critical section where a critical section can either branch to or
+ * reach through the normal course of its execution. The abort IP and the
+ * post-commit IP are already part of the __rseq_cs section and should not be
+ * explicitly defined as additional exit points. Knowing all exit points is
+ * useful to assist debuggers stepping over the critical section.
+ */
+#define RSEQ_ASM_DEFINE_EXIT_POINT(start_ip, exit_ip)                  \
+               ".pushsection __rseq_exit_point_array, \"aw\"\n\t"      \
+               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
+               RSEQ_ASM_U64_PTR(__rseq_str(exit_ip)) "\n\t"            \
+               ".popsection\n\t"
+
+#endif
index 641b2782368e03f07d60f3cd9c1260876ea518f8..d369f9170e6c69d8526e1279f2744651898a0bc0 100644 (file)
@@ -119,64 +119,8 @@ do {                                                                       \
 
 #define RSEQ_ASM_U32(x)                        ".word " x
 
-/* Only used in RSEQ_ASM_DEFINE_TABLE. */
-#define __RSEQ_ASM_DEFINE_TABLE(label, version, flags, start_ip, \
-                               post_commit_offset, abort_ip) \
-               ".pushsection __rseq_cs, \"aw\"\n\t" \
-               ".balign 32\n\t" \
-               __rseq_str(label) ":\n\t" \
-               RSEQ_ASM_U32(__rseq_str(version)) "\n\t" \
-               RSEQ_ASM_U32(__rseq_str(flags)) "\n\t" \
-               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t" \
-               RSEQ_ASM_U64_PTR(__rseq_str(post_commit_offset)) "\n\t" \
-               RSEQ_ASM_U64_PTR(__rseq_str(abort_ip)) "\n\t" \
-               ".popsection\n\t" \
-               ".pushsection __rseq_cs_ptr_array, \"aw\"\n\t" \
-               RSEQ_ASM_U64_PTR(__rseq_str(label) "b") "\n\t" \
-               ".popsection\n\t"
-
-/*
- * Define an rseq critical section structure of version 0 with no flags.
- *
- *  @label:
- *    Local label for the beginning of the critical section descriptor
- *    structure.
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @post_commit_ip:
- *    Pointer to the instruction after the last instruction of the sequence of
- *    consecutive assembly instructions.
- *  @abort_ip:
- *    Pointer to the instruction where to move the execution flow in case of
- *    abort of the sequence of consecutive assembly instructions.
- */
-#define RSEQ_ASM_DEFINE_TABLE(label, start_ip, post_commit_ip, abort_ip) \
-       __RSEQ_ASM_DEFINE_TABLE(label, 0x0, 0x0, start_ip, \
-                               (post_commit_ip) - (start_ip), abort_ip)
-
-/*
- * Define the @exit_ip pointer as an exit point for the sequence of consecutive
- * assembly instructions at @start_ip.
- *
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @exit_ip:
- *    Pointer to an exit point instruction.
- *
- * Exit points of a rseq critical section consist of all instructions outside
- * of the critical section where a critical section can either branch to or
- * reach through the normal course of its execution. The abort IP and the
- * post-commit IP are already part of the __rseq_cs section and should not be
- * explicitly defined as additional exit points. Knowing all exit points is
- * useful to assist debuggers stepping over the critical section.
- */
-#define RSEQ_ASM_DEFINE_EXIT_POINT(start_ip, exit_ip) \
-               ".pushsection __rseq_exit_point_array, \"aw\"\n\t" \
-               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t" \
-               RSEQ_ASM_U64_PTR(__rseq_str(exit_ip)) "\n\t" \
-               ".popsection\n\t"
+/* Common architecture support macros. */
+#include "rseq/arch/generic/common.h"
 
 /* Only used in RSEQ_ASM_DEFINE_ABORT. */
 #define __RSEQ_ASM_DEFINE_ABORT(label, teardown, abort_label, \
index 8c7566ed694a3c1768ed98d5e84cf833da3b7d4f..d1b25cfac788179d2a7f30d94a7267b9f237108b 100644 (file)
@@ -92,6 +92,27 @@ do {                                                                 \
 
 #define RSEQ_ASM_U32(x)                        ".long " x
 
+/* Common architecture support macros. */
+#include "rseq/arch/generic/common.h"
+
+/*
+ * Define a critical section abort handler.
+ *
+ *  @label:
+ *    Local label to the abort handler.
+ *  @teardown:
+ *    Sequence of instructions to run on abort.
+ *  @abort_label:
+ *    C label to jump to at the end of the sequence.
+ */
+#define RSEQ_ASM_DEFINE_ABORT(label, teardown, abort_label)                    \
+               ".pushsection __rseq_failure, \"ax\"\n\t"                       \
+               RSEQ_ASM_U32(__rseq_str(RSEQ_SIG)) "\n\t"                       \
+               __rseq_str(label) ":\n\t"                                       \
+               teardown                                                        \
+               "b %l[" __rseq_str(abort_label) "]\n\t"                         \
+               ".popsection\n\t"
+
 /*
  * Store the address of the critical section descriptor structure at
  * @cs_label into the @rseq_cs pointer and emit the label @label, which
@@ -125,83 +146,6 @@ do {                                                                       \
                __rseq_str(label) ":\n\t"
 #endif
 
-/* Only used in RSEQ_ASM_DEFINE_TABLE. */
-#define __RSEQ_ASM_DEFINE_TABLE(label, version, flags,                         \
-                       start_ip, post_commit_offset, abort_ip)                 \
-               ".pushsection __rseq_cs, \"aw\"\n\t"                            \
-               ".balign 32\n\t"                                                \
-               __rseq_str(label) ":\n\t"                                       \
-               RSEQ_ASM_U32(__rseq_str(version)) "\n\t"                        \
-               RSEQ_ASM_U32(__rseq_str(flags)) "\n\t"                          \
-               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"                   \
-               RSEQ_ASM_U64_PTR(__rseq_str(post_commit_offset)) "\n\t"         \
-               RSEQ_ASM_U64_PTR(__rseq_str(abort_ip)) "\n\t"                   \
-               ".popsection\n\t"                                               \
-               ".pushsection __rseq_cs_ptr_array, \"aw\"\n\t"                  \
-               RSEQ_ASM_U64_PTR(__rseq_str(label) "b") "\n\t"                  \
-               ".popsection\n\t"
-
-/*
- * Define an rseq critical section structure of version 0 with no flags.
- *
- *  @label:
- *    Local label for the beginning of the critical section descriptor
- *    structure.
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @post_commit_ip:
- *    Pointer to the instruction after the last instruction of the sequence of
- *    consecutive assembly instructions.
- *  @abort_ip:
- *    Pointer to the instruction where to move the execution flow in case of
- *    abort of the sequence of consecutive assembly instructions.
- */
-#define RSEQ_ASM_DEFINE_TABLE(label, start_ip, post_commit_ip, abort_ip)       \
-               __RSEQ_ASM_DEFINE_TABLE(label, 0x0, 0x0, start_ip,              \
-                                       (post_commit_ip) - (start_ip), abort_ip)
-
-/*
- * Define the @exit_ip pointer as an exit point for the sequence of consecutive
- * assembly instructions at @start_ip.
- *
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @exit_ip:
- *    Pointer to an exit point instruction.
- *
- * Exit points of a rseq critical section consist of all instructions outside
- * of the critical section where a critical section can either branch to or
- * reach through the normal course of its execution. The abort IP and the
- * post-commit IP are already part of the __rseq_cs section and should not be
- * explicitly defined as additional exit points. Knowing all exit points is
- * useful to assist debuggers stepping over the critical section.
- */
-#define RSEQ_ASM_DEFINE_EXIT_POINT(start_ip, exit_ip)                  \
-               ".pushsection __rseq_exit_point_array, \"aw\"\n\t"      \
-               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
-               RSEQ_ASM_U64_PTR(__rseq_str(exit_ip)) "\n\t"            \
-               ".popsection\n\t"
-
-/*
- * Define a critical section abort handler.
- *
- *  @label:
- *    Local label to the abort handler.
- *  @teardown:
- *    Sequence of instructions to run on abort.
- *  @abort_label:
- *    C label to jump to at the end of the sequence.
- */
-#define RSEQ_ASM_DEFINE_ABORT(label, teardown, abort_label)                    \
-               ".pushsection __rseq_failure, \"ax\"\n\t"                       \
-               RSEQ_ASM_U32(__rseq_str(RSEQ_SIG)) "\n\t"                       \
-               __rseq_str(label) ":\n\t"                                       \
-               teardown                                                        \
-               "b %l[" __rseq_str(abort_label) "]\n\t"                         \
-               ".popsection\n\t"
-
 /* Jump to local label @label when @cpu_id != @current_cpu_id. */
 #define RSEQ_ASM_CBNE_CPU_ID(cpu_id, current_cpu_id, label)                    \
                RSEQ_INJECT_ASM(2)                                              \
index 3cfb9ac04e92dadcc490952c1846daf5ec8bba10..eceaf2fba5dc1c4730994a62dfcf8f3e439eefec 100644 (file)
@@ -86,64 +86,8 @@ do {                                                                 \
 #define RSEQ_ASM_TMP_REG_3     "t4"
 #define RSEQ_ASM_TMP_REG_4     "t3"
 
-/* Only used in RSEQ_ASM_DEFINE_TABLE. */
-#define __RSEQ_ASM_DEFINE_TABLE(label, version, flags, start_ip,       \
-                               post_commit_offset, abort_ip)           \
-       ".pushsection   __rseq_cs, \"aw\"\n"                            \
-       ".balign        32\n"                                           \
-       __rseq_str(label) ":\n"                                         \
-       RSEQ_ASM_U32(__rseq_str(version)) "\n"                          \
-       RSEQ_ASM_U32(__rseq_str(flags)) "\n"                            \
-       RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n"                     \
-       RSEQ_ASM_U64_PTR(__rseq_str(post_commit_offset)) "\n"           \
-       RSEQ_ASM_U64_PTR(__rseq_str(abort_ip)) "\n"                     \
-       ".popsection\n\t"                                               \
-       ".pushsection __rseq_cs_ptr_array, \"aw\"\n"                    \
-       RSEQ_ASM_U64_PTR(__rseq_str(label) "b") "\n"                    \
-       ".popsection\n"
-
-/*
- * Define an rseq critical section structure of version 0 with no flags.
- *
- *  @label:
- *    Local label for the beginning of the critical section descriptor
- *    structure.
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @post_commit_ip:
- *    Pointer to the instruction after the last instruction of the sequence of
- *    consecutive assembly instructions.
- *  @abort_ip:
- *    Pointer to the instruction where to move the execution flow in case of
- *    abort of the sequence of consecutive assembly instructions.
- */
-#define RSEQ_ASM_DEFINE_TABLE(label, start_ip, post_commit_ip, abort_ip) \
-       __RSEQ_ASM_DEFINE_TABLE(label, 0x0, 0x0, start_ip,               \
-                               (post_commit_ip) - (start_ip), abort_ip)
-
-/*
- * Define the @exit_ip pointer as an exit point for the sequence of consecutive
- * assembly instructions at @start_ip.
- *
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @exit_ip:
- *    Pointer to an exit point instruction.
- *
- * Exit points of a rseq critical section consist of all instructions outside
- * of the critical section where a critical section can either branch to or
- * reach through the normal course of its execution. The abort IP and the
- * post-commit IP are already part of the __rseq_cs section and should not be
- * explicitly defined as additional exit points. Knowing all exit points is
- * useful to assist debuggers stepping over the critical section.
- */
-#define RSEQ_ASM_DEFINE_EXIT_POINT(start_ip, exit_ip)                  \
-       ".pushsection __rseq_exit_point_array, \"aw\"\n"                \
-       RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n"                     \
-       RSEQ_ASM_U64_PTR(__rseq_str(exit_ip)) "\n"                      \
-       ".popsection\n"
+/* Common architecture support macros. */
+#include "rseq/arch/generic/common.h"
 
 /*
  * Define a critical section abort handler.
index 0b111165ca337c2e75f4ac40f62d87151c406920..9804b9d20001527d39170781ff79b34ffcc1f8f1 100644 (file)
@@ -85,64 +85,8 @@ do {                                                                 \
 
 #define RSEQ_ASM_U32(x)                        ".long " x
 
-/* Only used in RSEQ_ASM_DEFINE_TABLE. */
-#define __RSEQ_ASM_DEFINE_TABLE(label, version, flags,                         \
-                       start_ip, post_commit_offset, abort_ip)                 \
-               ".pushsection __rseq_cs, \"aw\"\n\t"                            \
-               ".balign 32\n\t"                                                \
-               __rseq_str(label) ":\n\t"                                       \
-               RSEQ_ASM_U32(__rseq_str(version)) "\n\t"                \
-               RSEQ_ASM_U32(__rseq_str(flags)) "\n\t"                  \
-               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"                   \
-               RSEQ_ASM_U64_PTR(__rseq_str(post_commit_offset)) "\n\t"         \
-               RSEQ_ASM_U64_PTR(__rseq_str(abort_ip)) "\n\t"                   \
-               ".popsection\n\t"                                               \
-               ".pushsection __rseq_cs_ptr_array, \"aw\"\n\t"                  \
-               RSEQ_ASM_U64_PTR(__rseq_str(label) "b") "\n\t"                  \
-               ".popsection\n\t"
-
-/*
- * Define an rseq critical section structure of version 0 with no flags.
- *
- *  @label:
- *    Local label for the beginning of the critical section descriptor
- *    structure.
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @post_commit_ip:
- *    Pointer to the instruction after the last instruction of the sequence of
- *    consecutive assembly instructions.
- *  @abort_ip:
- *    Pointer to the instruction where to move the execution flow in case of
- *    abort of the sequence of consecutive assembly instructions.
- */
-#define RSEQ_ASM_DEFINE_TABLE(label, start_ip, post_commit_ip, abort_ip) \
-       __RSEQ_ASM_DEFINE_TABLE(label, 0x0, 0x0, start_ip,              \
-                               (post_commit_ip) - (start_ip), abort_ip)
-
-/*
- * Define the @exit_ip pointer as an exit point for the sequence of consecutive
- * assembly instructions at @start_ip.
- *
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @exit_ip:
- *    Pointer to an exit point instruction.
- *
- * Exit points of a rseq critical section consist of all instructions outside
- * of the critical section where a critical section can either branch to or
- * reach through the normal course of its execution. The abort IP and the
- * post-commit IP are already part of the __rseq_cs section and should not be
- * explicitly defined as additional exit points. Knowing all exit points is
- * useful to assist debuggers stepping over the critical section.
- */
-#define RSEQ_ASM_DEFINE_EXIT_POINT(start_ip, exit_ip)                  \
-               ".pushsection __rseq_exit_point_array, \"aw\"\n\t"      \
-               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
-               RSEQ_ASM_U64_PTR(__rseq_str(exit_ip)) "\n\t"            \
-               ".popsection\n\t"
+/* Common architecture support macros. */
+#include "rseq/arch/generic/common.h"
 
 /*
  * Define a critical section abort handler.
index 1385dc4f18e6c2e1d69c70928d095ed95695efb3..8b61cf9ee38a5454da4f289f8c761ce298dab9b0 100644 (file)
@@ -90,91 +90,8 @@ do {                                                                 \
 
 #define RSEQ_ASM_U32(x)                        ".long " x
 
-/*
- * Store the address of the critical section descriptor structure at
- * @cs_label into the @rseq_cs pointer and emit the label @label, which
- * is the beginning of the sequence of consecutive assembly instructions.
- *
- *  @label:
- *    Local label to the beginning of the sequence of consecutive assembly
- *    instructions.
- *  @cs_label:
- *    Source local label to the critical section descriptor structure.
- *  @rseq_cs:
- *    Destination pointer where to store the address of the critical
- *    section descriptor structure.
- */
-#ifdef RSEQ_ARCH_AMD64
-#define RSEQ_ASM_STORE_RSEQ_CS(label, cs_label, rseq_cs)               \
-               RSEQ_INJECT_ASM(1)                                      \
-               "leaq " __rseq_str(cs_label) "(%%rip), %%rax\n\t"       \
-               "movq %%rax, " __rseq_str(rseq_cs) "\n\t"               \
-               __rseq_str(label) ":\n\t"
-#else
-# define RSEQ_ASM_STORE_RSEQ_CS(label, cs_label, rseq_cs)              \
-               RSEQ_INJECT_ASM(1)                                      \
-               "movl $" __rseq_str(cs_label) ", " __rseq_str(rseq_cs) "\n\t"   \
-               __rseq_str(label) ":\n\t"
-#endif
-
-/* Only used in RSEQ_ASM_DEFINE_TABLE. */
-#define __RSEQ_ASM_DEFINE_TABLE(label, version, flags,                 \
-                               start_ip, post_commit_offset, abort_ip) \
-               ".pushsection __rseq_cs, \"aw\"\n\t"                    \
-               ".balign 32\n\t"                                        \
-               __rseq_str(label) ":\n\t"                               \
-               RSEQ_ASM_U32(__rseq_str(version)) "\n\t"                \
-               RSEQ_ASM_U32(__rseq_str(flags)) "\n\t"                  \
-               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
-               RSEQ_ASM_U64_PTR(__rseq_str(post_commit_offset)) "\n\t" \
-               RSEQ_ASM_U64_PTR(__rseq_str(abort_ip)) "\n\t"           \
-               ".popsection\n\t"                                       \
-               ".pushsection __rseq_cs_ptr_array, \"aw\"\n\t"          \
-               RSEQ_ASM_U64_PTR(__rseq_str(label) "b") "\n\t"          \
-               ".popsection\n\t"
-
-/*
- * Define an rseq critical section structure of version 0 with no flags.
- *
- *  @label:
- *    Local label for the beginning of the critical section descriptor
- *    structure.
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @post_commit_ip:
- *    Pointer to the instruction after the last instruction of the sequence of
- *    consecutive assembly instructions.
- *  @abort_ip:
- *    Pointer to the instruction where to move the execution flow in case of
- *    abort of the sequence of consecutive assembly instructions.
- */
-#define RSEQ_ASM_DEFINE_TABLE(label, start_ip, post_commit_ip, abort_ip) \
-       __RSEQ_ASM_DEFINE_TABLE(label, 0x0, 0x0, start_ip,              \
-                               (post_commit_ip) - (start_ip), abort_ip)
-
-/*
- * Define the @exit_ip pointer as an exit point for the sequence of consecutive
- * assembly instructions at @start_ip.
- *
- *  @start_ip:
- *    Pointer to the first instruction of the sequence of consecutive assembly
- *    instructions.
- *  @exit_ip:
- *    Pointer to an exit point instruction.
- *
- * Exit points of a rseq critical section consist of all instructions outside
- * of the critical section where a critical section can either branch to or
- * reach through the normal course of its execution. The abort IP and the
- * post-commit IP are already part of the __rseq_cs section and should not be
- * explicitly defined as additional exit points. Knowing all exit points is
- * useful to assist debuggers stepping over the critical section.
- */
-#define RSEQ_ASM_DEFINE_EXIT_POINT(start_ip, exit_ip)                  \
-               ".pushsection __rseq_exit_point_array, \"aw\"\n\t"      \
-               RSEQ_ASM_U64_PTR(__rseq_str(start_ip)) "\n\t"           \
-               RSEQ_ASM_U64_PTR(__rseq_str(exit_ip)) "\n\t"            \
-               ".popsection\n\t"
+/* Common architecture support macros. */
+#include "rseq/arch/generic/common.h"
 
 /*
  * Define a critical section abort handler.
@@ -217,6 +134,33 @@ do {                                                                       \
                "jmp %l[" __rseq_str(target_label) "]\n\t"              \
                ".popsection\n\t"
 
+/*
+ * Store the address of the critical section descriptor structure at
+ * @cs_label into the @rseq_cs pointer and emit the label @label, which
+ * is the beginning of the sequence of consecutive assembly instructions.
+ *
+ *  @label:
+ *    Local label to the beginning of the sequence of consecutive assembly
+ *    instructions.
+ *  @cs_label:
+ *    Source local label to the critical section descriptor structure.
+ *  @rseq_cs:
+ *    Destination pointer where to store the address of the critical
+ *    section descriptor structure.
+ */
+#ifdef RSEQ_ARCH_AMD64
+#define RSEQ_ASM_STORE_RSEQ_CS(label, cs_label, rseq_cs)               \
+               RSEQ_INJECT_ASM(1)                                      \
+               "leaq " __rseq_str(cs_label) "(%%rip), %%rax\n\t"       \
+               "movq %%rax, " __rseq_str(rseq_cs) "\n\t"               \
+               __rseq_str(label) ":\n\t"
+#else
+# define RSEQ_ASM_STORE_RSEQ_CS(label, cs_label, rseq_cs)              \
+               RSEQ_INJECT_ASM(1)                                      \
+               "movl $" __rseq_str(cs_label) ", " __rseq_str(rseq_cs) "\n\t"   \
+               __rseq_str(label) ":\n\t"
+#endif
+
 /* Jump to local label @label when @cpu_id != @current_cpu_id. */
 #define RSEQ_ASM_CBNE_CPU_ID(cpu_id, current_cpu_id, label)            \
                RSEQ_INJECT_ASM(2)                                      \
This page took 0.042918 seconds and 4 git commands to generate.