Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / aarch64 / bti-3.c
bloba852856d9a6d3da56b5480dbf4b8873c8312d9eb
1 /*
2 * BTI vs PACIASP
3 */
5 #include "bti-crt.inc.c"
7 static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc)
9 uc->uc_mcontext.pc += 8;
10 uc->uc_mcontext.pstate = 1;
13 #define BTYPE_1() \
14 asm("mov %0,#1; adr x16, 1f; br x16; 1: hint #25; mov %0,#0" \
15 : "=r"(skipped) : : "x16", "x30")
17 #define BTYPE_2() \
18 asm("mov %0,#1; adr x16, 1f; blr x16; 1: hint #25; mov %0,#0" \
19 : "=r"(skipped) : : "x16", "x30")
21 #define BTYPE_3() \
22 asm("mov %0,#1; adr x15, 1f; br x15; 1: hint #25; mov %0,#0" \
23 : "=r"(skipped) : : "x15", "x30")
25 #define TEST(WHICH, EXPECT) \
26 do { WHICH(); fail += skipped ^ EXPECT; } while (0)
28 int main()
30 int fail = 0;
31 int skipped;
33 /* Signal-like with SA_SIGINFO. */
34 signal_info(SIGILL, skip2_sigill);
36 /* With SCTLR_EL1.BT0 set, PACIASP is not compatible with type=3. */
37 TEST(BTYPE_1, 0);
38 TEST(BTYPE_2, 0);
39 TEST(BTYPE_3, 1);
41 return fail;