Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / powerpc / tm / tm-fork.c
blobc27b935f0e9fc016f8f8e8888078fd0daa7c199a
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright 2015, Michael Neuling, IBM Corp.
5 * Edited: Rashmica Gupta, Nov 2015
7 * This test does a fork syscall inside a transaction. Basic sniff test
8 * to see if we can enter the kernel during a transaction.
9 */
11 #include <errno.h>
12 #include <inttypes.h>
13 #include <pthread.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <unistd.h>
18 #include "utils.h"
19 #include "tm.h"
21 int test_fork(void)
23 SKIP_IF(!have_htm());
24 SKIP_IF(htm_is_synthetic());
26 asm __volatile__(
27 "tbegin.;"
28 "blt 1f; "
29 "li 0, 2;" /* fork syscall */
30 "sc ;"
31 "tend.;"
32 "1: ;"
33 : : : "memory", "r0");
34 /* If we reach here, we've passed. Otherwise we've probably crashed
35 * the kernel */
37 return 0;
40 int main(int argc, char *argv[])
42 return test_harness(test_fork, "tm_fork");