Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
aff3ac4
Re-enable the dynamorio kernel module
bin-wang Jun 1, 2026
e0a8e73
Fix issues in globals_api.h
bin-wang Jun 1, 2026
e0b20ac
Fix includes in globals_shared.h
bin-wang Jun 1, 2026
8cae6ff
Define DYNAMORIO_INTERNAL when building drk
bin-wang Jun 1, 2026
2a84c2d
Fix includes in globals.h
bin-wang Jun 1, 2026
d75c2c3
Add explicit void to function prototypes
bin-wang Jun 2, 2026
9aff966
Remove redundant function type cast
bin-wang Jun 2, 2026
d29bfeb
Use basename instead of absolute path in comment
bin-wang Jun 2, 2026
4473616
Build DynamoRIO in drk CI to generate `event_strings.h`
bin-wang Jun 2, 2026
05f006c
Add explicit void to function prototypes
bin-wang Jun 2, 2026
4204aa4
Remove unnecessary LINUX_KERNEL definition in exports.py
bin-wang Jun 2, 2026
2247702
Fix includes in drlibc.h for kernel builds
bin-wang Jun 2, 2026
39cda65
Add explicit void to function prototypes
bin-wang Jun 2, 2026
65a22e3
Add explicit void to function prototypes
bin-wang Jun 2, 2026
2c6025a
Pull in definition of tls_offset_t from drk
bin-wang Jun 2, 2026
c1e97b3
Build drk before downloading kernel source
bin-wang Jun 2, 2026
e6eac86
Re-format code with clang-format
bin-wang Jun 2, 2026
36db807
Pull in definitions of `interrupt_vector_t` and `interrupt_handler_t`
bin-wang Jun 2, 2026
9c375cd
Avoid __DATE__ and __TIME__ in kernel builds
bin-wang Jun 2, 2026
d18f040
Exclude os_cxt from client_data_t in kernel builds
bin-wang Jun 2, 2026
3a31fcd
Use wrapper for stdarg.h and stddef.h
bin-wang Jun 2, 2026
e603f87
Exclude dr_stat_syscall from kernel builds
bin-wang Jun 2, 2026
40600e4
Provide definition for wchar_t in kernel builds
bin-wang Jun 3, 2026
77fce8c
Pull in changes from drk
bin-wang Jun 3, 2026
a031e5d
Add explicit void to function prototypes
bin-wang Jun 3, 2026
145d5b1
Use relative path of stddef_wrapper.h in arch.h
bin-wang Jun 3, 2026
e158c35
Use limits_wrapper.h in heap.c
bin-wang Jun 3, 2026
77624d0
Use wrapper headers in fcache.c and fragment.c
bin-wang Jun 3, 2026
d46c9f0
Add explicit void to function definitions in C files
bin-wang Jun 3, 2026
5b07277
Do not define MAX/MIN in DR when building the kernel modules
bin-wang Jun 3, 2026
da9e357
Do not define printf and others in kernel builds
bin-wang Jun 3, 2026
8e394d2
Do not include <limits.h> in kernel builds
bin-wang Jun 3, 2026
32701fc
Fix windows CI
bin-wang Jun 3, 2026
77bd296
Fix windows CI
bin-wang Jun 3, 2026
eaf840e
Fix windows CI
bin-wang Jun 3, 2026
c42a1d1
Add explicit void to function prototypes
bin-wang Jun 3, 2026
301bc87
Do not include <math.h> for kernel builds
bin-wang Jun 3, 2026
45b5d42
Change NOINLINE definition to using the double-underscore variant
bin-wang Jun 4, 2026
16a355b
Exclude instrument_kernel_xfer from kernel builds
bin-wang Jun 4, 2026
2998cef
Use limits_wrapper.h instead of limits.h
bin-wang Jun 4, 2026
706585a
Add explicit void to function prototypes
bin-wang Jun 4, 2026
675df41
Exclude rseq function calls in fragment.c from kernel builds
bin-wang Jun 4, 2026
a1e8198
Skip os_page_size_init in drk
bin-wang Jun 5, 2026
1dc69d1
Fix format mismatch
bin-wang Jun 5, 2026
4a6c23e
Change NOINLINE definition to using the double-underscore variant
bin-wang Jun 5, 2026
fdf658f
Exclude rseq function call in dispatch.c from kernel builds
bin-wang Jun 5, 2026
356f5fe
Exclude dead code in dispatch.c for kernel builds
bin-wang Jun 5, 2026
e496141
Exclude dead code in dispatch.c from kernel builds
bin-wang Jun 5, 2026
3a40641
Exclude os_handle_mov_seg from kernel builds
bin-wang Jun 6, 2026
21791b9
Port changes from drk branch
bin-wang Jun 6, 2026
4063184
Exclude dead code from kernel builds
bin-wang Jun 7, 2026
d611d8d
Remove unused ignorable_system_call function
bin-wang Jun 7, 2026
7ca7c4c
Early return bb_process_syscall in kernel mode
bin-wang Jun 7, 2026
aab3899
Exclude dead code from kernel builds
bin-wang Jun 7, 2026
21734d3
Reformat code with clang-format
bin-wang Jun 7, 2026
ab63f13
Fix path of instrlist.o
bin-wang Jun 7, 2026
9cd519b
Use kernel compatible wrapper headers
bin-wang Jun 7, 2026
b10acb7
Update mutex lock/unlock function names
bin-wang Jun 7, 2026
f92d99f
Fix headers
bin-wang Jun 8, 2026
3d0326d
Use wrapper header for limits.h in iox.h
bin-wang Jun 8, 2026
3fbf118
Add explicit void to kstat_calibrate in stats.c
bin-wang Jun 8, 2026
671c271
Skip send_nudge_signal in kernel builds
bin-wang Jun 8, 2026
807826e
Add explicit void to vm_areas_statistics()
bin-wang Jun 8, 2026
ac0235a
Mark intentional fall-throughs with DR_FALLTHROUGH
bin-wang Jun 8, 2026
056e7f1
Merge remote-tracking branch drk-v2 into drk-v2-dynamorio
bin-wang Jun 8, 2026
9da53bf
Reformat code with clang-format
bin-wang Jun 8, 2026
21c4f72
Add explicit void to function prototypes
bin-wang Jun 8, 2026
a4c9c57
Exclude double related print functions from kernel builds
bin-wang Jun 8, 2026
0315ffa
Remove unit-rct.o from dynamorio-objs
bin-wang Jun 8, 2026
3463ac7
Add stub for os_wait_thread_terminated
bin-wang Jun 11, 2026
dc0979a
Fix headers in utils.c
bin-wang Jun 11, 2026
c39830a
Update utils.c
bin-wang Jun 11, 2026
c1fd0ed
Exclude signal_remove_alarm_handlers from kernel builds
bin-wang Jun 11, 2026
a9bf07b
Allocate badopt/wordbuffer on the heap in kernel build
bin-wang Jun 11, 2026
dd28ac6
Allocate badopt/wordbuffer as static in kernel build
bin-wang Jun 11, 2026
e853429
Exclude rseq related code in kernel build
bin-wang Jun 11, 2026
6cbe98a
Prefix atomic functions with d_r_ to avoid naming conflicts
bin-wang Jun 11, 2026
305a9c1
Exclude old_basedir in kernel build
bin-wang Jun 11, 2026
b20b78a
Exclude os_signal_thread_detach/os_wait_thread_detached
bin-wang Jun 11, 2026
63b5e84
Update dynamorio.o object paths to match current DynamoRIO layout
bin-wang Jun 12, 2026
82afa34
Remove hypercall related headers
bin-wang Jun 14, 2026
ea0213c
Add explicit void to function prototypes
bin-wang Jun 14, 2026
a144310
Add d_r_ prefix to mutex functions
bin-wang Jun 14, 2026
4b5eeb9
Update function signatures in core/kernel_linux/os.c
bin-wang Jun 14, 2026
08bc42f
Rename fallthrough variable in interp.c to avoid kernel macro collision
bin-wang Jun 14, 2026
0cb76cc
Reformat code with clang-format
bin-wang Jun 14, 2026
008bb41
Mark intentional fall throughs with the DR_FALLTHROUGH macro
bin-wang Jun 15, 2026
ceaa037
Resolve -Wundef
bin-wang Jun 15, 2026
aefac1d
Reformat DR_FALLTHROUGH
bin-wang Jun 15, 2026
7447581
Remvoe hypercall related code in kernel_interface.c
bin-wang Jun 15, 2026
9d0ba07
Fix headers for kernel build
bin-wang Jun 15, 2026
3305ff4
Add DR_PARAM_ prefix to IN/OUT/INOUT
bin-wang Jun 15, 2026
b5207a6
Fix include path in instrument.c
bin-wang Jun 22, 2026
20188d1
Exclude user space headers in kernel build
bin-wang Jun 22, 2026
485abf7
Add explicit void
bin-wang Jun 22, 2026
7c1f192
Add explicit conversion
bin-wang Jun 22, 2026
7954136
Handle -Werror=return-type in get_interrupted_location()
bin-wang Jun 22, 2026
2e85ff8
Rename INTN_LENGTH to INT_LENGTH
bin-wang Jun 22, 2026
7d0cdf6
Rename fallthrough to avoid naming conflict with the kernel
bin-wang Jun 22, 2026
b033841
Remove redundant NULL arguments
bin-wang Jun 22, 2026
502afad
Remove CLIENT_INTERFACE define
bin-wang Jun 22, 2026
51c3794
Reformat code
bin-wang Jun 22, 2026
94fa0ef
Added vsyscall_sysenter_displaced_pc in drk
bin-wang Jun 22, 2026
c0e578b
Update signature for set_itimer_callback in drk
bin-wang Jun 22, 2026
c96d8b4
Exclude os_module_update_dynamic_info from kernel build
bin-wang Jun 22, 2026
e3edeca
Exclude rseq related code from kernel build
bin-wang Jun 22, 2026
bf94201
Exclude PLT interception logic from kernel build
bin-wang Jun 22, 2026
f1ffb91
Exclude is_currently_on_sigaltstack from kernel build
bin-wang Jun 23, 2026
b892c98
Fix bb_process_syscall kernel build error
bin-wang Jun 23, 2026
1a7da57
Exclude unused functions from kernel build
bin-wang Jun 23, 2026
da3cef7
Exclude os_dump_core_live from kernel build
bin-wang Jun 23, 2026
79ac0c3
Return early in dr_insert_get_seg_base for kernel build
bin-wang Jun 23, 2026
3736342
Exclude os_cxt related code in kernel build
bin-wang Jun 23, 2026
4f4c4ca
Add missing definition and stubs
bin-wang Jun 23, 2026
b86e895
Reformat
bin-wang Jun 23, 2026
3b94119
Update WHERE_FCACHE to new name DR_WHERE_FCACHE
bin-wang Jun 23, 2026
2b2e978
Update function signatures
bin-wang Jun 23, 2026
e44597a
Add missing declaration for optimize_sys_call_ret
bin-wang Jun 23, 2026
dcad856
Copy KSTAT definitions from drk branch
bin-wang Jun 23, 2026
3716aa8
Reformat
bin-wang Jun 23, 2026
6ce94e7
Reformat
bin-wang Jun 23, 2026
17ba8b5
Copy next_app_tag in dcontext_t from drk branch
bin-wang Jun 23, 2026
39cf637
Add const to function parameter type
bin-wang Jun 23, 2026
5598331
Update function signatures and usages
bin-wang Jun 23, 2026
4deb956
dr_mcontext_t -> priv_mcontext_t
bin-wang Jun 23, 2026
a7a57ec
Port in definitions of EFLAGS_IF and EFLAGS_SYSTEM
bin-wang Jun 24, 2026
ab73cd4
Correct usage of recreate_app_state()
bin-wang Jun 24, 2026
52ff37c
Reformat
bin-wang Jun 24, 2026
91c1c4c
Port in variants of enum recreate_success_t from drk branch
bin-wang Jun 24, 2026
897c907
Implement os_random_seed() in core/kernel_linux/os.c
bin-wang Jun 24, 2026
4f1f367
Port in optimize_syscall_code from drk branch
bin-wang Jun 24, 2026
7b58f5f
Fix in_fcache_enter/in_fcache_return
bin-wang Jun 24, 2026
b169346
Port syscall and interrupt entry handlers from drk
bin-wang Jun 26, 2026
7adfa2d
Reformat
bin-wang Jun 26, 2026
81c266f
Add missing include
bin-wang Jun 29, 2026
e79dedd
Port was_kernel_interrupted from drk branch
bin-wang Jun 29, 2026
f2e04ba
Fix typo
bin-wang Jun 29, 2026
dcea2cb
Port patch_interrupt/unpatch_interrupt from drk branch
bin-wang Jun 29, 2026
c8a88ac
Port ibl related definitions and function from drk
bin-wang Jun 29, 2026
d21462e
Replace deprecated functions
bin-wang Jun 29, 2026
3ac398a
Reformat
bin-wang Jun 29, 2026
ca84a26
Port dr_interrupt_t and related API declarations from drk
bin-wang Jun 29, 2026
59e029c
Add signature of instrument_interrupt
bin-wang Jun 30, 2026
1d2fdd5
Add function definitions
bin-wang Jun 30, 2026
58e1da3
Port clean_call_clear_saved_interrupt_flag from drk
bin-wang Jun 30, 2026
45d64a2
Handle conversion between priv_mcontext_t and dr_mcontext_t
bin-wang Jun 30, 2026
4d55d11
Define INSTR_INLINE as static inline in kernel build
bin-wang Jun 30, 2026
04d14fd
Fix symbol export handling in kernel builds
bin-wang Jun 30, 2026
250e5e2
Port signature declaration for os_warm_fcache from drk
bin-wang Jun 30, 2026
01b4922
Port definitions for dr_smp_init/dr_smp_exit from drk
bin-wang Jun 30, 2026
b62c66d
Exclude unported functions from being exported
bin-wang Jun 30, 2026
d6ea492
Reformat
bin-wang Jun 30, 2026
6db62c8
Fix clang-format bug in CI
bin-wang Jun 30, 2026
cc06259
Restrict ibl related procedures to kernel only
bin-wang Jun 30, 2026
062b3e2
Add missing .o files to drk Makefile
bin-wang Jul 6, 2026
28cee99
Exclude irrelevant code from kernel build
bin-wang Jul 6, 2026
159f4e4
Handle float/double disassembly in kernel build
bin-wang Jul 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/ci-drk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ jobs:
sudo apt install -y doxygen vera++ libelf-dev scons cmake g++-multilib
echo "MAKE_CMD=make -j$(nproc)" >> $GITHUB_ENV

