execve: Clear sigaltstack and fp_regs
Fujitsu: POSTK_DEBUG_TEMP_FIX_19 Refs: #976 Change-Id: I16895eab13eecbb47b7e6da961fae82ee5e570ee
This commit is contained in:
@ -1437,8 +1437,7 @@ void copy_fp_regs(struct thread *from, struct thread *to)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void clear_fp_regs(void)
|
||||||
clear_fp_regs(struct thread *thread)
|
|
||||||
{
|
{
|
||||||
if (likely(elf_hwcap & (HWCAP_FP | HWCAP_ASIMD))) {
|
if (likely(elf_hwcap & (HWCAP_FP | HWCAP_ASIMD))) {
|
||||||
#ifdef CONFIG_ARM64_SVE
|
#ifdef CONFIG_ARM64_SVE
|
||||||
@ -1475,7 +1474,7 @@ restore_fp_regs(struct thread *thread)
|
|||||||
if (likely(elf_hwcap & (HWCAP_FP | HWCAP_ASIMD))) {
|
if (likely(elf_hwcap & (HWCAP_FP | HWCAP_ASIMD))) {
|
||||||
if (!thread->fp_regs) {
|
if (!thread->fp_regs) {
|
||||||
// only clear fpregs.
|
// only clear fpregs.
|
||||||
clear_fp_regs(thread);
|
clear_fp_regs();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
thread_fpsimd_load(thread);
|
thread_fpsimd_load(thread);
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#include <cpufeature.h>
|
#include <cpufeature.h>
|
||||||
#include <kmalloc.h>
|
#include <kmalloc.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
#include <process.h>
|
||||||
|
|
||||||
//#define DEBUG_PRINT_FPSIMD
|
//#define DEBUG_PRINT_FPSIMD
|
||||||
|
|
||||||
@ -71,9 +72,6 @@ static int get_nr_threads(struct process *proc)
|
|||||||
return nr_threads;
|
return nr_threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void save_fp_regs(struct thread *thread);
|
|
||||||
extern void clear_fp_regs(struct thread *thread);
|
|
||||||
extern void restore_fp_regs(struct thread *thread);
|
|
||||||
/* @ref.impl arch/arm64/kernel/fpsimd.c::sve_set_vector_length */
|
/* @ref.impl arch/arm64/kernel/fpsimd.c::sve_set_vector_length */
|
||||||
int sve_set_vector_length(struct thread *thread,
|
int sve_set_vector_length(struct thread *thread,
|
||||||
unsigned long vl, unsigned long flags)
|
unsigned long vl, unsigned long flags)
|
||||||
@ -127,7 +125,7 @@ int sve_set_vector_length(struct thread *thread,
|
|||||||
/* for self at prctl syscall */
|
/* for self at prctl syscall */
|
||||||
if (thread == cpu_local_var(current)) {
|
if (thread == cpu_local_var(current)) {
|
||||||
save_fp_regs(thread);
|
save_fp_regs(thread);
|
||||||
clear_fp_regs(thread);
|
clear_fp_regs();
|
||||||
thread_sve_to_fpsimd(thread, &fp_regs);
|
thread_sve_to_fpsimd(thread, &fp_regs);
|
||||||
sve_free(thread);
|
sve_free(thread);
|
||||||
|
|
||||||
|
|||||||
@ -1760,14 +1760,6 @@ void copy_fp_regs(struct thread *from, struct thread *to)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_TEMP_FIX_19
|
|
||||||
void
|
|
||||||
clear_fp_regs(struct thread *thread)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif /* POSTK_DEBUG_TEMP_FIX_19 */
|
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
@ requires \valid(thread);
|
@ requires \valid(thread);
|
||||||
@ assigns thread->fp_regs;
|
@ assigns thread->fp_regs;
|
||||||
@ -1775,8 +1767,11 @@ clear_fp_regs(struct thread *thread)
|
|||||||
void
|
void
|
||||||
restore_fp_regs(struct thread *thread)
|
restore_fp_regs(struct thread *thread)
|
||||||
{
|
{
|
||||||
if (!thread->fp_regs)
|
if (!thread->fp_regs) {
|
||||||
|
// only clear fpregs.
|
||||||
|
clear_fp_regs();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (xsave_available) {
|
if (xsave_available) {
|
||||||
unsigned int low, high;
|
unsigned int low, high;
|
||||||
@ -1795,6 +1790,13 @@ restore_fp_regs(struct thread *thread)
|
|||||||
//release_fp_regs(thread);
|
//release_fp_regs(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear_fp_regs(void)
|
||||||
|
{
|
||||||
|
struct cpu_local_var *v = get_this_cpu_local_var();
|
||||||
|
|
||||||
|
restore_fp_regs(&v->idle);
|
||||||
|
}
|
||||||
|
|
||||||
ihk_mc_user_context_t *lookup_user_context(struct thread *thread)
|
ihk_mc_user_context_t *lookup_user_context(struct thread *thread)
|
||||||
{
|
{
|
||||||
ihk_mc_user_context_t *uctx = thread->uctx;
|
ihk_mc_user_context_t *uctx = thread->uctx;
|
||||||
|
|||||||
@ -829,4 +829,10 @@ void proc_init(void);
|
|||||||
void set_timer(void);
|
void set_timer(void);
|
||||||
struct sig_pending *hassigpending(struct thread *thread);
|
struct sig_pending *hassigpending(struct thread *thread);
|
||||||
|
|
||||||
|
void release_fp_regs(struct thread *proc);
|
||||||
|
void save_fp_regs(struct thread *proc);
|
||||||
|
void copy_fp_regs(struct thread *from, struct thread *to);
|
||||||
|
void restore_fp_regs(struct thread *proc);
|
||||||
|
void clear_fp_regs(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -77,10 +77,6 @@ static int vm_range_insert(struct process_vm *vm,
|
|||||||
static struct vm_range *vm_range_find(struct process_vm *vm,
|
static struct vm_range *vm_range_find(struct process_vm *vm,
|
||||||
unsigned long addr);
|
unsigned long addr);
|
||||||
static int copy_user_ranges(struct process_vm *vm, struct process_vm *orgvm);
|
static int copy_user_ranges(struct process_vm *vm, struct process_vm *orgvm);
|
||||||
extern void release_fp_regs(struct thread *proc);
|
|
||||||
extern void save_fp_regs(struct thread *proc);
|
|
||||||
extern void copy_fp_regs(struct thread *from, struct thread *to);
|
|
||||||
extern void restore_fp_regs(struct thread *proc);
|
|
||||||
extern void __runq_add_proc(struct thread *proc, int cpu_id);
|
extern void __runq_add_proc(struct thread *proc, int cpu_id);
|
||||||
extern void terminate_host(int pid);
|
extern void terminate_host(int pid);
|
||||||
extern void lapic_timer_enable(unsigned int clocks);
|
extern void lapic_timer_enable(unsigned int clocks);
|
||||||
@ -2947,6 +2943,9 @@ void sched_init(void)
|
|||||||
INIT_LIST_HEAD(&cpu_local_var(migq));
|
INIT_LIST_HEAD(&cpu_local_var(migq));
|
||||||
ihk_mc_spinlock_init(&cpu_local_var(migq_lock));
|
ihk_mc_spinlock_init(&cpu_local_var(migq_lock));
|
||||||
|
|
||||||
|
// to save default fpregs
|
||||||
|
save_fp_regs(idle_thread);
|
||||||
|
|
||||||
#ifdef TIMER_CPU_ID
|
#ifdef TIMER_CPU_ID
|
||||||
if (ihk_mc_get_processor_id() == TIMER_CPU_ID) {
|
if (ihk_mc_get_processor_id() == TIMER_CPU_ID) {
|
||||||
init_timers();
|
init_timers();
|
||||||
|
|||||||
@ -2129,10 +2129,6 @@ static void munmap_all(void)
|
|||||||
return;
|
return;
|
||||||
} /* munmap_all() */
|
} /* munmap_all() */
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_TEMP_FIX_19
|
|
||||||
extern void clear_fp_regs(struct thread *thread);
|
|
||||||
#endif /* POSTK_DEBUG_TEMP_FIX_19 */
|
|
||||||
|
|
||||||
SYSCALL_DECLARE(execve)
|
SYSCALL_DECLARE(execve)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
@ -2273,10 +2269,13 @@ SYSCALL_DECLARE(execve)
|
|||||||
thread->sigcommon->action[i].sa.sa_handler = SIG_DFL;
|
thread->sigcommon->action[i].sa.sa_handler = SIG_DFL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_TEMP_FIX_19
|
/* Reset floating-point environment to default. */
|
||||||
/* The floating-point environment is reset to the default. */
|
clear_fp_regs();
|
||||||
clear_fp_regs(thread);
|
|
||||||
#endif /* POSTK_DEBUG_TEMP_FIX_19 */
|
/* Reset sigaltstack to default */
|
||||||
|
thread->sigstack.ss_sp = NULL;
|
||||||
|
thread->sigstack.ss_flags = SS_DISABLE;
|
||||||
|
thread->sigstack.ss_size = 0;
|
||||||
|
|
||||||
error = ptrace_report_exec(thread);
|
error = ptrace_report_exec(thread);
|
||||||
if(error) {
|
if(error) {
|
||||||
|
|||||||
100
test/issues/976/C976.sh
Normal file
100
test/issues/976/C976.sh
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
if [ -f $HOME/mck_test_config ]; then
|
||||||
|
. $HOME/mck_test_config
|
||||||
|
else
|
||||||
|
BIN=
|
||||||
|
SBIN=
|
||||||
|
OSTEST=
|
||||||
|
LTP=
|
||||||
|
fi
|
||||||
|
BOOTPARAM="-c 1-7,9-15,17-23,25-31 -m 10G@0,10G@1 -r 1-7:0+9-15:8+17-23:16+25-31:24"
|
||||||
|
|
||||||
|
if [ "x$BINDIR" = x ];then
|
||||||
|
BINDIR="$BIN"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$SBINDIR" = x ];then
|
||||||
|
SBINDIR="$SBIN"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$OSTESTDIR" = x ]; then
|
||||||
|
OSTESTDIR="$OSTEST"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$LTPDIR" = x ]; then
|
||||||
|
LTPDIR="$LTP"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x $SBINDIR/mcstop+release.sh ]; then
|
||||||
|
echo mcstop+release: not found >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -n "mcstop+release.sh ... "
|
||||||
|
sudo $SBINDIR/mcstop+release.sh
|
||||||
|
echo "done"
|
||||||
|
|
||||||
|
if [ ! -x $SBINDIR/mcreboot.sh ]; then
|
||||||
|
echo mcreboot: not found >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -n "mcreboot.sh $BOOTPARAM ... "
|
||||||
|
sudo $SBINDIR/mcreboot.sh $BOOTPARAM
|
||||||
|
echo "done"
|
||||||
|
|
||||||
|
if [ ! -x $BINDIR/mcexec ]; then
|
||||||
|
echo mcexec: not found >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
$BINDIR/mcexec ./CT_001
|
||||||
|
$BINDIR/mcexec ./CT_002
|
||||||
|
$BINDIR/mcexec ./CT_003
|
||||||
|
|
||||||
|
tid=001
|
||||||
|
echo "*** LT_$tid start *******************************"
|
||||||
|
sudo PATH=$LTPDIR/bin:${PATH} $BINDIR/mcexec $LTPDIR/bin/execve01 2>&1 | tee ./LT_${tid}.txt
|
||||||
|
ok=`grep TPASS LT_${tid}.txt | wc -l`
|
||||||
|
ng=`grep TFAIL LT_${tid}.txt | wc -l`
|
||||||
|
if [ $ng = 0 ]; then
|
||||||
|
echo "*** LT_$tid: PASSED (ok:$ok)"
|
||||||
|
else
|
||||||
|
echo "*** LT_$tid: FAILED (ok:$ok, ng:$ng)"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
tid=002
|
||||||
|
echo "*** LT_$tid start *******************************"
|
||||||
|
sudo PATH=$LTPDIR/bin:${PATH} $BINDIR/mcexec $LTPDIR/bin/execve02 2>&1 | tee ./LT_${tid}.txt
|
||||||
|
ok=`grep TPASS LT_${tid}.txt | wc -l`
|
||||||
|
ng=`grep TFAIL LT_${tid}.txt | wc -l`
|
||||||
|
if [ $ng = 0 ]; then
|
||||||
|
echo "*** LT_$tid: PASSED (ok:$ok)"
|
||||||
|
else
|
||||||
|
echo "*** LT_$tid: FAILED (ok:$ok, ng:$ng)"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
tid=003
|
||||||
|
echo "*** LT_$tid start *******************************"
|
||||||
|
sudo PATH=$LTPDIR/bin:${PATH} $BINDIR/mcexec $LTPDIR/bin/execve03 2>&1 | tee ./LT_${tid}.txt
|
||||||
|
ok=`grep TPASS LT_${tid}.txt | wc -l`
|
||||||
|
ng=`grep TFAIL LT_${tid}.txt | wc -l`
|
||||||
|
if [ $ng = 0 ]; then
|
||||||
|
echo "*** LT_$tid: PASSED (ok:$ok)"
|
||||||
|
else
|
||||||
|
echo "*** LT_$tid: FAILED (ok:$ok, ng:$ng)"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
tid=004
|
||||||
|
echo "*** LT_$tid start *******************************"
|
||||||
|
sudo PATH=$LTPDIR/bin:${PATH} $BINDIR/mcexec $LTPDIR/bin/execve05 20 $LTPDIR/bin/execve05 $LTPDIR/bin/execve05 4 2>&1 | tee ./LT_${tid}.txt
|
||||||
|
ok=`grep TPASS LT_${tid}.txt | wc -l`
|
||||||
|
ng=`grep TFAIL LT_${tid}.txt | wc -l`
|
||||||
|
if [ $ng = 0 ]; then
|
||||||
|
echo "*** LT_$tid: PASSED (ok:$ok)"
|
||||||
|
else
|
||||||
|
echo "*** LT_$tid: FAILED (ok:$ok, ng:$ng)"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
64
test/issues/976/CT_001.c
Normal file
64
test/issues/976/CT_001.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <error.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include "./test_chk.h"
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#define TEST_NAME "CT_001"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
stack_t cur_stack;
|
||||||
|
stack_t set_stack;
|
||||||
|
void *stack_area = NULL;
|
||||||
|
char *exargv[3] = {argv[0], "stop", NULL};
|
||||||
|
char *exenvp[1] = {NULL};
|
||||||
|
|
||||||
|
printf("*** %s start ********************************\n", TEST_NAME);
|
||||||
|
rc = sigaltstack(NULL, &cur_stack);
|
||||||
|
OKNG(rc != 0, "sigaltstack() to get current returned %d"
|
||||||
|
"\n (expect return is 0)", rc);
|
||||||
|
|
||||||
|
OKNG(cur_stack.ss_sp != NULL, "default ss_sp is %p"
|
||||||
|
"\n (expect ss_sp is NULL)", cur_stack.ss_sp);
|
||||||
|
|
||||||
|
stack_area = mmap(0, MINSIGSTKSZ, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||||
|
|
||||||
|
OKNG(stack_area == MAP_FAILED, "alloc altstack area %p"
|
||||||
|
"\n (expect area is valid vaddr)", stack_area);
|
||||||
|
|
||||||
|
set_stack.ss_sp = stack_area;
|
||||||
|
set_stack.ss_flags = 0;
|
||||||
|
set_stack.ss_size = MINSIGSTKSZ;
|
||||||
|
|
||||||
|
rc = sigaltstack(&set_stack, NULL);
|
||||||
|
OKNG(rc != 0, "sigaltstack() to set new stack returned %d"
|
||||||
|
"\n (expect return is 0)", rc);
|
||||||
|
|
||||||
|
rc = sigaltstack(NULL, &cur_stack);
|
||||||
|
OKNG(rc != 0, "sigaltstack() to get current returned %d"
|
||||||
|
"\n (expect return is 0)", rc);
|
||||||
|
|
||||||
|
OKNG(cur_stack.ss_sp != stack_area, "new ss_sp is %p"
|
||||||
|
"\n (expect ss_sp is %p)", cur_stack.ss_sp, stack_area);
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("** Re-run by execve\n");
|
||||||
|
execve(exargv[0], exargv, exenvp);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("*** %s PASSED\n\n", TEST_NAME);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fn_fail:
|
||||||
|
printf("*** %s FAILED\n\n", TEST_NAME);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
52
test/issues/976/CT_002.c
Normal file
52
test/issues/976/CT_002.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "./test_chk.h"
|
||||||
|
|
||||||
|
#include <fenv.h>
|
||||||
|
|
||||||
|
#define TEST_NAME "CT_002"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
fenv_t fenv;
|
||||||
|
int rc = 0;
|
||||||
|
int round = 0;
|
||||||
|
double dummy = 0;
|
||||||
|
char *exargv[3] = {argv[0], "stop", NULL};
|
||||||
|
char *exenvp[1] = {NULL};
|
||||||
|
|
||||||
|
printf("*** %s start ********************************\n", TEST_NAME);
|
||||||
|
rc = fetestexcept(FE_ALL_EXCEPT);
|
||||||
|
OKNG(rc != 0, "fetestexcept(FE_ALL_EXCEPT) returned %d"
|
||||||
|
"\n (expect return is 0)", rc);
|
||||||
|
|
||||||
|
dummy = (double)0 / 0;
|
||||||
|
rc = fetestexcept(FE_ALL_EXCEPT);
|
||||||
|
OKNG(rc != FE_INVALID, "fetestexcept(FE_ALL_EXCEPT) returned %d"
|
||||||
|
"\n (expect return is FE_INVALID(%d))", rc, FE_INVALID);
|
||||||
|
|
||||||
|
rc = feraiseexcept(FE_ALL_EXCEPT);
|
||||||
|
OKNG(rc != 0, "feraiseexcept(FE_ALL_EXCEPT) returned %d"
|
||||||
|
"\n (expect return is 0)", rc);
|
||||||
|
|
||||||
|
rc = fetestexcept(FE_ALL_EXCEPT);
|
||||||
|
OKNG(rc != FE_ALL_EXCEPT, "fetestexcept(FE_ALL_EXCEPT) returned %d"
|
||||||
|
"\n (expect return is FE_ALL_EXCEPT(%d))",
|
||||||
|
rc, FE_ALL_EXCEPT);
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("** Re-run by execve\n");
|
||||||
|
execve(exargv[0], exargv, exenvp);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("*** %s PASSED\n\n", TEST_NAME);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fn_fail:
|
||||||
|
printf("*** %s FAILED\n\n", TEST_NAME);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
48
test/issues/976/CT_003.c
Normal file
48
test/issues/976/CT_003.c
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "./test_chk.h"
|
||||||
|
|
||||||
|
#include <fenv.h>
|
||||||
|
|
||||||
|
#define TEST_NAME "CT_003"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
fenv_t fenv;
|
||||||
|
int rc = 0;
|
||||||
|
int round = 0;
|
||||||
|
char *exargv[3] = {argv[0], "stop", NULL};
|
||||||
|
char *exenvp[1] = {NULL};
|
||||||
|
|
||||||
|
printf("*** %s start ********************************\n", TEST_NAME);
|
||||||
|
round = fegetround();
|
||||||
|
OKNG(round != FE_TONEAREST, "fegetround returned %d"
|
||||||
|
"\n (expect return is FE_TONEAREST(%d))",
|
||||||
|
round, FE_TONEAREST);
|
||||||
|
|
||||||
|
rc = fesetround(FE_TOWARDZERO);
|
||||||
|
OKNG(rc != 0, "fesetround(FE_TOWARDZERO) returned %d"
|
||||||
|
"\n (expect return is 0)", rc);
|
||||||
|
|
||||||
|
round = fegetround();
|
||||||
|
OKNG(round != FE_TOWARDZERO, "fegetround returned %d"
|
||||||
|
"\n (expect return is FE_TOWARDZERO(%d))",
|
||||||
|
round, FE_TOWARDZERO);
|
||||||
|
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("** Re-run by execve\n");
|
||||||
|
execve(exargv[0], exargv, exenvp);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("*** %s PASSED\n\n", TEST_NAME);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fn_fail:
|
||||||
|
printf("*** %s FAILED\n\n", TEST_NAME);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
23
test/issues/976/Makefile
Normal file
23
test/issues/976/Makefile
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
CC = gcc
|
||||||
|
TARGET=CT_001 CT_002 CT_003
|
||||||
|
|
||||||
|
CPPFLAGS =
|
||||||
|
LDFLAGS =
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
CT_001: CT_001.c
|
||||||
|
$(CC) -o $@ $^ $(LDFLAGS)
|
||||||
|
|
||||||
|
CT_002: CT_002.c
|
||||||
|
$(CC) -o $@ $^ $(LDFLAGS) -lm
|
||||||
|
|
||||||
|
CT_003: CT_003.c
|
||||||
|
$(CC) -o $@ $^ $(LDFLAGS) -lm
|
||||||
|
|
||||||
|
test: all
|
||||||
|
@sh ./C976.sh
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(TARGET) *.o
|
||||||
|
|
||||||
54
test/issues/976/README
Normal file
54
test/issues/976/README
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
【Issue#976 動作確認】
|
||||||
|
□ テスト内容
|
||||||
|
1. Issueで報告された再現プログラムでの確認
|
||||||
|
CT_001: sigaltstackがexecve時に初期化されていることの確認
|
||||||
|
1. 自プロセスの代替シグナルスタック(ss_sp)がNULLであることを確認
|
||||||
|
2. sigaltstack()で新たに代替シグナルスタックを設定
|
||||||
|
3. execve で自身を再実行し、自プロセスの代替シグナルスタックがNULLであることを確認
|
||||||
|
|
||||||
|
CT_002: fenvの浮動小数点例外発生フラグがexecve時に初期化されていることを確認
|
||||||
|
1. fetestexcept(FE_ALL_EXCEPT)で自プロセスの浮動小数点例外の発生フラグが
|
||||||
|
すべて0であることを確認
|
||||||
|
2. 0除算を実行し、浮動小数点例外(FE_INVALID)を発生させる
|
||||||
|
3. fetestexcept(FE_ALL_EXCEPT)で自プロセスのFE_INVALIDフラグが1に
|
||||||
|
なっていることを確認
|
||||||
|
4. feraiseexcept(FE_ALL_EXCEPT)で自プロセスの浮動小数点例外の発生フラグを
|
||||||
|
すべて1にする
|
||||||
|
5. execve で自身を再実行し、浮動小数点例外の発生フラグがすべて0であることを確認
|
||||||
|
|
||||||
|
CT_003: fenvの浮動小数丸めの設定がexecve時に初期化されていることを確認
|
||||||
|
1. fegetround() で自プロセスの丸めモードを取得し、FE_TONEARESTであることを確認
|
||||||
|
2. fesetround(FE_TOWARDZERO) で自プロセスの丸めモードをFE_TOWARDZEROに変更する
|
||||||
|
3. execve で自身を再実行し、自プロセスの丸めモードがFE_TONEARESTであることを確認
|
||||||
|
|
||||||
|
2. 既存のexecve機能に影響がないことをLTPを用いて確認
|
||||||
|
LT_001: ltp-execve01
|
||||||
|
子プロセスがexecveを実行し、正常に終了することを確認 (TPASS 1件)
|
||||||
|
|
||||||
|
LT_002: ltp-execve02
|
||||||
|
rootのみに実行権限が付与された実行ファイルを、
|
||||||
|
一般ユーザがexecveした場合に失敗することを確認 (TPASS 1件)
|
||||||
|
|
||||||
|
LT_003: ltp-execve03
|
||||||
|
下記の不正な引数でexecveを実行した場合、返り値と設定されるerrnoが
|
||||||
|
正しいことを確認 (TPASS 6件)
|
||||||
|
|
||||||
|
LT_004: ltp-execve05
|
||||||
|
execveの標準的な動作を確認 (TPASS 8件)
|
||||||
|
|
||||||
|
□ 実行手順
|
||||||
|
McKernelのインストール先や、OSTEST, LTPの配置場所は、
|
||||||
|
$HOME/mck_test_config を参照している
|
||||||
|
mck_test_config は、McKernelをビルドした際に生成される
|
||||||
|
mck_test_config.sample ファイルを$HOMEにコピーし、適宜編集する
|
||||||
|
|
||||||
|
$ make test
|
||||||
|
|
||||||
|
実行できない場合は、C976.shの以下の行を適切に書き換えた後に実行。
|
||||||
|
BIN= mcexec が存在するパス
|
||||||
|
SBIN= mcreboot.sh が存在するパス
|
||||||
|
LTP= LTPが存在するパス
|
||||||
|
|
||||||
|
□ 実行結果
|
||||||
|
result.log 参照。
|
||||||
|
すべての項目をPASSしていることを確認。
|
||||||
103
test/issues/976/result.log
Normal file
103
test/issues/976/result.log
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
*** CT_001 start ********************************
|
||||||
|
[OK] sigaltstack() to get current returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] default ss_sp is (nil)
|
||||||
|
(expect ss_sp is NULL)
|
||||||
|
[OK] alloc altstack area 0x2aaaab014000
|
||||||
|
(expect area is valid vaddr)
|
||||||
|
[OK] sigaltstack() to set new stack returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] sigaltstack() to get current returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] new ss_sp is 0x2aaaab014000
|
||||||
|
(expect ss_sp is 0x2aaaab014000)
|
||||||
|
** Re-run by execve
|
||||||
|
*** CT_001 start ********************************
|
||||||
|
[OK] sigaltstack() to get current returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] default ss_sp is (nil)
|
||||||
|
(expect ss_sp is NULL)
|
||||||
|
[OK] alloc altstack area 0x2aaaab014000
|
||||||
|
(expect area is valid vaddr)
|
||||||
|
[OK] sigaltstack() to set new stack returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] sigaltstack() to get current returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] new ss_sp is 0x2aaaab014000
|
||||||
|
(expect ss_sp is 0x2aaaab014000)
|
||||||
|
*** CT_001 PASSED
|
||||||
|
|
||||||
|
*** CT_002 start ********************************
|
||||||
|
[OK] fetestexcept(FE_ALL_EXCEPT) returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] fetestexcept(FE_ALL_EXCEPT) returned 1
|
||||||
|
(expect return is FE_INVALID(1))
|
||||||
|
[OK] feraiseexcept(FE_ALL_EXCEPT) returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] fetestexcept(FE_ALL_EXCEPT) returned 61
|
||||||
|
(expect return is FE_ALL_EXCEPT(61))
|
||||||
|
** Re-run by execve
|
||||||
|
*** CT_002 start ********************************
|
||||||
|
[OK] fetestexcept(FE_ALL_EXCEPT) returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] fetestexcept(FE_ALL_EXCEPT) returned 1
|
||||||
|
(expect return is FE_INVALID(1))
|
||||||
|
[OK] feraiseexcept(FE_ALL_EXCEPT) returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] fetestexcept(FE_ALL_EXCEPT) returned 61
|
||||||
|
(expect return is FE_ALL_EXCEPT(61))
|
||||||
|
*** CT_002 PASSED
|
||||||
|
|
||||||
|
*** CT_003 start ********************************
|
||||||
|
[OK] fegetround returned 0
|
||||||
|
(expect return is FE_TONEAREST(0))
|
||||||
|
[OK] fesetround(FE_TOWARDZERO) returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] fegetround returned 3072
|
||||||
|
(expect return is FE_TOWARDZERO(3072))
|
||||||
|
** Re-run by execve
|
||||||
|
*** CT_003 start ********************************
|
||||||
|
[OK] fegetround returned 0
|
||||||
|
(expect return is FE_TONEAREST(0))
|
||||||
|
[OK] fesetround(FE_TOWARDZERO) returned 0
|
||||||
|
(expect return is 0)
|
||||||
|
[OK] fegetround returned 3072
|
||||||
|
(expect return is FE_TOWARDZERO(3072))
|
||||||
|
*** CT_003 PASSED
|
||||||
|
|
||||||
|
*** LT_001 start *******************************
|
||||||
|
execl01_child 1 TPASS : execve01_child executed
|
||||||
|
execve01 0 TINFO : Child process returned TPASS
|
||||||
|
*** LT_001: PASSED (ok:2)
|
||||||
|
|
||||||
|
*** LT_002 start *******************************
|
||||||
|
Error: Failed to open execve_child
|
||||||
|
execve(): error loading ELF for file execve_child
|
||||||
|
execve02 1 TPASS : execve() failed expectedly: TEST_ERRNO=EACCES(13): Permission denied
|
||||||
|
execve02 0 TINFO : Child process returned TPASS
|
||||||
|
*** LT_002: PASSED (ok:2)
|
||||||
|
|
||||||
|
*** LT_003 start *******************************
|
||||||
|
lookup_exec_path: lookup_exec_path(): error stat
|
||||||
|
Error: /tmp/exeiG2gZP/fake.11925 is not an executable?, errno: 13
|
||||||
|
execve(): error loading ELF for file /tmp/exeiG2gZP/fake.11925
|
||||||
|
Error: file /tmp/exeiG2gZP/execve03.11925 is zero length
|
||||||
|
execve(): error loading ELF for file /tmp/exeiG2gZP/execve03.11925
|
||||||
|
execve03 1 TPASS : execve failed as expected: TEST_ERRNO=ENAMETOOLONG(36): File name too long
|
||||||
|
execve03 2 TPASS : execve failed as expected: TEST_ERRNO=ENOENT(2): No such file or directory
|
||||||
|
execve03 3 TPASS : execve failed as expected: TEST_ERRNO=ENOTDIR(20): Not a directory
|
||||||
|
execve03 4 TPASS : execve failed as expected: TEST_ERRNO=EFAULT(14): Bad address
|
||||||
|
execve03 5 TPASS : execve failed as expected: TEST_ERRNO=EACCES(13): Permission denied
|
||||||
|
execve03 6 TPASS : execve failed as expected: TEST_ERRNO=ENOEXEC(8): Exec format error
|
||||||
|
*** LT_003: PASSED (ok:6)
|
||||||
|
|
||||||
|
*** LT_004 start *******************************
|
||||||
|
execve05 1 TPASS : Test DONE, pid 11995, -- /home/satoken/ltp/testcases/bin/execve05 0 /home/satoken/ltp/testcases/bin/execve05 /home/satoken/ltp/testcases/bin/execve05
|
||||||
|
execve05 1 TPASS : Test DONE, pid 12025, -- /home/satoken/ltp/testcases/bin/execve05 0 /home/satoken/ltp/testcases/bin/execve05 /home/satoken/ltp/testcases/bin/execve05
|
||||||
|
execve05 1 TPASS : Test DONE, pid 12055, -- /home/satoken/ltp/testcases/bin/execve05 0 /home/satoken/ltp/testcases/bin/execve05 /home/satoken/ltp/testcases/bin/execve05
|
||||||
|
execve05 1 TPASS : Test DONE, pid 12085, -- /home/satoken/ltp/testcases/bin/execve05 0 /home/satoken/ltp/testcases/bin/execve05 /home/satoken/ltp/testcases/bin/execve05
|
||||||
|
execve05 1 TPASS : Test DONE, pid 12115, -- /home/satoken/ltp/testcases/bin/execve05 0 /home/satoken/ltp/testcases/bin/execve05 /home/satoken/ltp/testcases/bin/execve05
|
||||||
|
execve05 1 TPASS : Test DONE, pid 12145, -- /home/satoken/ltp/testcases/bin/execve05 0 /home/satoken/ltp/testcases/bin/execve05 /home/satoken/ltp/testcases/bin/execve05
|
||||||
|
execve05 1 TPASS : Test DONE, pid 12175, -- /home/satoken/ltp/testcases/bin/execve05 0 /home/satoken/ltp/testcases/bin/execve05 /home/satoken/ltp/testcases/bin/execve05
|
||||||
|
execve05 1 TPASS : Test DONE, pid 12205, -- /home/satoken/ltp/testcases/bin/execve05 0 /home/satoken/ltp/testcases/bin/execve05 /home/satoken/ltp/testcases/bin/execve05
|
||||||
|
*** LT_004: PASSED (ok:8)
|
||||||
23
test/issues/976/test_chk.h
Normal file
23
test/issues/976/test_chk.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef HEADER_TEST_CHK_H
|
||||||
|
#define HEADER_TEST_CHK_H
|
||||||
|
|
||||||
|
#define CHKANDJUMP(cond, ...) do {\
|
||||||
|
if (cond) {\
|
||||||
|
fprintf(stderr, " [NG] ");\
|
||||||
|
fprintf(stderr, __VA_ARGS__);\
|
||||||
|
fprintf(stderr, " failed\n");\
|
||||||
|
goto fn_fail;\
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define OKNG(cond, ...) do {\
|
||||||
|
if (cond) {\
|
||||||
|
CHKANDJUMP(cond, __VA_ARGS__);\
|
||||||
|
} else {\
|
||||||
|
fprintf(stdout, " [OK] ");\
|
||||||
|
fprintf(stdout, __VA_ARGS__);\
|
||||||
|
fprintf(stdout, "\n");\
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user