Skip to content

Commit

Permalink
Rename LIBIA2_DEBUG* defines to IA2_DEBUG*
Browse files Browse the repository at this point in the history
  • Loading branch information
rinon committed Oct 9, 2024
1 parent d944ffe commit 967bbd6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
-DClang_DIR=$Clang_DIR \
-DLLVM_DIR=$LLVM_DIR \
-DLLVM_EXTERNAL_LIT=$HOME/.local/bin/lit \
-DLIBIA2_DEBUG=${{ matrix.ia2-debug }} \
-DIA2_DEBUG=${{ matrix.ia2-debug }} \
-DIA2_TRACER=${{ matrix.ia2-tracer }} \
-G Ninja
ninja
Expand Down
6 changes: 3 additions & 3 deletions cmake/ia2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ function(add_ia2_call_gates NAME)

add_library(${CALL_GATE_TARGET} SHARED ${CALL_GATE_SRC})
add_dependencies(${CALL_GATE_TARGET} ${NAME}-rewrite)
# This is needed to enable LIBIA2_DEBUG=1
# This is needed to enable IA2_DEBUG=1
target_compile_definitions(${CALL_GATE_TARGET} PRIVATE IA2_ENABLE=1)
if(LIBIA2_DEBUG)
target_compile_definitions(${CALL_GATE_TARGET} PRIVATE LIBIA2_DEBUG=1 IA2_ENABLE=1)
if(IA2_DEBUG)
target_compile_definitions(${CALL_GATE_TARGET} PRIVATE IA2_DEBUG=1 IA2_ENABLE=1)
endif()
target_compile_definitions(${CALL_GATE_TARGET} PRIVATE _GNU_SOURCE)
target_link_libraries(${CALL_GATE_TARGET} PUBLIC libia2)
Expand Down
2 changes: 1 addition & 1 deletion docs/build_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ cmake .. \

### Notable CMake variables

- `LIBIA2_DEBUG` - Adds additional runtime assertions to validate control-flow.
- `IA2_DEBUG` - Adds additional runtime assertions to validate control-flow.
- `LIBIA2_AARCH64` - Builds the runtime and tests for AArch64 using MTE instead of x86-64 with MPK. Tools are still built for the host.
- `CMAKE_TOOLCHAIN_FILE` - Typically set to [`cmake/aarch64-toolchain.cmake`](../cmake/aarch64-toolchain.cmake) to build for AArch64 using GCC. This also sets `LIBIA2_AARCH64`.
- `IA2_TRACER` - Can be used to unconditionally disable the syscall tracer for all tests. Individual tests can opt-out of syscall tracing by specifying `WITHOUT_SANDBOX` in `define_test`.
Expand Down
4 changes: 2 additions & 2 deletions external/nginx/auto/make
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ IA2_CFLAGS = \\
-DPKEY=1 \\
-DIA2_ENABLE=\$(IA2_ENABLE) \\
-DLIBIA2_X86_64=1 \\
-DLIBIA2_DEBUG=1 \\
-DIA2_DEBUG=1 \\
-I \$(C_SYSTEM_INCLUDE) \\
-I \$(C_SYSTEM_INCLUDE_FIXED) \\
-Wno-error \\
Expand Down Expand Up @@ -93,7 +93,7 @@ IA2_MODULE_CFLAGS = \\
-DPKEY=2 \\
-DIA2_ENABLE=\$(IA2_ENABLE) \\
-DLIBIA2_X86_64=1 \\
-DLIBIA2_DEBUG=1 \\
-DIA2_DEBUG=1 \\
-I \$(C_SYSTEM_INCLUDE) \\
-I \$(C_SYSTEM_INCLUDE_FIXED) \\
-Wno-error \\
Expand Down
8 changes: 4 additions & 4 deletions runtime/libia2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ if (LIBIA2_AARCH64)
else()
endif()