- name: Generate DynamoRIO headers via CMake
run: |
mkdir -p build
cd build
cmake ..
$MAKE_CMD

- name: Download and extract kernel source
run: |
VERSION="6.6.130"
Expand All @@ -30,12 +37,6 @@ jobs:
make defconfig
$MAKE_CMD modules_prepare

- name: Generate DynamoRIO headers via CMake
run: |
mkdir -p build
cd build
cmake ..

- name: Build drk
# TODO i#10: Convert to cmake.
run: cd core && $MAKE_CMD -f drk.mk KERNELDIR=$GITHUB_WORKSPACE/$KERNEL_DIR
4 changes: 2 additions & 2 deletions core/annotations.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ free_annotation_handler(void *p);
*/

void
annotation_init()
annotation_init(void)
{
handlers = strhash_hash_create(
GLOBAL_DCONTEXT, 8, 80, /* favor a small table */
Expand Down Expand Up @@ -302,7 +302,7 @@ annotation_init()
}

void
annotation_exit()
annotation_exit(void)
{
# if !(defined(WINDOWS) && defined(X64))
uint i;
Expand Down
4 changes: 2 additions & 2 deletions core/annotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ typedef struct _dr_annotation_handler_t {
} dr_annotation_handler_t;

void
annotation_init();
annotation_init(void);

void
annotation_exit();
annotation_exit(void);

static inline bool
is_annotation_label(instr_t *instr)
Expand Down
186 changes: 177 additions & 9 deletions core/arch/arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ shared_gencode_emit(generated_code_t *gencode _IF_X86_64(bool x86_mode))
pc = check_size_and_cache_line(isa_mode, gencode, pc);
gencode->fcache_enter = pc;
pc = emit_fcache_enter_shared(GLOBAL_DCONTEXT, gencode, pc);
gencode->fcache_enter_end = pc;
pc = check_size_and_cache_line(isa_mode, gencode, pc);
gencode->fcache_return = pc;
pc = emit_fcache_return_shared(GLOBAL_DCONTEXT, gencode, pc);
Expand Down Expand Up @@ -989,15 +990,40 @@ emit_ibl_routine_and_template(dcontext_t *dcontext, generated_code_t *code, byte
ibl_code->thread_shared_routine = thread_shared;
ibl_code->branch_type = branch_type;
ibl_code->source_fragment_type = source_type;
#ifdef LINUX_KERNEL
ibl_code->num_ibl_found_exits = 0;
#endif

pc = emit_indirect_branch_lookup(dcontext, code, pc, fcache_return_pc,
target_trace_table, inline_ibl_head, ibl_code);
#ifdef LINUX_KERNEL
ibl_code->indirect_branch_lookup_routine_end = pc;
#endif
if (inline_ibl_head) {
/* create the inlined ibl template */
pc = check_size_and_cache_line(isa_mode, code, pc);
pc = emit_inline_ibl_stub(dcontext, pc, ibl_code, target_trace_table);
}

#ifdef LINUX_KERNEL
pc = check_size_and_cache_line(isa_mode, code, pc);
ibl_code->found_unlinked = pc;
pc = emit_ibl_found_unlinked_code(dcontext, pc, fcache_return_pc, ibl_code, false,
false);
pc = check_size_and_cache_line(isa_mode, code, pc);
ibl_code->found_unlinked_prefix = pc;
pc = emit_ibl_found_unlinked_code(dcontext, pc, fcache_return_pc, ibl_code, false,
true);
pc = check_size_and_cache_line(isa_mode, code, pc);
ibl_code->found_unlinked_eflags = pc;
pc = emit_ibl_found_unlinked_code(dcontext, pc, fcache_return_pc, ibl_code, true,
false);
pc = check_size_and_cache_line(isa_mode, code, pc);
ibl_code->found_unlinked_eflags_prefix = pc;
pc = emit_ibl_found_unlinked_code(dcontext, pc, fcache_return_pc, ibl_code, true,
true);
#endif

ibl_code->far_ibl = pc;
pc = emit_far_ibl(
dcontext, pc, ibl_code,
Expand Down Expand Up @@ -1148,6 +1174,25 @@ emit_syscall_routines(dcontext_t *dcontext, generated_code_t *code, byte *pc,
code->do_syscall = pc;
pc = emit_do_syscall(dcontext, code, pc, code->fcache_return, thread_shared, 0,
&code->do_syscall_offs);
#elif defined(LINUX_KERNEL)
ASSERT(thread_shared);
pc = check_size_and_cache_line(isa_mode, code, pc);
code->syscall_entry = pc;
pc = emit_syscall_entry(dcontext, code->fcache_return,
os_get_native_syscall_entry(dcontext), pc);
pc = check_size_and_cache_line(isa_mode, code, pc);
code->common_vector_entry = pc;
pc = emit_common_vector_entry(dcontext, os_get_tls_base(dcontext),
os_get_interrupt_handler(0), pc);
pc = check_size_and_cache_line(isa_mode, code, pc);
for (int vector = VECTOR_START; vector < VECTOR_END; vector++) {
/* Pack as many as we can on a cache line. */
if (CROSSES_ALIGNMENT(pc, VECTOR_ENTRY_CODE_SIZE, proc_get_cache_line_size())) {
pc = check_size_and_cache_line(isa_mode, code, pc);
}
code->vector_entry[vector - VECTOR_START] = pc;
pc = emit_vector_entry(dcontext, code->common_vector_entry, vector, pc);
}
#else /* UNIX */
pc = check_size_and_cache_line(isa_mode, code, pc);
code->do_syscall = pc;
Expand Down Expand Up @@ -1180,6 +1225,19 @@ emit_syscall_routines(dcontext_t *dcontext, generated_code_t *code, byte *pc,
return pc;
}

#ifdef LINUX_KERNEL
void
optimize_syscall_code(dcontext_t *dcontext, fragment_t *f)
{
generated_code_t *code = THREAD_GENCODE(dcontext);
byte *pc = code->syscall_entry;
/* Assert pc points to swapgs. */
ASSERT(pc[0] == 0x0f && pc[1] == 0x01 && pc[2] == 0xf8);
pc += 3;
insert_relative_jump(pc, f->start_pc, false);
}
#endif

void
arch_thread_init(dcontext_t *dcontext)
{
Expand Down Expand Up @@ -1285,6 +1343,7 @@ arch_thread_init(dcontext_t *dcontext)
pc = check_size_and_cache_line(isa_mode, code, pc);
code->fcache_enter = pc;
pc = emit_fcache_enter(dcontext, code, pc);
code->fcache_enter_end = pc;
pc = check_size_and_cache_line(isa_mode, code, pc);
code->fcache_return = pc;
pc = emit_fcache_return(dcontext, code, pc);
Expand Down Expand Up @@ -1783,6 +1842,32 @@ in_generated_routine(dcontext_t *dcontext, cache_pc pc)
/* XXX: what about inlined IBL stubs */
}

static bool
in_fcache_enter_for_gencode(generated_code_t *code, cache_pc pc)
{
return pc != NULL && pc >= code->fcache_enter && pc < code->fcache_enter_end;
}

bool
in_fcache_enter(dcontext_t *dcontext, cache_pc pc)
{
generated_code_t *code = THREAD_GENCODE(dcontext);
if (in_fcache_enter_for_gencode(code, pc))
return true;
if (USE_SHARED_GENCODE()) {
if (in_fcache_enter_for_gencode(shared_code, pc))
return true;
#if defined(X86) && defined(X64)
if (shared_code_x86 != NULL && in_fcache_enter_for_gencode(shared_code_x86, pc))
return true;
if (shared_code_x86_to_x64 != NULL &&
in_fcache_enter_for_gencode(shared_code_x86_to_x64, pc))
return true;
#endif
}
return false;
}

static bool
in_fcache_return_for_gencode(generated_code_t *code, cache_pc pc)
{
Expand Down Expand Up @@ -1978,6 +2063,52 @@ get_do_vmkuw_syscall_entry(dcontext_t *dcontext)
# endif
#endif

#ifdef LINUX_KERNEL
cache_pc
get_syscall_entry(dcontext_t *dcontext)
{
generated_code_t *code = THREAD_GENCODE(dcontext);
return (cache_pc)code->syscall_entry;
}

cache_pc
get_vector_entry(dcontext_t *dcontext, interrupt_vector_t vector)
{
generated_code_t *code = THREAD_GENCODE(dcontext);
ASSERT(vector >= VECTOR_START && vector < VECTOR_END);
return (cache_pc)code->vector_entry[vector - VECTOR_START];
}

bool
vector_has_error_code(interrupt_vector_t vector)
{
ASSERT(vector >= VECTOR_START && vector < VECTOR_END);
switch (vector) {
case VECTOR_DOUBLE_FAULT:
case VECTOR_INVALID_TSS:
case VECTOR_SEGMENT_NOT_PRESENT:
case VECTOR_STACK_FAULT:
case VECTOR_GENERAL_PROTECTION:
case VECTOR_PAGE_FAULT:
case VECTOR_ALIGNMENT_CHECK: return true;
default: return false;
}
}

bool
vector_is_synchronous(interrupt_vector_t vector)
{
ASSERT(vector >= VECTOR_START && vector < VECTOR_END);
return vector >= VECTOR_EXCEPTION_START && vector < VECTOR_EXCEPTION_END;
}

bool
was_kernel_interrupted(interrupt_stack_frame_t *frame)
{
return (frame->cs & 3) == 0;
}
#endif

cache_pc
fcache_return_routine(dcontext_t *dcontext)
{
Expand Down Expand Up @@ -2540,6 +2671,39 @@ get_ibl_routine_code(dcontext_t *dcontext, ibl_branch_type_t branch_type,
: GENCODE_FROM_DCONTEXT));
}

#ifdef LINUX_KERNEL
ibl_code_t *
get_ibl_code_from_routine_pc(dcontext_t *dcontext, cache_pc pc)
{
ibl_source_fragment_type_t source_fragment_type;
ibl_branch_type_t branch_type;
# if defined(X86) && defined(X64)
gencode_mode_t mode;
# endif

for (source_fragment_type = IBL_SOURCE_TYPE_START;
source_fragment_type < IBL_SOURCE_TYPE_END; source_fragment_type++) {
for (branch_type = IBL_BRANCH_TYPE_START; branch_type < IBL_BRANCH_TYPE_END;
branch_type++) {
# if defined(X86) && defined(X64)
for (mode = GENCODE_X64; mode <= GENCODE_X86_TO_X64; mode++) {
# endif
ibl_code_t *code = get_ibl_routine_code_internal(
dcontext, source_fragment_type, branch_type _IF_X86_64(mode));
if (code != NULL && code->initialized &&
pc >= code->indirect_branch_lookup_routine &&
pc < code->indirect_branch_lookup_routine_end) {
return code;
}
# if defined(X86) && defined(X64)
}
# endif
}
}
return NULL;
}
#endif

#ifdef WINDOWS
/* XXX We support a private and shared fragments simultaneously targeting
* shared syscall -- -shared_fragment_shared_syscalls must be on and both
Expand Down Expand Up @@ -2818,6 +2982,10 @@ get_fcache_target(dcontext_t *dcontext)
void
set_fcache_target(dcontext_t *dcontext, cache_pc value)
{
#ifdef LINUX_KERNEL
/* Save the last app tag. We need this to handle interrupts in fcache_enter. */
dcontext->next_app_tag = dcontext->next_tag;
#endif
/* we used to use mcontext.pc, but that's in the writable
* portion of the dcontext, and so for self-protection we use the
* next_tag slot, which is protected
Expand Down Expand Up @@ -2881,7 +3049,7 @@ get_global_do_syscall_entry()
/* used only by cleanup_and_terminate to avoid the sysenter
* sygate hack version */
byte *
get_cleanup_and_terminate_global_do_syscall_entry()
get_cleanup_and_terminate_global_do_syscall_entry(void)
{
/* see note above: for 32-bit linux apps we use int.
* xref PR 332427 as well where sysenter causes a crash
Expand Down Expand Up @@ -4026,17 +4194,17 @@ unit_test_atomic_ops(void)
ATOMIC_8BYTE_WRITE(&count3, value64, false);
EXPECT(count3, -1);
# endif
EXPECT(atomic_inc_and_test(&count1), true); /* result is 0 */
EXPECT(atomic_inc_and_test(&count1), false); /* result is 1 */
EXPECT(atomic_dec_and_test(&count1), false); /* init value is 1, result is 0 */
EXPECT(atomic_dec_and_test(&count1), true); /* init value is 0, result is -1 */
EXPECT(atomic_dec_becomes_zero(&count1), false); /* result is -2 */
EXPECT(d_r_atomic_inc_and_test(&count1), true); /* result is 0 */
EXPECT(d_r_atomic_inc_and_test(&count1), false); /* result is 1 */
EXPECT(d_r_atomic_dec_and_test(&count1), false); /* init value is 1, result is 0 */
EXPECT(d_r_atomic_dec_and_test(&count1), true); /* init value is 0, result is -1 */
EXPECT(d_r_atomic_dec_becomes_zero(&count1), false); /* result is -2 */
EXPECT(atomic_compare_exchange_int(&count1, -3, 1), false); /* no exchange */
EXPECT(count1, -2);
EXPECT(atomic_compare_exchange_int(&count1, -2, 1), true); /* exchange */
EXPECT(atomic_dec_becomes_zero(&count1), true); /* result is 0 */
EXPECT(atomic_dec_and_test(&count1), true); /* init value is 0, result is -1 */
EXPECT(atomic_dec_and_test(&count1), true); /* init value is -1, result is -2 */
EXPECT(d_r_atomic_dec_becomes_zero(&count1), true); /* result is 0 */
EXPECT(d_r_atomic_dec_and_test(&count1), true); /* init value is 0, result is -1 */
EXPECT(d_r_atomic_dec_and_test(&count1), true); /* init value is -1, result is -2 */
ATOMIC_4BYTE_WRITE(&count1, 0, false);
do_parallel_updates();
EXPECT(count1, MAX_NUM_THREADS);
Expand Down
Loading
Loading