CCTLib
Calling-context and data-object attribution library for Intel Pin
redspy_cross_page_tp.c
Go to the documentation of this file.
1
// Redspy ISA edge case: cross-page same-value write. The qword store
2
// starts 4 bytes before a 4KB page boundary, so the write straddles two
3
// pages. Repeated writes of the SAME value at the same straddled address
4
// are redundant. Verifies redspy's shadow correctly maintains value
5
// tracking across page boundaries.
6
#include <stdint.h>
7
#include <stddef.h>
8
#include <sys/mman.h>
9
#define WORK_COUNT 10000
10
static
volatile
uint64_t
sink
;
11
int
main
(
int
argc,
char
** argv) {
12
(void)argc; (void)argv;
13
const
size_t
pagesz = 4096;
14
void
* region = mmap(NULL, 2 * pagesz, PROT_READ | PROT_WRITE,
15
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
16
if
(region == MAP_FAILED)
return
1;
17
uint64_t* straddle = (uint64_t*)((
char
*)region + pagesz - 4);
18
uint64_t v = 0xC0FFEEDEADBEEFULL;
19
for
(
int
i = 0; i <
WORK_COUNT
; ++i) {
20
__asm__ __volatile__(
21
"movq %[v], (%[p])\n\t"
22
"movq %[v], (%[p])\n\t"
// same value -- redundant
23
:
24
: [p]
"r"
(straddle), [v]
"r"
(v)
25
:
"memory"
);
26
}
27
sink
= *straddle;
28
munmap(region, 2 * pagesz);
29
return
0;
30
}
WORK_COUNT
#define WORK_COUNT
Definition:
redspy_cross_page_tp.c:9
main
int main(int argc, char **argv)
Definition:
redspy_cross_page_tp.c:11
sink
static volatile uint64_t sink
Definition:
redspy_cross_page_tp.c:10
tests
gtest
apps
isa
redspy_cross_page_tp.c
Generated on Wed Jul 15 2026 04:51:30 for CCTLib by
1.9.1