/** Assembly relative function call test of all BTI-relevant calls.
*/ int btitest_bl(void);
/* Assembly indirect call functions, using all BTI-relevant calls. *BRviax16andx17isoftenusedbylinkersforveneersandhassome *additionalhandlingdescribedintheARMArchitectureReferenceManual, *TableD8-36(IYWFHD). *Thepassedfunc_idxshouldbeoneoftheBTITEST_CALLEE_macros,whichcovers *thelandingpadinstructiontypesgivenintheARMArchitectureReference *Manual,TableD8-37(ICNBPL).
*/ int btitest_blr(int func_idx); int btitest_br_x16(int func_idx); int btitest_br_x17(int func_idx); int btitest_br(int func_idx);
/* Get the expected return code when a BTI access should be trapped */ staticint bti_trap_code(void) { #ifdef KERNEL_BTI_ENABLED if (arch_bti_supported()) { return ERR_FAULT;
} #endif /* No BTI, or not enabled - faults are not detected */ return0;
}
TEST(btitest, supported) { if (!arch_bti_supported()) {
trusty_unittest_printf("[ INFO ] BTI is not supported\n");
GTEST_SKIP();
}
EXPECT_EQ(true, arch_bti_supported());
test_abort:;
}
/* Smoke-test the callee functions; they should return 0 when called with BL */
TEST(btitest, smoke) {
EXPECT_EQ(0, btitest_bl());
}
TEST(btitest, nop) { /* Fault on jump or call to non-bti target */
EXPECT_EQ(bti_trap_code(), btitest_br(BTITEST_CALLEE_NOP));
EXPECT_EQ(bti_trap_code(), btitest_blr(BTITEST_CALLEE_NOP));
EXPECT_EQ(bti_trap_code(), btitest_br_x16(BTITEST_CALLEE_NOP));
EXPECT_EQ(bti_trap_code(), btitest_br_x17(BTITEST_CALLEE_NOP));
}
TEST(btitest, bti) { /* Fault on any jump or call to non-target bti */
EXPECT_EQ(bti_trap_code(), btitest_br(BTITEST_CALLEE_BTI));
EXPECT_EQ(bti_trap_code(), btitest_blr(BTITEST_CALLEE_BTI));
EXPECT_EQ(bti_trap_code(), btitest_br_x16(BTITEST_CALLEE_BTI));
EXPECT_EQ(bti_trap_code(), btitest_br_x17(BTITEST_CALLEE_BTI));
}
TEST(btitest, bti_c) { /* Call or branch via x16/17 to a call target is valid */
EXPECT_EQ(0, btitest_blr(BTITEST_CALLEE_BTI_C));
EXPECT_EQ(0, btitest_br_x16(BTITEST_CALLEE_BTI_C));
EXPECT_EQ(0, btitest_br_x17(BTITEST_CALLEE_BTI_C));
/* Fault on branch to call target */
EXPECT_EQ(bti_trap_code(), btitest_br(BTITEST_CALLEE_BTI_C));
}
TEST(btitest, bti_j) { /* Any branch to jump target is valid */
EXPECT_EQ(0, btitest_br(BTITEST_CALLEE_BTI_J));
EXPECT_EQ(0, btitest_br_x16(BTITEST_CALLEE_BTI_J));
EXPECT_EQ(0, btitest_br_x17(BTITEST_CALLEE_BTI_J));
/* Fault on call to jump target */
EXPECT_EQ(bti_trap_code(), btitest_blr(BTITEST_CALLEE_BTI_J));
}
TEST(btitest, bti_jc) { /* Either branch type allowed to call and jump target */
EXPECT_EQ(0, btitest_br(BTITEST_CALLEE_BTI_JC));
EXPECT_EQ(0, btitest_br_x16(BTITEST_CALLEE_BTI_JC));
EXPECT_EQ(0, btitest_br_x17(BTITEST_CALLEE_BTI_JC));
EXPECT_EQ(0, btitest_blr(BTITEST_CALLEE_BTI_JC));
}
TEST(btitest, pacisp) { if (!arch_pac_address_supported()) {
trusty_unittest_printf("[ INFO ] PAC is not supported\n");
GTEST_SKIP();
}
/* PACIASP is a valid target for all branch types */
EXPECT_EQ(0, btitest_br(BTITEST_CALLEE_PACIASP));
EXPECT_EQ(0, btitest_br_x16(BTITEST_CALLEE_PACIASP));
EXPECT_EQ(0, btitest_br_x17(BTITEST_CALLEE_PACIASP));
EXPECT_EQ(0, btitest_blr(BTITEST_CALLEE_PACIASP));
/* PACIBSP is a valid target for all branch types */
EXPECT_EQ(0, btitest_br(BTITEST_CALLEE_PACIBSP));
EXPECT_EQ(0, btitest_br_x16(BTITEST_CALLEE_PACIBSP));
EXPECT_EQ(0, btitest_br_x17(BTITEST_CALLEE_PACIBSP));
EXPECT_EQ(0, btitest_blr(BTITEST_CALLEE_PACIBSP));
test_abort:;
}
PORT_TEST(btitest, "com.android.kernel.btitest");
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.