if(LIBIA2_DEBUG)
target_compile_definitions(libia2 PUBLIC LIBIA2_DEBUG=1)
if(IA2_DEBUG)
target_compile_definitions(libia2 PUBLIC IA2_DEBUG=1)
endif()

if(LIBIA2_DEBUG_LOG)
target_compile_definitions(libia2 PRIVATE LIBIA2_DEBUG_LOG=1)
if(IA2_DEBUG_LOG)
target_compile_definitions(libia2 PRIVATE IA2_DEBUG_LOG=1)
endif()

target_link_options(libia2
Expand Down
10 changes: 5 additions & 5 deletions runtime/libia2/ia2.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ int protect_pages(struct dl_phdr_info *info, size_t size, void *data) {
search_args->found_library_count++;
}

#if LIBIA2_DEBUG_LOG
#if IA2_DEBUG_LOG
printf("protecting library: %s\n", basename(info->dlpi_name));
#endif

Expand Down Expand Up @@ -381,7 +381,7 @@ int protect_pages(struct dl_phdr_info *info, size_t size, void *data) {
search_args->shared_sections[i].end);
exit(-1);
}
#if LIBIA2_DEBUG_LOG
#if IA2_DEBUG_LOG
printf("Shared range %zu: 0x%" PRIx64 "-0x%" PRIx64 "\n", shared_range_count, cur_range->start, cur_range->end);
#endif

Expand Down Expand Up @@ -435,7 +435,7 @@ int protect_pages(struct dl_phdr_info *info, size_t size, void *data) {

Elf64_Addr start = (info->dlpi_addr + phdr.p_vaddr) & ~0xFFFUL;
Elf64_Addr seg_end = (info->dlpi_addr + phdr.p_vaddr + phdr.p_memsz + 0xFFFUL) & ~0xFFFUL;
#if LIBIA2_DEBUG_LOG
#if IA2_DEBUG_LOG
printf("Segment %zu: 0x%" PRIx64 "-0x%" PRIx64 "\n", i, start, seg_end);
#endif
while (start < seg_end) {
Expand All @@ -448,7 +448,7 @@ int protect_pages(struct dl_phdr_info *info, size_t size, void *data) {
// and remove the overlapping portion.
if (shared_ranges[j].start <= start && shared_ranges[j].end > start) {
start = shared_ranges[j].end;
#if LIBIA2_DEBUG_LOG
#if IA2_DEBUG_LOG
printf("Shared range %zu overlaps start of segment %zu, adjusting start to 0x%" PRIx64 "\n", j, i, start);
#endif
}
Expand All @@ -459,7 +459,7 @@ int protect_pages(struct dl_phdr_info *info, size_t size, void *data) {
if (shared_ranges[j].start > start &&
shared_ranges[j].start < cur_end) {
cur_end = shared_ranges[j].start;
#if LIBIA2_DEBUG_LOG
#if IA2_DEBUG_LOG
printf("Shared range %zu overlaps end of segment %zu, adjusting end to 0x%" PRIx64 "\n", j, i, cur_end);
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/libia2/include/ia2.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
/// value
///
/// `pkru` should be the register value, not the compartment pkey.
#ifndef LIBIA2_DEBUG
#ifndef IA2_DEBUG
#define ASSERT_PKRU(pkru)
#else
/* clang-format off */
Expand Down
2 changes: 1 addition & 1 deletion runtime/libia2/include/ia2_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ works as a reasonable signpost no-op. */
#if defined(__aarch64__)
int ia2_mprotect_with_tag(void *addr, size_t len, int prot, int tag);
#elif defined(__x86_64__)
#if LIBIA2_DEBUG_LOG
#if IA2_DEBUG_LOG
static int ia2_mprotect_with_tag(void *addr, size_t len, int prot, int tag) {
printf("ia2_mprotect_with_tag(addr=%p, len=%zu, prot=%d, tag=%d)\n", addr, len, prot, tag);
return pkey_mprotect(addr, len, prot, tag);
Expand Down

0 comments on commit 967bbd6

Please sign in to comment.