Skip to content

Commit d37344a

Browse files
committed
gem5: port lkmc/m5ops.h to x86
We can now easily include x86 m5ops on our gem5 examples.
1 parent 9fd9cb5 commit d37344a

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

README.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10916,8 +10916,9 @@ To use that file, first rebuild `m5ops.out` with the m5ops instructions enabled
1091610916
./build-userland \
1091710917
--arch aarch64 \
1091810918
--ccflags='-DLKMC_M5OPS_ENABLE=1' \
10919-
--force-rebuild c/m5ops \
10919+
--force-rebuild \
1092010920
--static \
10921+
userland/c/m5ops.c \
1092110922
;
1092210923
./build-buildroot --arch aarch64
1092310924
....

lkmc/m5ops.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,28 @@
55

66
#if LKMC_M5OPS_ENABLE
77

8-
#if defined(__arm__)
8+
#if defined(__x86_64__)
9+
10+
/* 0x43 is the identifier for CHECKPOINT on all archs.
11+
*
12+
* 0x040F is the magic x86 undefined instruction boilerplate to which the identifier gets added.
13+
*
14+
* D means RDI which is the first argument of a Linux C function call,
15+
* and S means RSI is the second one: these are also used by gem5 as arguments of the m5ops.
16+
*/
17+
#define LKMC_M5OPS_CHECKPOINT_ASM mov $0, %%rdi; mov $0, %%rsi; .word 0x040F; .word 0x0043
18+
#define LKMC_M5OPS_DUMPSTATS_ASM mov $0, %%rdi; mov $0, %%rsi; .word 0x040F; .word 0x0041
19+
#define LKMC_M5OPS_EXIT_ASM mov $0, %%rdi; .word 0x040F; .word 0x0021
20+
#define LKMC_M5OPS_FAIL_1_ASM mov $0, %%rdi; mov $1, %%rsi; .word 0x040F; .word 0x0022
21+
#define LKMC_M5OPS_RESETSTATS_ASM mov $0, %%rdi; mov $0, %%rsi; .word 0x040F; .word 0x0040
22+
23+
#define LKMC_M5OPS_CHECKPOINT __asm__ __volatile__ (".word 0x040F; .word 0x0043;" : : "D" (0), "S" (0) :)
24+
#define LKMC_M5OPS_DUMPSTATS __asm__ __volatile__ (".word 0x040F; .word 0x0041;" : : "D" (0), "S" (0) :)
25+
#define LKMC_M5OPS_EXIT __asm__ __volatile__ (".word 0x040F; .word 0x0021;" : : "D" (0) :)
26+
#define LKMC_M5OPS_FAIL_1 __asm__ __volatile__ (".word 0x040F; .word 0x0022;" : : "D" (0), "S" (1) :)
27+
#define LKMC_M5OPS_RESETSTATS __asm__ __volatile__ (".word 0x040F; .word 0x0040;" : : "D" (0), "S" (0) :)
28+
29+
#elif defined(__arm__)
930

1031
#define LKMC_M5OPS_CHECKPOINT_ASM mov r0, #0; mov r1, #0; mov r2, #0; mov r3, #0; .inst 0xEE000110 | (0x43 << 16)
1132
#define LKMC_M5OPS_DUMPSTATS_ASM mov r0, #0; mov r1, #0; mov r2, #0; mov r3, #0; .inst 0xEE000110 | (0x41 << 16)

0 commit comments

Comments
 (0)