tm-exec.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright 2016, Cyril Bur, IBM Corp.
  4. *
  5. * Syscalls can be performed provided the transactions are suspended.
  6. * The exec() class of syscall is unique as a new process is loaded.
  7. *
  8. * It makes little sense for after an exec() call for the previously
  9. * suspended transaction to still exist.
  10. */
  11. #define _GNU_SOURCE
  12. #include <errno.h>
  13. #include <inttypes.h>
  14. #include <libgen.h>
  15. #include <pthread.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <unistd.h>
  20. #include "utils.h"
  21. #include "tm.h"
  22. static char *path;
  23. static int test_exec(void)
  24. {
  25. SKIP_IF(!have_htm());
  26. SKIP_IF(htm_is_synthetic());
  27. asm __volatile__(
  28. "tbegin.;"
  29. "blt 1f; "
  30. "tsuspend.;"
  31. "1: ;"
  32. : : : "memory");
  33. execl(path, "tm-exec", "--child", NULL);
  34. /* Shouldn't get here */
  35. perror("execl() failed");
  36. return 1;
  37. }
  38. static int after_exec(void)
  39. {
  40. asm __volatile__(
  41. "tbegin.;"
  42. "blt 1f;"
  43. "tsuspend.;"
  44. "1: ;"
  45. : : : "memory");
  46. FAIL_IF(failure_is_nesting());
  47. return 0;
  48. }
  49. int main(int argc, char *argv[])
  50. {
  51. path = argv[0];
  52. if (argc > 1 && strcmp(argv[1], "--child") == 0)
  53. return after_exec();
  54. return test_harness(test_exec, "tm_exec");
  55. }