tools/testing/selftests/arm64/bti/test.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/arm64/bti/test.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/arm64/bti/test.c
Extension
.c
Size
4980 bytes
Lines
230
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (auxv->type) {
		case AT_HWCAP:
			hwcap = auxv->val;
			break;
		case AT_HWCAP2:
			hwcap2 = auxv->val;
			break;
		default:
			break;
		}
	}

	if (hwcap & HWCAP_PACA)
		putstr("# HWCAP_PACA present\n");
	else
		putstr("# HWCAP_PACA not present\n");

	if (hwcap2 & HWCAP2_BTI) {
		putstr("# HWCAP2_BTI present\n");
		if (!(hwcap & HWCAP_PACA))
			putstr("# Bad hardware?  Expect problems.\n");
		have_bti = true;
	} else {
		putstr("# HWCAP2_BTI not present\n");
		have_bti = false;
	}

	putstr("# Test binary");
	if (!BTI)
		putstr(" not");
	putstr(" built for BTI\n");

	sa.sa_handler = (sighandler_t)(void *)handler;
	sa.sa_flags = SA_SIGINFO;
	sigemptyset(&sa.sa_mask);
	sigaction(SIGILL, &sa, NULL);
	sigaddset(&sa.sa_mask, SIGILL);
	sigprocmask(SIG_UNBLOCK, &sa.sa_mask, NULL);

	do_test(1, 1, 1, nohint_func);
	do_test(1, 1, 1, bti_none_func);
	do_test(1, 0, 0, bti_c_func);
	do_test(0, 0, 1, bti_j_func);
	do_test(0, 0, 0, bti_jc_func);
	do_test(1, 0, 0, paciasp_func);

	print_summary();

	if (test_num - 1 != EXPECTED_TESTS)
		putstr("# WARNING - EXPECTED TEST COUNT WRONG\n");

	if (test_failed)
		exit(1);
	else
		exit(0);
}

Annotation

Implementation Notes