0b2d8bd698
Since commit139c1837db
("meson: rename included C source files to .c.inc"), QEMU standard procedure for included C files is to use *.c.inc. Besides, since commit6a0057aa22
("docs/devel: make a statement about includes") this is documented as the Coding Style: If you do use template header files they should be named with the ``.c.inc`` or ``.h.inc`` suffix to make it clear they are being included for expansion. Therefore rename 'bti-crt.inc.c' as 'bti-crt.c.inc'. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230606141252.95032-6-philmd@linaro.org>
43 lines
951 B
C
43 lines
951 B
C
/*
|
|
* BTI vs PACIASP
|
|
*/
|
|
|
|
#include "bti-crt.c.inc"
|
|
|
|
static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc)
|
|
{
|
|
uc->uc_mcontext.pc += 8;
|
|
uc->uc_mcontext.pstate = 1;
|
|
}
|
|
|
|
#define BTYPE_1() \
|
|
asm("mov %0,#1; adr x16, 1f; br x16; 1: hint #25; mov %0,#0" \
|
|
: "=r"(skipped) : : "x16", "x30")
|
|
|
|
#define BTYPE_2() \
|
|
asm("mov %0,#1; adr x16, 1f; blr x16; 1: hint #25; mov %0,#0" \
|
|
: "=r"(skipped) : : "x16", "x30")
|
|
|
|
#define BTYPE_3() \
|
|
asm("mov %0,#1; adr x15, 1f; br x15; 1: hint #25; mov %0,#0" \
|
|
: "=r"(skipped) : : "x15", "x30")
|
|
|
|
#define TEST(WHICH, EXPECT) \
|
|
do { WHICH(); fail += skipped ^ EXPECT; } while (0)
|
|
|
|
int main()
|
|
{
|
|
int fail = 0;
|
|
int skipped;
|
|
|
|
/* Signal-like with SA_SIGINFO. */
|
|
signal_info(SIGILL, skip2_sigill);
|
|
|
|
/* With SCTLR_EL1.BT0 set, PACIASP is not compatible with type=3. */
|
|
TEST(BTYPE_1, 0);
|
|
TEST(BTYPE_2, 0);
|
|
TEST(BTYPE_3, 1);
|
|
|
|
return fail;
|
|
}
|