Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright 2015, Michael Neuling, IBM Corp.
0004  *
0005  * Edited: Rashmica Gupta, Nov 2015
0006  *
0007  * This test does a fork syscall inside a transaction. Basic sniff test
0008  * to see if we can enter the kernel during a transaction.
0009  */
0010 
0011 #include <errno.h>
0012 #include <inttypes.h>
0013 #include <pthread.h>
0014 #include <stdio.h>
0015 #include <stdlib.h>
0016 #include <unistd.h>
0017 
0018 #include "utils.h"
0019 #include "tm.h"
0020 
0021 int test_fork(void)
0022 {
0023     SKIP_IF(!have_htm());
0024     SKIP_IF(htm_is_synthetic());
0025 
0026     asm __volatile__(
0027         "tbegin.;"
0028         "blt    1f; "
0029         "li     0, 2;"  /* fork syscall */
0030         "sc  ;"
0031         "tend.;"
0032         "1: ;"
0033         : : : "memory", "r0");
0034     /* If we reach here, we've passed.  Otherwise we've probably crashed
0035      * the kernel */
0036 
0037     return 0;
0038 }
0039 
0040 int main(int argc, char *argv[])
0041 {
0042     return test_harness(test_fork, "tm_fork");
0043 }