tm-fork.c 826 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright 2015, Michael Neuling, IBM Corp.
  4. *
  5. * Edited: Rashmica Gupta, Nov 2015
  6. *
  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. */
  10. #include <errno.h>
  11. #include <inttypes.h>
  12. #include <pthread.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <unistd.h>
  16. #include "utils.h"
  17. #include "tm.h"
  18. int test_fork(void)
  19. {
  20. SKIP_IF(!have_htm());
  21. SKIP_IF(htm_is_synthetic());
  22. asm __volatile__(
  23. "tbegin.;"
  24. "blt 1f; "
  25. "li 0, 2;" /* fork syscall */
  26. "sc ;"
  27. "tend.;"
  28. "1: ;"
  29. : : : "memory", "r0");
  30. /* If we reach here, we've passed. Otherwise we've probably crashed
  31. * the kernel */
  32. return 0;
  33. }
  34. int main(int argc, char *argv[])
  35. {
  36. return test_harness(test_fork, "tm_fork");
  37. }