testsuite: Add test for x86 port io
PATCH v2 1/1 testsuite: Add test for x86 port io
Test case for the following regression:
https://www.xenomai.org/pipermail/xenomai/2022-March/047451.html
Signed-off-by Richard Weinberger <[email protected]>
---
Changes since v1:
- Make sure to restore SA upon failure.
--- configure.ac | 2 + testsuite/smokey/Makefile.am | 7 +++ testsuite/smokey/x86io/Makefile.am | 7 +++ testsuite/smokey/x86io/x86io.c | 77 ++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 testsuite/smokey/x86io/Makefile.am create mode 100644 testsuite/smokey/x86io/x86io.c
configure.ac +2 -0
@@ -169,6 +169,7 @@ esac AC_MSG_RESULT([$target_cpu_arch]) XENO_TARGET_ARCH=$target_cpu_arch +AM_CONDITIONAL(XENO_X86,[test x$target_cpu_arch = xx86]) AC_ENABLE_SHARED AC_PROG_LIBTOOL
@@ -1044,6 +1045,7 @@ AC_CONFIG_FILES([ \ testsuite/smokey/gdb/Makefile \ testsuite/smokey/y2038/Makefile \ testsuite/smokey/can/Makefile + testsuite/smokey/x86io/Makefile testsuite/clocktest/Makefile \ testsuite/xeno-test/Makefile \ utils/Makefile \
testsuite/smokey/Makefile.am +7 -0
@@ -82,6 +82,10 @@ DIST_SUBDIRS = \ xddp \ y2038 +if XENO_X86 +DIST_SUBDIRS += x86io +endif + if XENO_COBALT if CONFIG_XENO_LIBS_DLOPEN COBALT_SUBDIRS += dlopen
@@ -89,6 +93,9 @@ endif if XENO_PSHARED COBALT_SUBDIRS += memory-pshared endif +if XENO_X86 +COBALT_SUBDIRS += x86io +endif wrappers = $(XENO_POSIX_WRAPPERS) SUBDIRS = $(COBALT_SUBDIRS) else
testsuite/smokey/x86io/Makefile.am new file +7 -0
@@ -0,0 +1,7 @@ +noinst_LIBRARIES = libx86io.a + +libx86io_a_SOURCES = x86io.c + +libx86io_a_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir)/include
testsuite/smokey/x86io/x86io.c new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.34.1
Jan Kiszka
AppliedQuoted 147 lines · Richard Weinberger via Xenomai
Test case for the following regression:
https://www.xenomai.org/pipermail/xenomai/2022-March/047451.htmlSigned-off-by Richard Weinberger <[email protected]>---
Changes since v1:
- Make sure to restore SA upon failure.--- configure.ac | 2 + testsuite/smokey/Makefile.am | 7 +++ testsuite/smokey/x86io/Makefile.am | 7 +++ testsuite/smokey/x86io/x86io.c | 77 ++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 testsuite/smokey/x86io/Makefile.am create mode 100644 testsuite/smokey/x86io/x86io.cconfigure.ac +2
-0@@ -169,6 +169,7 @@ esac AC_MSG_RESULT([$target_cpu_arch]) XENO_TARGET_ARCH=$target_cpu_arch +AM_CONDITIONAL(XENO_X86,[test x$target_cpu_arch = xx86]) AC_ENABLE_SHARED AC_PROG_LIBTOOL@@ -1044,6 +1045,7 @@ AC_CONFIG_FILES([ \ testsuite/smokey/gdb/Makefile \ testsuite/smokey/y2038/Makefile \ testsuite/smokey/can/Makefile + testsuite/smokey/x86io/Makefile testsuite/clocktest/Makefile \ testsuite/xeno-test/Makefile \ utils/Makefile \testsuite/smokey/Makefile.am +7
-0@@ -82,6 +82,10 @@ DIST_SUBDIRS = \ xddp \ y2038 +if XENO_X86 +DIST_SUBDIRS += x86io +endif + if XENO_COBALT if CONFIG_XENO_LIBS_DLOPEN COBALT_SUBDIRS += dlopen@@ -89,6 +93,9 @@ endif if XENO_PSHARED COBALT_SUBDIRS += memory-pshared endif +if XENO_X86 +COBALT_SUBDIRS += x86io +endif wrappers = $(XENO_POSIX_WRAPPERS) SUBDIRS = $(COBALT_SUBDIRS) elsetestsuite/smokey/x86io/Makefile.am new file +7
-0@@ -0,0 +1,7 @@ +noinst_LIBRARIES = libx86io.a + +libx86io_a_SOURCES = x86io.c + +libx86io_a_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir)/includetestsuite/smokey/x86io/x86io.c new file +67
-0@@ -0,0 +1,77 @@ +/* +* Test for a working iopl() after a regression on 5.15: +* https://www.xenomai.org/pipermail/xenomai/2022-March/047451.html +* +* Copyright (C) 2022 sigma star gmbh +* Author Richard Weinberger <[email protected]> +* +* Released under the terms of GPLv2. +*/ +#include <pthread.h> +#include <sched.h> +#include <signal.h> +#include <smokey/smokey.h> +#include <string.h> +#include <sys/io.h> +#include <unistd.h> + +#define PORT (0x378) + +static int saw_segv; + +static void *tfn (void *d) +{ +struct sched_param schedp = {0 }; +int ret; + + schedp.sched_priority =1 ; +__Terrno (ret,sched_setscheduler (0 ,SCHED_FIFO , &schedp)); + + (void )inb (PORT ); + +return (void *)(unsigned long )ret; +} + +static void sgfn (int sig,siginfo_t *si,void *ctx) +{ + saw_segv =1 ; +} + +smokey_test_plugin (x86io,SMOKEY_NOARGS ,"Check x86 port io" ); + +int run_x86io (struct smokey_test *t,int argc,char *const argv[]) +{ +struct sigaction sa, old_sa; +unsigned long ptret; +pthread_t pt; +int ret; + +memset (&sa,0 ,sizeof (sa)); + sa.sa_sigaction = sgfn; + sa.sa_flags =SA_SIGINFO ; +sigemptyset (&sa.sa_mask); + +if (!__Terrno (ret,sigaction (SIGSEGV , &sa, &old_sa))) + goto out; + +if (!__Terrno (ret,iopl (3 ))) + goto out_restore; + +if (!__T (ret,pthread_create (&pt,NULL , tfn,NULL ))) + goto out_restore; + +if (!__T (ret,pthread_join (pt, (void *)&ptret))) + goto out_restore; + +out_restore: +sigaction (SIGSEGV , &old_sa,NULL );
testsuite/smokey/x86io/x86io.c line 77
Quoted 10 lines
testsuite/smokey/x86io/x86io.c new file +10
-0+ +out: +if (ret) +return -ret; +if (ptret) +return -ptret; +if (saw_segv) +return -EFAULT ; +return 0 ; +}
OK, let's through this at our lab and see if anything explodes.
Thanks, applied.
Jan
Signature · 2 lines
Siemens AG, Technology Competence Center Embedded Linux