1 #include "../multiarch/noexec.c.inc"
3 static void *arch_mcontext_pc(const mcontext_t
*ctx
)
5 return (void *)ctx
->__gregs
[REG_PC
];
8 static int arch_mcontext_arg(const mcontext_t
*ctx
)
10 return ctx
->__gregs
[REG_A0
];
13 static void arch_flush(void *p
, int len
)
15 __builtin___clear_cache(p
, p
+ len
);
18 extern char noexec_1
[];
19 extern char noexec_2
[];
20 extern char noexec_end
[];
25 " li a0,1\n" /* a0 is 0 on entry, set 1. */
27 " li a0,2\n" /* a0 is 0/1; set 2. */
34 struct noexec_test noexec_tests
[] = {
36 .name
= "fallthrough",
37 .test_code
= noexec_1
,
38 .test_len
= noexec_end
- noexec_1
,
39 .page_ofs
= noexec_1
- noexec_2
,
40 .entry_ofs
= noexec_1
- noexec_2
,
47 .test_code
= noexec_1
,
48 .test_len
= noexec_end
- noexec_1
,
49 .page_ofs
= noexec_1
- noexec_2
,
56 .name
= "fallthrough [cross]",
57 .test_code
= noexec_1
,
58 .test_len
= noexec_end
- noexec_1
,
59 .page_ofs
= noexec_1
- noexec_2
- 2,
60 .entry_ofs
= noexec_1
- noexec_2
- 2,
62 .expected_pc_ofs
= -2,
66 .name
= "jump [cross]",
67 .test_code
= noexec_1
,
68 .test_len
= noexec_end
- noexec_1
,
69 .page_ofs
= noexec_1
- noexec_2
- 2,
72 .expected_pc_ofs
= -2,
77 return test_noexec(noexec_tests
,
78 sizeof(noexec_tests
) / sizeof(noexec_tests
[0]));