Commit a431b946 authored by Cyril Bur's avatar Cyril Bur Committed by Michael Ellerman

selftests/powerpc: exec() with suspended transaction

Perform an exec() class syscall with a suspended transaction.

This is a test for the bug we fixed in 8e96a87c ("powerpc/tm: Always
reclaim in start_thread() for exec() class syscalls").
Signed-off-by: default avatarCyril Bur <cyrilbur@gmail.com>
[mpe: Fix build errors, use a single binary for the test]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent dd570237
...@@ -6,3 +6,4 @@ tm-vmxcopy ...@@ -6,3 +6,4 @@ tm-vmxcopy
tm-fork tm-fork
tm-tar tm-tar
tm-tmspr tm-tmspr
tm-exec
TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack tm-vmxcopy tm-fork tm-tar tm-tmspr TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
tm-vmxcopy tm-fork tm-tar tm-tmspr tm-exec tm-execed
all: $(TEST_PROGS) all: $(TEST_PROGS)
$(TEST_PROGS): ../harness.c ../utils.c $(TEST_PROGS): ../harness.c ../utils.c
CFLAGS += -mhtm
tm-syscall: tm-syscall-asm.S tm-syscall: tm-syscall-asm.S
tm-syscall: CFLAGS += -mhtm -I../../../../../usr/include tm-syscall: CFLAGS += -I../../../../../usr/include
tm-tmspr: CFLAGS += -pthread tm-tmspr: CFLAGS += -pthread
include ../../lib.mk include ../../lib.mk
......
/*
* Copyright 2016, Cyril Bur, IBM Corp.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* Syscalls can be performed provided the transactions are suspended.
* The exec() class of syscall is unique as a new process is loaded.
*
* It makes little sense for after an exec() call for the previously
* suspended transaction to still exist.
*/
#define _GNU_SOURCE
#include <errno.h>
#include <inttypes.h>
#include <libgen.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "utils.h"
#include "tm.h"
static char *path;
static int test_exec(void)
{
SKIP_IF(!have_htm());
asm __volatile__(
"tbegin.;"
"blt 1f; "
"tsuspend.;"
"1: ;"
: : : "memory");
execl(path, "tm-exec", "--child", NULL);
/* Shouldn't get here */
perror("execl() failed");
return 1;
}
static int after_exec(void)
{
asm __volatile__(
"tbegin.;"
"blt 1f;"
"tsuspend.;"
"1: ;"
: : : "memory");
FAIL_IF(failure_is_nesting());
return 0;
}
int main(int argc, char *argv[])
{
path = argv[0];
if (argc > 1 && strcmp(argv[1], "--child") == 0)
return after_exec();
return test_harness(test_exec, "tm_exec");
}
...@@ -27,21 +27,6 @@ unsigned retries = 0; ...@@ -27,21 +27,6 @@ unsigned retries = 0;
#define TEST_DURATION 10 /* seconds */ #define TEST_DURATION 10 /* seconds */
#define TM_RETRIES 100 #define TM_RETRIES 100
long failure_code(void)
{
return __builtin_get_texasru() >> 24;
}
bool failure_is_persistent(void)
{
return (failure_code() & TM_CAUSE_PERSISTENT) == TM_CAUSE_PERSISTENT;
}
bool failure_is_syscall(void)
{
return (failure_code() & TM_CAUSE_SYSCALL) == TM_CAUSE_SYSCALL;
}
pid_t getppid_tm(bool suspend) pid_t getppid_tm(bool suspend)
{ {
int i; int i;
......
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
#ifndef _SELFTESTS_POWERPC_TM_TM_H #ifndef _SELFTESTS_POWERPC_TM_TM_H
#define _SELFTESTS_POWERPC_TM_TM_H #define _SELFTESTS_POWERPC_TM_TM_H
#include <stdbool.h> #include <asm/tm.h>
#include <asm/cputable.h> #include <asm/cputable.h>
#include <stdbool.h>
#include "../utils.h" #include "../utils.h"
...@@ -31,4 +32,24 @@ static inline bool have_htm_nosc(void) ...@@ -31,4 +32,24 @@ static inline bool have_htm_nosc(void)
#endif #endif
} }
static inline long failure_code(void)
{
return __builtin_get_texasru() >> 24;
}
static inline bool failure_is_persistent(void)
{
return (failure_code() & TM_CAUSE_PERSISTENT) == TM_CAUSE_PERSISTENT;
}
static inline bool failure_is_syscall(void)
{
return (failure_code() & TM_CAUSE_SYSCALL) == TM_CAUSE_SYSCALL;
}
static inline bool failure_is_nesting(void)
{
return (__builtin_get_texasru() & 0x400000);
}
#endif /* _SELFTESTS_POWERPC_TM_TM_H */ #endif /* _SELFTESTS_POWERPC_TM_TM_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment