tools/testing/selftests/powerpc/tm/tm-signal-context-force-tm.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/tm/tm-signal-context-force-tm.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/powerpc/tm/tm-signal-context-force-tm.c
Extension
.c
Size
4472 bytes
Lines
181
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

if (ss.ss_sp == (void *)-1) {
			perror("mmap error\n");
			exit(-1);
		}

		/* Force the allocation through a page fault */
		if (madvise(ss.ss_sp, SIGSTKSZ, MADV_DONTNEED)) {
			perror("madvise\n");
			exit(-1);
		}

		/*
		 * Setting an alternative stack to generate a page fault when
		 * the signal is raised.
		 */
		if (sigaltstack(&ss, NULL)) {
			perror("sigaltstack\n");
			exit(-1);
		}

		/* The signal handler will enable MSR_TS */
		sigaction(SIGUSR1, &usr_sa, NULL);
		/* If it does not crash, it might segfault, avoid it to retest */
		sigaction(SIGSEGV, &seg_sa, NULL);

		raise(SIGUSR1);
		count++;
	}
}

int tm_signal_context_force_tm(void)
{
	SKIP_IF(!have_htm());
	/*
	 * Skipping if not running on 64 bits system, since I think it is
	 * not possible to set mcontext's [MSR] with TS, due to it being 32
	 * bits.
	 */
	SKIP_IF(!is_ppc64le());

	tm_trap_test();

	return EXIT_SUCCESS;
}

int main(int argc, char **argv)
{
	return test_harness(tm_signal_context_force_tm, "tm_signal_context_force_tm");
}

Annotation

Implementation Notes