All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/cma: test case should return TCONF if syscall doesn't exist
@ 2018-12-03  9:43 Jason Xing
  2018-12-03  9:58 ` Jan Stancek
  0 siblings, 1 reply; 23+ messages in thread
From: Jason Xing @ 2018-12-03  9:43 UTC (permalink / raw)
  To: ltp

The original code returns TFAIL when process_vm_readv/_writev syscalls
do not exist, while we are expecting a TCONF. During investigation, we
find it is due to '#if defined(__NR_process_vm_readv/_writev)' fails to
work as expected.  We fix this issue by using ltp_syscall() function in
setup function. BTW, we don't use new tst_syscall() interface due to
compatibility issue exists between old apis and new ones.

Signed-off-by: jasonxing <kerneljasonxing@linux.alibaba.com>
Signed-off-by: Caspar Zhang <caspar@linux.alibaba.com>
---
 testcases/kernel/syscalls/cma/process_vm.h         | 62 ----------------------
 testcases/kernel/syscalls/cma/process_vm01.c       | 30 ++++-------
 testcases/kernel/syscalls/cma/process_vm_readv02.c | 12 ++---
 testcases/kernel/syscalls/cma/process_vm_readv03.c | 14 ++---
 .../kernel/syscalls/cma/process_vm_writev02.c      | 12 ++---
 5 files changed, 30 insertions(+), 100 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/cma/process_vm.h

diff --git a/testcases/kernel/syscalls/cma/process_vm.h b/testcases/kernel/syscalls/cma/process_vm.h
deleted file mode 100644
index 1ecf325..0000000
--- a/testcases/kernel/syscalls/cma/process_vm.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2012 Linux Test Project, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-#ifndef _PROCESS_VM_H_
-#define _PROCESS_VM_H_
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-#include <sys/syscall.h>
-#include <sys/uio.h>
-#include <unistd.h>
-#include "lapi/semun.h"
-
-static inline ssize_t test_process_vm_readv(pid_t pid,
-		const struct iovec *lvec, unsigned long liovcnt,
-		const struct iovec *rvec, unsigned long riovcnt,
-		unsigned long flags)
-{
-#if defined(__NR_process_vm_readv)
-	return syscall(__NR_process_vm_readv, pid, lvec, liovcnt,
-			rvec, riovcnt, flags);
-#else
-	return syscall(-1);
-#endif
-}
-
-static inline ssize_t test_process_vm_writev(pid_t pid,
-		const struct iovec *lvec, unsigned long liovcnt,
-		const struct iovec *rvec, unsigned long riovcnt,
-		unsigned long flags)
-{
-#if defined(__NR_process_vm_writev)
-	return syscall(__NR_process_vm_writev, pid, lvec, liovcnt,
-			rvec, riovcnt, flags);
-#else
-	return syscall(-1);
-#endif
-}
-
-#endif /* _PROCESS_VM_H_ */
diff --git a/testcases/kernel/syscalls/cma/process_vm01.c b/testcases/kernel/syscalls/cma/process_vm01.c
index bc6b04f..f9bd865 100644
--- a/testcases/kernel/syscalls/cma/process_vm01.c
+++ b/testcases/kernel/syscalls/cma/process_vm01.c
@@ -42,7 +42,7 @@
 #include "config.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "process_vm.h"
+#include "lapi/syscalls.h"
 
 struct process_vm_params {
 	int len;
@@ -103,20 +103,10 @@ static void setup(char *argv[])
 			 " at the same time.");
 	else if (rflag) {
 		TCID = TCID_readv;
-#if defined(__NR_process_vm_readv)
 		cma_test_params = cma_test_params_read;
-#else
-		tst_brkm(TCONF, NULL, "process_vm_readv does not"
-			 " exist on your system.");
-#endif
 	} else if (wflag) {
 		TCID = TCID_writev;
-#if defined(__NR_process_vm_writev)
 		cma_test_params = cma_test_params_write;
-#else
-		tst_brkm(TCONF, NULL, "process_vm_writev does not"
-			 " exist on your system.");
-#endif
 	} else
 		tst_brkm(TBROK, NULL, "Parameter missing, required -r or -w.");
 	TEST_PAUSE;
@@ -134,18 +124,20 @@ static void help(void)
 
 static void cma_test_params_read(struct process_vm_params *params)
 {
-	TEST(test_process_vm_readv(params->pid,
-				   params->lvec, params->liovcnt,
-				   params->rvec, params->riovcnt,
-				   params->flags));
+	TEST(ltp_syscall(__NR_process_vm_readv,
+			 params->pid,
+			 params->lvec, params->liovcnt,
+			 params->rvec, params->riovcnt,
+			 params->flags));
 }
 
 static void cma_test_params_write(struct process_vm_params *params)
 {
-	TEST(test_process_vm_writev(params->pid,
-				    params->lvec, params->liovcnt,
-				    params->rvec, params->riovcnt,
-				    params->flags));
+	TEST(ltp_syscall(__NR_process_vm_writev,
+			 params->pid,
+			 params->lvec, params->liovcnt,
+			 params->rvec, params->riovcnt,
+			 params->flags));
 }
 
 static int cma_check_ret(long expected_ret, long act_ret)
diff --git a/testcases/kernel/syscalls/cma/process_vm_readv02.c b/testcases/kernel/syscalls/cma/process_vm_readv02.c
index ef9b7e1..e1fc32a 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv02.c
@@ -29,7 +29,7 @@
 
 #include "test.h"
 #include "safe_macros.h"
-#include "process_vm.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "process_vm_readv02";
 int TST_TOTAL = 1;
@@ -134,7 +134,8 @@ static void child_invoke(void)
 	remote.iov_len = len;
 
 	tst_resm(TINFO, "child 1: reading string from same memory location.");
-	TEST(test_process_vm_readv(pids[0], &local, 1, &remote, 1, 0));
+	TEST(ltp_syscall(__NR_process_vm_readv, pids[0],
+			 &local, 1, &remote, 1, 0));
 	if (TEST_RETURN != len)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 	if (strncmp(lp, tst_string, len) != 0)
@@ -148,10 +149,9 @@ static void setup(void)
 {
 	tst_require_root();
 
-#if !defined(__NR_process_vm_readv)
-	tst_brkm(TCONF, NULL, "process_vm_readv does not exist "
-		 "on your system");
-#endif
+	/* Just a sanity check of the existence of syscall */
+	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0);
+
 	tst_tmpdir();
 	TST_CHECKPOINT_INIT(cleanup);
 
diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c b/testcases/kernel/syscalls/cma/process_vm_readv03.c
index 8b8dfc3..45f7c92 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
@@ -32,7 +32,7 @@
 
 #include "test.h"
 #include "safe_macros.h"
-#include "process_vm.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "process_vm_readv03";
 int TST_TOTAL = 1;
@@ -180,7 +180,8 @@ static long *fetch_remote_addrs(void)
 	remote.iov_base = foo;
 	remote.iov_len = len;
 
-	TEST(test_process_vm_readv(pids[0], &local, 1, &remote, 1, 0));
+	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
+			 1, &remote, 1, 0));
 	if (TEST_RETURN != len)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 
@@ -212,7 +213,7 @@ static void child_invoke(int *bufsz_arr)
 	tst_resm(TINFO, "child 1: %d local iovecs initialized.",
 		 NUM_LOCAL_VECS);
 
-	TEST(test_process_vm_readv(pids[0], local, NUM_LOCAL_VECS,
+	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local, NUM_LOCAL_VECS,
 				   remote, nr_iovecs, 0));
 	if (TEST_RETURN != bufsz)
 		tst_brkm(TBROK | TERRNO, tst_exit, "process_vm_readv");
@@ -246,14 +247,13 @@ static void setup(void)
 {
 	tst_require_root();
 
+	/* Just a sanity check of the existence of syscall */
+	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0);
+
 	nr_iovecs = nflag ? SAFE_STRTOL(NULL, nr_opt, 1, IOV_MAX) : 10;
 	bufsz = sflag ? SAFE_STRTOL(NULL, sz_opt, NUM_LOCAL_VECS, LONG_MAX)
 	    : 100000;
 
-#if !defined(__NR_process_vm_readv)
-	tst_brkm(TCONF, NULL, "process_vm_readv does not exist "
-		 "on your system");
-#endif
 	tst_tmpdir();
 	TST_CHECKPOINT_INIT(cleanup);
 	srand(time(NULL));
diff --git a/testcases/kernel/syscalls/cma/process_vm_writev02.c b/testcases/kernel/syscalls/cma/process_vm_writev02.c
index b707760..b1edba5 100644
--- a/testcases/kernel/syscalls/cma/process_vm_writev02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_writev02.c
@@ -30,7 +30,7 @@
 
 #include "test.h"
 #include "safe_macros.h"
-#include "process_vm.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "process_vm_writev02";
 int TST_TOTAL = 1;
@@ -171,7 +171,8 @@ static void child_write(void)
 	remote.iov_len = bufsz;
 
 	tst_resm(TINFO, "child 2: write to the same memory location.");
-	TEST(test_process_vm_writev(pids[0], &local, 1, &remote, 1, 0));
+	TEST(ltp_syscall(__NR_process_vm_writev, pids[0], &local,
+			 1, &remote, 1, 0));
 	if (TEST_RETURN != bufsz)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 }
@@ -180,14 +181,13 @@ static void setup(void)
 {
 	tst_require_root();
 
+	/* Just a sanity check of the existence of syscall */
+	ltp_syscall(__NR_process_vm_writev, getpid(), NULL, 0, NULL, 0, 0);
+
 	bufsz =
 	    sflag ? SAFE_STRTOL(NULL, sz_opt, 1, LONG_MAX - PADDING_SIZE * 2)
 	    : 100000;
 
-#if !defined(__NR_process_vm_readv)
-	tst_brkm(TCONF, NULL, "process_vm_writev does not exist "
-		 "on your system");
-#endif
 	tst_tmpdir();
 	TST_CHECKPOINT_INIT(cleanup);
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH] syscalls/cma: test case should return TCONF if syscall doesn't exist
  2018-12-03  9:43 [LTP] [PATCH] syscalls/cma: test case should return TCONF if syscall doesn't exist Jason Xing
@ 2018-12-03  9:58 ` Jan Stancek
  2018-12-04  2:49   ` Jason Xing
  0 siblings, 1 reply; 23+ messages in thread
From: Jan Stancek @ 2018-12-03  9:58 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> The original code returns TFAIL when process_vm_readv/_writev syscalls
> do not exist, while we are expecting a TCONF. During investigation, we
> find it is due to '#if defined(__NR_process_vm_readv/_writev)' fails to
> work as expected.  We fix this issue by using ltp_syscall() function in
> setup function. BTW, we don't use new tst_syscall() interface due to
> compatibility issue exists between old apis and new ones.

Fine by me, but then you should also add syscall numbers to
include/lapi/syscalls:

process_vm01.c: In function ‘setup’:
process_vm01.c:97: warning: unused parameter ‘argv’
process_vm01.c: In function ‘cma_test_params_read’:
process_vm01.c:127: error: ‘__NR_process_vm_readv’ undeclared (first use in this function)
process_vm01.c:127: error: (Each undeclared identifier is reported only once
process_vm01.c:127: error: for each function it appears in.)
process_vm01.c: In function ‘cma_test_params_write’:
process_vm01.c:136: error: ‘__NR_process_vm_writev’ undeclared (first use in this function)

Regards,
Jan

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH] syscalls/cma: test case should return TCONF if syscall doesn't exist
  2018-12-03  9:58 ` Jan Stancek
@ 2018-12-04  2:49   ` Jason Xing
  2018-12-04  8:54     ` Jan Stancek
  0 siblings, 1 reply; 23+ messages in thread
From: Jason Xing @ 2018-12-04  2:49 UTC (permalink / raw)
  To: ltp



On 2018/12/3 下午5:58, Jan Stancek wrote:
>
>
> ----- Original Message -----
>> The original code returns TFAIL when process_vm_readv/_writev syscalls
>> do not exist, while we are expecting a TCONF. During investigation, we
>> find it is due to '#if defined(__NR_process_vm_readv/_writev)' fails to
>> work as expected.  We fix this issue by using ltp_syscall() function in
>> setup function. BTW, we don't use new tst_syscall() interface due to
>> compatibility issue exists between old apis and new ones.
>
> Fine by me, but then you should also add syscall numbers to
> include/lapi/syscalls:
>

Thanks.
I have TWO questions:

1. If I use this command #./strip_syscall.awk 
/usr/include/asm/unistd_64.h > x86_64.in, it will update and add more 
new syscall numbers into x86_64.in file which includes many other 
syscall numbers not only process_vm_readv/_writev. To solve this 
problem, can I just add the process_vm_readv/_writev syscall numbers and 
let go of other numbers?

2. I don't have so many types of machines that support different 
architectures like hppa and s390x. So what should I do to know this 
syscall number on other architectures. I'm running the tests on x86_64 arch.

Jason

> process_vm01.c: In function ‘setup’:
> process_vm01.c:97: warning: unused parameter ‘argv’
> process_vm01.c: In function ‘cma_test_params_read’:
> process_vm01.c:127: error: ‘__NR_process_vm_readv’ undeclared (first use in this function)
> process_vm01.c:127: error: (Each undeclared identifier is reported only once
> process_vm01.c:127: error: for each function it appears in.)
> process_vm01.c: In function ‘cma_test_params_write’:
> process_vm01.c:136: error: ‘__NR_process_vm_writev’ undeclared (first use in this function)
>
> Regards,
> Jan
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH] syscalls/cma: test case should return TCONF if syscall doesn't exist
  2018-12-04  2:49   ` Jason Xing
@ 2018-12-04  8:54     ` Jan Stancek
  2018-12-05 13:43       ` [LTP] [PATCH v2 1/2] " Jason Xing
  0 siblings, 1 reply; 23+ messages in thread
From: Jan Stancek @ 2018-12-04  8:54 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> 
> 
> On 2018/12/3 下午5:58, Jan Stancek wrote:
> >
> >
> > ----- Original Message -----
> >> The original code returns TFAIL when process_vm_readv/_writev syscalls
> >> do not exist, while we are expecting a TCONF. During investigation, we
> >> find it is due to '#if defined(__NR_process_vm_readv/_writev)' fails to
> >> work as expected.  We fix this issue by using ltp_syscall() function in
> >> setup function. BTW, we don't use new tst_syscall() interface due to
> >> compatibility issue exists between old apis and new ones.
> >
> > Fine by me, but then you should also add syscall numbers to
> > include/lapi/syscalls:
> >
> 
> Thanks.
> I have TWO questions:
> 
> 1. If I use this command #./strip_syscall.awk
> /usr/include/asm/unistd_64.h > x86_64.in, it will update and add more
> new syscall numbers into x86_64.in file which includes many other
> syscall numbers not only process_vm_readv/_writev. To solve this
> problem, can I just add the process_vm_readv/_writev syscall numbers and
> let go of other numbers?

Yes, I think updating only syscalls your patch is touching would be preferred.

> 
> 2. I don't have so many types of machines that support different
> architectures like hppa and s390x. So what should I do to know this
> syscall number on other architectures. I'm running the tests on x86_64 arch.

You can find it in kernel sources, e.g. grep for it, or usually
one of first commits mentioning the syscall will also add number.

Regards,
Jan


> 
> Jason
> 
> > process_vm01.c: In function ‘setup’:
> > process_vm01.c:97: warning: unused parameter ‘argv’
> > process_vm01.c: In function ‘cma_test_params_read’:
> > process_vm01.c:127: error: ‘__NR_process_vm_readv’ undeclared (first use in
> > this function)
> > process_vm01.c:127: error: (Each undeclared identifier is reported only
> > once
> > process_vm01.c:127: error: for each function it appears in.)
> > process_vm01.c: In function ‘cma_test_params_write’:
> > process_vm01.c:136: error: ‘__NR_process_vm_writev’ undeclared (first use
> > in this function)
> >
> > Regards,
> > Jan
> >
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist
  2018-12-04  8:54     ` Jan Stancek
@ 2018-12-05 13:43       ` Jason Xing
  2018-12-05 13:43         ` [LTP] [PATCH v2 2/2] lapi/syscalls: Add syscall numbers for process_vm_readv/_writev Jason Xing
  2019-02-15 10:50         ` [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist Li Wang
  0 siblings, 2 replies; 23+ messages in thread
From: Jason Xing @ 2018-12-05 13:43 UTC (permalink / raw)
  To: ltp

The original code returns TFAIL when process_vm_readv/_writev syscalls
do not exist, while we are expecting a TCONF. During investigation, we
find it is due to '#if defined(__NR_process_vm_readv/_writev)' fails to
work as expected.  We fix this issue by using ltp_syscall() function in
setup function. BTW, we don't use new tst_syscall() interface due to
compatibility issue exists between old apis and new ones.

Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
Signed-off-by: Caspar Zhang <caspar@linux.alibaba.com>
---
 testcases/kernel/syscalls/cma/process_vm.h         | 62 ----------------------
 testcases/kernel/syscalls/cma/process_vm01.c       | 30 ++++-------
 testcases/kernel/syscalls/cma/process_vm_readv02.c | 12 ++---
 testcases/kernel/syscalls/cma/process_vm_readv03.c | 14 ++---
 .../kernel/syscalls/cma/process_vm_writev02.c      | 12 ++---
 5 files changed, 30 insertions(+), 100 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/cma/process_vm.h

diff --git a/testcases/kernel/syscalls/cma/process_vm.h b/testcases/kernel/syscalls/cma/process_vm.h
deleted file mode 100644
index 1ecf325..0000000
--- a/testcases/kernel/syscalls/cma/process_vm.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2012 Linux Test Project, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it
- * is free of the rightful claim of any third person regarding
- * infringement or the like.  Any license provided herein, whether
- * implied or otherwise, applies only to this software file.  Patent
- * licenses, if any, provided herein do not apply to combinations of
- * this program with other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-#ifndef _PROCESS_VM_H_
-#define _PROCESS_VM_H_
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-#include <sys/syscall.h>
-#include <sys/uio.h>
-#include <unistd.h>
-#include "lapi/semun.h"
-
-static inline ssize_t test_process_vm_readv(pid_t pid,
-		const struct iovec *lvec, unsigned long liovcnt,
-		const struct iovec *rvec, unsigned long riovcnt,
-		unsigned long flags)
-{
-#if defined(__NR_process_vm_readv)
-	return syscall(__NR_process_vm_readv, pid, lvec, liovcnt,
-			rvec, riovcnt, flags);
-#else
-	return syscall(-1);
-#endif
-}
-
-static inline ssize_t test_process_vm_writev(pid_t pid,
-		const struct iovec *lvec, unsigned long liovcnt,
-		const struct iovec *rvec, unsigned long riovcnt,
-		unsigned long flags)
-{
-#if defined(__NR_process_vm_writev)
-	return syscall(__NR_process_vm_writev, pid, lvec, liovcnt,
-			rvec, riovcnt, flags);
-#else
-	return syscall(-1);
-#endif
-}
-
-#endif /* _PROCESS_VM_H_ */
diff --git a/testcases/kernel/syscalls/cma/process_vm01.c b/testcases/kernel/syscalls/cma/process_vm01.c
index bc6b04f..f9bd865 100644
--- a/testcases/kernel/syscalls/cma/process_vm01.c
+++ b/testcases/kernel/syscalls/cma/process_vm01.c
@@ -42,7 +42,7 @@
 #include "config.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "process_vm.h"
+#include "lapi/syscalls.h"
 
 struct process_vm_params {
 	int len;
@@ -103,20 +103,10 @@ static void setup(char *argv[])
 			 " at the same time.");
 	else if (rflag) {
 		TCID = TCID_readv;
-#if defined(__NR_process_vm_readv)
 		cma_test_params = cma_test_params_read;
-#else
-		tst_brkm(TCONF, NULL, "process_vm_readv does not"
-			 " exist on your system.");
-#endif
 	} else if (wflag) {
 		TCID = TCID_writev;
-#if defined(__NR_process_vm_writev)
 		cma_test_params = cma_test_params_write;
-#else
-		tst_brkm(TCONF, NULL, "process_vm_writev does not"
-			 " exist on your system.");
-#endif
 	} else
 		tst_brkm(TBROK, NULL, "Parameter missing, required -r or -w.");
 	TEST_PAUSE;
@@ -134,18 +124,20 @@ static void help(void)
 
 static void cma_test_params_read(struct process_vm_params *params)
 {
-	TEST(test_process_vm_readv(params->pid,
-				   params->lvec, params->liovcnt,
-				   params->rvec, params->riovcnt,
-				   params->flags));
+	TEST(ltp_syscall(__NR_process_vm_readv,
+			 params->pid,
+			 params->lvec, params->liovcnt,
+			 params->rvec, params->riovcnt,
+			 params->flags));
 }
 
 static void cma_test_params_write(struct process_vm_params *params)
 {
-	TEST(test_process_vm_writev(params->pid,
-				    params->lvec, params->liovcnt,
-				    params->rvec, params->riovcnt,
-				    params->flags));
+	TEST(ltp_syscall(__NR_process_vm_writev,
+			 params->pid,
+			 params->lvec, params->liovcnt,
+			 params->rvec, params->riovcnt,
+			 params->flags));
 }
 
 static int cma_check_ret(long expected_ret, long act_ret)
diff --git a/testcases/kernel/syscalls/cma/process_vm_readv02.c b/testcases/kernel/syscalls/cma/process_vm_readv02.c
index ef9b7e1..e1fc32a 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv02.c
@@ -29,7 +29,7 @@
 
 #include "test.h"
 #include "safe_macros.h"
-#include "process_vm.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "process_vm_readv02";
 int TST_TOTAL = 1;
@@ -134,7 +134,8 @@ static void child_invoke(void)
 	remote.iov_len = len;
 
 	tst_resm(TINFO, "child 1: reading string from same memory location.");
-	TEST(test_process_vm_readv(pids[0], &local, 1, &remote, 1, 0));
+	TEST(ltp_syscall(__NR_process_vm_readv, pids[0],
+			 &local, 1, &remote, 1, 0));
 	if (TEST_RETURN != len)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 	if (strncmp(lp, tst_string, len) != 0)
@@ -148,10 +149,9 @@ static void setup(void)
 {
 	tst_require_root();
 
-#if !defined(__NR_process_vm_readv)
-	tst_brkm(TCONF, NULL, "process_vm_readv does not exist "
-		 "on your system");
-#endif
+	/* Just a sanity check of the existence of syscall */
+	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0);
+
 	tst_tmpdir();
 	TST_CHECKPOINT_INIT(cleanup);
 
diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c b/testcases/kernel/syscalls/cma/process_vm_readv03.c
index 8b8dfc3..45f7c92 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
@@ -32,7 +32,7 @@
 
 #include "test.h"
 #include "safe_macros.h"
-#include "process_vm.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "process_vm_readv03";
 int TST_TOTAL = 1;
@@ -180,7 +180,8 @@ static long *fetch_remote_addrs(void)
 	remote.iov_base = foo;
 	remote.iov_len = len;
 
-	TEST(test_process_vm_readv(pids[0], &local, 1, &remote, 1, 0));
+	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
+			 1, &remote, 1, 0));
 	if (TEST_RETURN != len)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 
@@ -212,7 +213,7 @@ static void child_invoke(int *bufsz_arr)
 	tst_resm(TINFO, "child 1: %d local iovecs initialized.",
 		 NUM_LOCAL_VECS);
 
-	TEST(test_process_vm_readv(pids[0], local, NUM_LOCAL_VECS,
+	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local, NUM_LOCAL_VECS,
 				   remote, nr_iovecs, 0));
 	if (TEST_RETURN != bufsz)
 		tst_brkm(TBROK | TERRNO, tst_exit, "process_vm_readv");
@@ -246,14 +247,13 @@ static void setup(void)
 {
 	tst_require_root();
 
+	/* Just a sanity check of the existence of syscall */
+	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0);
+
 	nr_iovecs = nflag ? SAFE_STRTOL(NULL, nr_opt, 1, IOV_MAX) : 10;
 	bufsz = sflag ? SAFE_STRTOL(NULL, sz_opt, NUM_LOCAL_VECS, LONG_MAX)
 	    : 100000;
 
-#if !defined(__NR_process_vm_readv)
-	tst_brkm(TCONF, NULL, "process_vm_readv does not exist "
-		 "on your system");
-#endif
 	tst_tmpdir();
 	TST_CHECKPOINT_INIT(cleanup);
 	srand(time(NULL));
diff --git a/testcases/kernel/syscalls/cma/process_vm_writev02.c b/testcases/kernel/syscalls/cma/process_vm_writev02.c
index b707760..b1edba5 100644
--- a/testcases/kernel/syscalls/cma/process_vm_writev02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_writev02.c
@@ -30,7 +30,7 @@
 
 #include "test.h"
 #include "safe_macros.h"
-#include "process_vm.h"
+#include "lapi/syscalls.h"
 
 char *TCID = "process_vm_writev02";
 int TST_TOTAL = 1;
@@ -171,7 +171,8 @@ static void child_write(void)
 	remote.iov_len = bufsz;
 
 	tst_resm(TINFO, "child 2: write to the same memory location.");
-	TEST(test_process_vm_writev(pids[0], &local, 1, &remote, 1, 0));
+	TEST(ltp_syscall(__NR_process_vm_writev, pids[0], &local,
+			 1, &remote, 1, 0));
 	if (TEST_RETURN != bufsz)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 }
@@ -180,14 +181,13 @@ static void setup(void)
 {
 	tst_require_root();
 
+	/* Just a sanity check of the existence of syscall */
+	ltp_syscall(__NR_process_vm_writev, getpid(), NULL, 0, NULL, 0, 0);
+
 	bufsz =
 	    sflag ? SAFE_STRTOL(NULL, sz_opt, 1, LONG_MAX - PADDING_SIZE * 2)
 	    : 100000;
 
-#if !defined(__NR_process_vm_readv)
-	tst_brkm(TCONF, NULL, "process_vm_writev does not exist "
-		 "on your system");
-#endif
 	tst_tmpdir();
 	TST_CHECKPOINT_INIT(cleanup);
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 2/2] lapi/syscalls: Add syscall numbers for process_vm_readv/_writev
  2018-12-05 13:43       ` [LTP] [PATCH v2 1/2] " Jason Xing
@ 2018-12-05 13:43         ` Jason Xing
  2018-12-05 22:07           ` Petr Vorel
  2019-02-15 10:50         ` [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist Li Wang
  1 sibling, 1 reply; 23+ messages in thread
From: Jason Xing @ 2018-12-05 13:43 UTC (permalink / raw)
  To: ltp

Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
Signed-off-by: Caspar Zhang <caspar@linux.alibaba.com>
---
 include/lapi/syscalls/aarch64.in   | 2 ++
 include/lapi/syscalls/arm.in       | 2 ++
 include/lapi/syscalls/hppa.in      | 2 ++
 include/lapi/syscalls/i386.in      | 2 ++
 include/lapi/syscalls/ia64.in      | 2 ++
 include/lapi/syscalls/powerpc.in   | 2 ++
 include/lapi/syscalls/powerpc64.in | 2 ++
 include/lapi/syscalls/s390.in      | 2 ++
 include/lapi/syscalls/s390x.in     | 2 ++
 include/lapi/syscalls/sh.in        | 2 ++
 include/lapi/syscalls/sparc.in     | 2 ++
 include/lapi/syscalls/sparc64.in   | 2 ++
 include/lapi/syscalls/x86_64.in    | 2 ++
 13 files changed, 26 insertions(+)

diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/aarch64.in
index c7ed2fe..bf04895 100644
--- a/include/lapi/syscalls/aarch64.in
+++ b/include/lapi/syscalls/aarch64.in
@@ -253,6 +253,8 @@ clock_adjtime 266
 syncfs 267
 setns 268
 sendmmsg 269
+process_vm_readv 270
+process_vm_writev 271
 kcmp 272
 getrandom 278
 memfd_create 279
diff --git a/include/lapi/syscalls/arm.in b/include/lapi/syscalls/arm.in
index e63d15b..38de1d5 100644
--- a/include/lapi/syscalls/arm.in
+++ b/include/lapi/syscalls/arm.in
@@ -334,6 +334,8 @@ accept4 (__NR_SYSCALL_BASE+366)
 fanotify_init (__NR_SYSCALL_BASE+367)
 fanotify_mark (__NR_SYSCALL_BASE+368)
 prlimit64 (__NR_SYSCALL_BASE+369)
+process_vm_readv(__NR_SYSCALL_BASE+376)
+process_vm_writev(__NR_SYSCALL_BASE+377)
 kcmp (__NR_SYSCALL_BASE+378)
 sched_setattr (__NR_SYSCALL_BASE+380)
 sched_getattr (__NR_SYSCALL_BASE+381)
diff --git a/include/lapi/syscalls/hppa.in b/include/lapi/syscalls/hppa.in
index 56e89ba..182d393 100644
--- a/include/lapi/syscalls/hppa.in
+++ b/include/lapi/syscalls/hppa.in
@@ -16,6 +16,8 @@ faccessat (__NR_openat + 12)
 splice 291
 tee 293
 vmsplice 294
+process_vm_readv 330
+process_vm_writev 331
 memfd_create 340
 membarrier 343
 execveat 342
diff --git a/include/lapi/syscalls/i386.in b/include/lapi/syscalls/i386.in
index ad14b36..2fb0188 100644
--- a/include/lapi/syscalls/i386.in
+++ b/include/lapi/syscalls/i386.in
@@ -332,6 +332,8 @@ recvmmsg 337
 fanotify_init 338
 fanotify_mark 339
 prlimit64 340
+process_vm_readv 347
+process_vm_writev 348
 kcmp 349
 sched_setattr 351
 sched_getattr 352
diff --git a/include/lapi/syscalls/ia64.in b/include/lapi/syscalls/ia64.in
index 828765f..081c9ed 100644
--- a/include/lapi/syscalls/ia64.in
+++ b/include/lapi/syscalls/ia64.in
@@ -293,6 +293,8 @@ recvmmsg 1322
 fanotify_init 1323
 fanotify_mark 1324
 prlimit64 1325
+process_vm_readv 1332
+process_vm_writev 1333
 renameat2 1338
 getrandom 1339
 memfd_create 1340
diff --git a/include/lapi/syscalls/powerpc.in b/include/lapi/syscalls/powerpc.in
index 6176116..d16f9f9 100644
--- a/include/lapi/syscalls/powerpc.in
+++ b/include/lapi/syscalls/powerpc.in
@@ -339,6 +339,8 @@ recvmsg 342
 recvmmsg 343
 accept4 344
 syscalls 345
+process_vm_readv  351
+process_vm_writev 352
 kcmp 354
 sched_setattr 355
 sched_getattr 356
diff --git a/include/lapi/syscalls/powerpc64.in b/include/lapi/syscalls/powerpc64.in
index 6176116..d16f9f9 100644
--- a/include/lapi/syscalls/powerpc64.in
+++ b/include/lapi/syscalls/powerpc64.in
@@ -339,6 +339,8 @@ recvmsg 342
 recvmmsg 343
 accept4 344
 syscalls 345
+process_vm_readv  351
+process_vm_writev 352
 kcmp 354
 sched_setattr 355
 sched_getattr 356
diff --git a/include/lapi/syscalls/s390.in b/include/lapi/syscalls/s390.in
index fa70d73..4019438 100644
--- a/include/lapi/syscalls/s390.in
+++ b/include/lapi/syscalls/s390.in
@@ -323,6 +323,8 @@ setgid 214
 setfsuid 215
 setfsgid 216
 newfstatat 293
+process_vm_readv 340
+process_vm_writev 341
 kcmp 343
 sched_setattr 345
 sched_getattr 346
diff --git a/include/lapi/syscalls/s390x.in b/include/lapi/syscalls/s390x.in
index fa70d73..4019438 100644
--- a/include/lapi/syscalls/s390x.in
+++ b/include/lapi/syscalls/s390x.in
@@ -323,6 +323,8 @@ setgid 214
 setfsuid 215
 setfsgid 216
 newfstatat 293
+process_vm_readv 340
+process_vm_writev 341
 kcmp 343
 sched_setattr 345
 sched_getattr 346
diff --git a/include/lapi/syscalls/sh.in b/include/lapi/syscalls/sh.in
index f8ae691..8520bb1 100644
--- a/include/lapi/syscalls/sh.in
+++ b/include/lapi/syscalls/sh.in
@@ -360,6 +360,8 @@ accept4 366
 fanotify_init 367
 fanotify_mark 368
 prlimit64 369
+process_vm_readv 376
+process_vm_writev 377
 kcmp 378
 memfd_create 385
 execveat 387
diff --git a/include/lapi/syscalls/sparc.in b/include/lapi/syscalls/sparc.in
index 7d05da2..b7bb135 100644
--- a/include/lapi/syscalls/sparc.in
+++ b/include/lapi/syscalls/sparc.in
@@ -330,6 +330,8 @@ recvmmsg 328
 fanotify_init 329
 fanotify_mark 330
 prlimit64 331
+process_vm_readv 338
+process_vm_writev 339
 kcmp 341
 renameat2 345
 getrandom 347
diff --git a/include/lapi/syscalls/sparc64.in b/include/lapi/syscalls/sparc64.in
index fb305c3..a211df8 100644
--- a/include/lapi/syscalls/sparc64.in
+++ b/include/lapi/syscalls/sparc64.in
@@ -306,6 +306,8 @@ recvmmsg 328
 fanotify_init 329
 fanotify_mark 330
 prlimit64 331
+process_vm_readv 338
+process_vm_writev 339
 kcmp 341
 renameat2 345
 getrandom 347
diff --git a/include/lapi/syscalls/x86_64.in b/include/lapi/syscalls/x86_64.in
index 9504dc5..dae5769 100644
--- a/include/lapi/syscalls/x86_64.in
+++ b/include/lapi/syscalls/x86_64.in
@@ -299,6 +299,8 @@ recvmmsg 299
 fanotify_init 300
 fanotify_mark 301
 prlimit64 302
+process_vm_readv 310
+process_vm_writev 311
 kcmp 312
 sched_setattr 314
 sched_getattr 315
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 2/2] lapi/syscalls: Add syscall numbers for process_vm_readv/_writev
  2018-12-05 13:43         ` [LTP] [PATCH v2 2/2] lapi/syscalls: Add syscall numbers for process_vm_readv/_writev Jason Xing
@ 2018-12-05 22:07           ` Petr Vorel
  2018-12-06  3:37             ` Jason Xing
  0 siblings, 1 reply; 23+ messages in thread
From: Petr Vorel @ 2018-12-05 22:07 UTC (permalink / raw)
  To: ltp

Hi Jason,

> Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
> Signed-off-by: Caspar Zhang <caspar@linux.alibaba.com>
> ---

...
> diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/aarch64.in
> index c7ed2fe..bf04895 100644
> --- a/include/lapi/syscalls/aarch64.in
> +++ b/include/lapi/syscalls/aarch64.in
> --- a/include/lapi/syscalls/arm.in
> +++ b/include/lapi/syscalls/arm.in
> @@ -334,6 +334,8 @@ accept4 (__NR_SYSCALL_BASE+366)
>  fanotify_init (__NR_SYSCALL_BASE+367)
>  fanotify_mark (__NR_SYSCALL_BASE+368)
>  prlimit64 (__NR_SYSCALL_BASE+369)
> +process_vm_readv(__NR_SYSCALL_BASE+376)
> +process_vm_writev(__NR_SYSCALL_BASE+377)
This triggered error during generation headers:
invalid line found: process_vm_readv(__NR_SYSCALL_BASE+376)
(reproducible by: cd $l/include/lapi/syscalls; ./regen.sh)

and thus build error:
../../../../include/lapi/syscalls.h:13: error: unterminated #ifndef
 #ifndef __LAPI_SYSCALLS_H__

I fixed it by adding space:

-process_vm_readv(__NR_SYSCALL_BASE+376)
-process_vm_writev(__NR_SYSCALL_BASE+377)
+process_vm_readv (__NR_SYSCALL_BASE+376)
+process_vm_writev (__NR_SYSCALL_BASE+377)

+ put this commit first and pushed.

Thanks for your patches.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 2/2] lapi/syscalls: Add syscall numbers for process_vm_readv/_writev
  2018-12-05 22:07           ` Petr Vorel
@ 2018-12-06  3:37             ` Jason Xing
  0 siblings, 0 replies; 23+ messages in thread
From: Jason Xing @ 2018-12-06  3:37 UTC (permalink / raw)
  To: ltp



On 2018/12/6 上午6:07, Petr Vorel wrote:
> Hi Jason,
>
>> Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
>> Signed-off-by: Caspar Zhang <caspar@linux.alibaba.com>
>> ---
>
> ...
>> diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/aarch64.in
>> index c7ed2fe..bf04895 100644
>> --- a/include/lapi/syscalls/aarch64.in
>> +++ b/include/lapi/syscalls/aarch64.in
>> --- a/include/lapi/syscalls/arm.in
>> +++ b/include/lapi/syscalls/arm.in
>> @@ -334,6 +334,8 @@ accept4 (__NR_SYSCALL_BASE+366)
>>   fanotify_init (__NR_SYSCALL_BASE+367)
>>   fanotify_mark (__NR_SYSCALL_BASE+368)
>>   prlimit64 (__NR_SYSCALL_BASE+369)
>> +process_vm_readv(__NR_SYSCALL_BASE+376)
>> +process_vm_writev(__NR_SYSCALL_BASE+377)
> This triggered error during generation headers:
> invalid line found: process_vm_readv(__NR_SYSCALL_BASE+376)
> (reproducible by: cd $l/include/lapi/syscalls; ./regen.sh)
>
> and thus build error:
> ../../../../include/lapi/syscalls.h:13: error: unterminated #ifndef
>   #ifndef __LAPI_SYSCALLS_H__
>
> I fixed it by adding space:
>
> -process_vm_readv(__NR_SYSCALL_BASE+376)
> -process_vm_writev(__NR_SYSCALL_BASE+377)
> +process_vm_readv (__NR_SYSCALL_BASE+376)
> +process_vm_writev (__NR_SYSCALL_BASE+377)
>
> + put this commit first and pushed.

Thanks for your instructions.

>
> Thanks for your patches.
>
> Kind regards,
> Petr
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist
  2018-12-05 13:43       ` [LTP] [PATCH v2 1/2] " Jason Xing
  2018-12-05 13:43         ` [LTP] [PATCH v2 2/2] lapi/syscalls: Add syscall numbers for process_vm_readv/_writev Jason Xing
@ 2019-02-15 10:50         ` Li Wang
  2019-02-15 13:53           ` Jan Stancek
  1 sibling, 1 reply; 23+ messages in thread
From: Li Wang @ 2019-02-15 10:50 UTC (permalink / raw)
  To: ltp

Hi Jason,

A new failure was occured after applying this new patch.

From our observation, the latest process_vm_readv03.c failed with
process_vm_readv() Invalid argument error on rhel7.3 platfrom. We suspect
that this problem maybe caused by glibc or compiler, because if compile the
test program with -O0 it get pass, but with the ltp
default optimization -O2 it get fail.  Also, if we revert this new patch,
the test PASS whatever with -O2 and -O0, that's very strange.

--------------------------------
# gcc -g -O2 -g -O2   -fno-strict-aliasing -pipe -Wall -W
-Wold-style-definition -D_FORTIFY_SOURCE=2 -I../../../../include
-I../../../../include -I../../../../include/old/   -L../../../../lib
process_vm_readv03.c   -lltp -o process_vm_readv03_O2

# ./process_vm_readv03_O2
process_vm_readv03    0  TINFO  :  child 0: 10 iovecs allocated and
initialized.
process_vm_readv03    0  TINFO  :  child 1: 10 remote iovecs received.
process_vm_readv03    0  TINFO  :  child 1: 4 local iovecs initialized.
process_vm_readv03    1  TBROK  :  process_vm_readv03.c:220:
process_vm_readv: errno=EINVAL(22): Invalid argument
process_vm_readv03    2  TBROK  :  process_vm_readv03.c:220: Remaining
cases broken
process_vm_readv03    1  TFAIL  :  process_vm_readv03.c:103: child 1
returns 512

# strace -f ./process_vm_readv03_O2
...
[pid 14676] process_vm_readv(14675, 0x7ffe40232ea0, 4, 0x7640c0, 10,
140728898420736) = -1 EINVAL (Invalid argument)
[pid 14676] write(1, "process_vm_readv03    1  \33[1;31m"...,
125process_vm_readv03    1  TBROK  :  process_vm_readv03.c:220:
process_vm_readv: errno=EINVAL(22): Invalid argument
) = 125
...

--------------------------------------------
# gcc -g -O0 -g -O0   -fno-strict-aliasing -pipe -Wall -W
-Wold-style-definition -D_FORTIFY_SOURCE=2 -I../../../../include
-I../../../../include -I../../../../include/old/   -L../../../../lib
process_vm_readv03.c   -lltp -o process_vm_readv03_O0

# ./process_vm_readv03_O0
process_vm_readv03    0  TINFO  :  child 0: 10 iovecs allocated and
initialized.
process_vm_readv03    0  TINFO  :  child 1: 10 remote iovecs received.
process_vm_readv03    0  TINFO  :  child 1: 4 local iovecs initialized.
process_vm_readv03    1  TPASS  :  child 1: all bytes are correctly
received.

# strace -f ./process_vm_readv03_O0
...
[pid 14703] process_vm_readv(14702,
[{"\0\1\2\3\4\5\6\7\10\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37"...,
43269},
{"\5\6\7\10\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37
!\"#$"..., 18907},
{"\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"...,
3203}, {"cdefghijklmnopqrstuvwxyz{|}~\177\200\201\202"..., 34621}], 4,
[{0x9570c0, 24638}, {0x95d110, 35640}, {0x965c50, 19802}, {0x96a9c0, 490},
{0x96abc0, 8624}, {0x96cd80, 3571}, {0x96db80, 2114}, {0x96e3d0, 2374},
{0x96ed20, 1139}, {0x96f1a0, 1608}], 10, 0) = 100000
[pid 14703] write(1, "process_vm_readv03    1  \33[1;32m"...,
89process_vm_readv03    1  TPASS  :  child 1: all bytes are correctly
received.
) = 89
...

# uname  -r
3.10.0-514.55.4.el7.x86_64

# rpm -q glibc
glibc-2.17-157.el7_3.5.x86_64

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190215/02b113eb/attachment-0001.html>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist
  2019-02-15 10:50         ` [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist Li Wang
@ 2019-02-15 13:53           ` Jan Stancek
  2019-02-16  7:18             ` Li Wang
  0 siblings, 1 reply; 23+ messages in thread
From: Jan Stancek @ 2019-02-15 13:53 UTC (permalink / raw)
  To: ltp

----- Original Message -----

> Hi Jason,

> A new failure was occured after applying this new patch.

> From our observation, the latest process_vm_readv03.c failed with
> process_vm_readv() Invalid argument error on rhel7.3 platfrom. We suspect
> that this problem maybe caused by glibc or compiler, because if compile the
> test program with -O0 it get pass, but with the ltp default optimization -O2
> it get fail. Also, if we revert this new patch, the test PASS whatever with
> -O2 and -O0, that's very strange.

One difference is that the extra function promoted int to long. 
Can you try with patch below? (Note that I dropped also root requirement, man page 
says that it has same requirements as ptrace - you should be able to read from processes you own) 

Regards, 
Jan 

diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c b/testcases/kernel/syscalls/cma/process_vm_readv03.c 
index 45f7c92e499c..1cec442b3456 100644 
--- a/testcases/kernel/syscalls/cma/process_vm_readv03.c 
+++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c 
@@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void) 
remote.iov_len = len; 

TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local, 
- 1, &remote, 1, 0)); 
+ 1, &remote, 1, 0L)); 
if (TEST_RETURN != len) 
tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv"); 

@@ -214,7 +214,7 @@ static void child_invoke(int *bufsz_arr) 
NUM_LOCAL_VECS); 

TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local, NUM_LOCAL_VECS, 
- remote, nr_iovecs, 0)); 
+ remote, nr_iovecs, 0L)); 
if (TEST_RETURN != bufsz) 
tst_brkm(TBROK | TERRNO, tst_exit, "process_vm_readv"); 

@@ -245,10 +245,8 @@ static void child_invoke(int *bufsz_arr) 

static void setup(void) 
{ 
- tst_require_root(); 
- 
/* Just a sanity check of the existence of syscall */ 
- ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0); 
+ ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0L); 

nr_iovecs = nflag ? SAFE_STRTOL(NULL, nr_opt, 1, IOV_MAX) : 10; 
bufsz = sflag ? SAFE_STRTOL(NULL, sz_opt, NUM_LOCAL_VECS, LONG_MAX) 

> --------------------------------
> # gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W
> -Wold-style-definition -D_FORTIFY_SOURCE=2 -I../../../../include
> -I../../../../include -I../../../../include/old/ -L../../../../lib
> process_vm_readv03.c -lltp -o process_vm_readv03_O2

> # ./process_vm_readv03_O2
> process_vm_readv03 0 TINFO : child 0: 10 iovecs allocated and initialized.
> process_vm_readv03 0 TINFO : child 1: 10 remote iovecs received.
> process_vm_readv03 0 TINFO : child 1: 4 local iovecs initialized.
> process_vm_readv03 1 TBROK : process_vm_readv03.c:220: process_vm_readv:
> errno=EINVAL(22): Invalid argument
> process_vm_readv03 2 TBROK : process_vm_readv03.c:220: Remaining cases broken
> process_vm_readv03 1 TFAIL : process_vm_readv03.c:103: child 1 returns 512

> # strace -f ./process_vm_readv03_O2
> ...
> [pid 14676] process_vm_readv(14675, 0x7ffe40232ea0, 4, 0x7640c0, 10,
> 140728898420736) = -1 EINVAL (Invalid argument)
> [pid 14676] write(1, "process_vm_readv03 1 \33[1;31m"...,
> 125process_vm_readv03 1 TBROK : process_vm_readv03.c:220: process_vm_readv:
> errno=EINVAL(22): Invalid argument
> ) = 125
> ...

> --------------------------------------------
> # gcc -g -O0 -g -O0 -fno-strict-aliasing -pipe -Wall -W
> -Wold-style-definition -D_FORTIFY_SOURCE=2 -I../../../../include
> -I../../../../include -I../../../../include/old/ -L../../../../lib
> process_vm_readv03.c -lltp -o process_vm_readv03_O0

> # ./process_vm_readv03_O0
> process_vm_readv03 0 TINFO : child 0: 10 iovecs allocated and initialized.
> process_vm_readv03 0 TINFO : child 1: 10 remote iovecs received.
> process_vm_readv03 0 TINFO : child 1: 4 local iovecs initialized.
> process_vm_readv03 1 TPASS : child 1: all bytes are correctly received.

> # strace -f ./process_vm_readv03_O0
> ...
> [pid 14703] process_vm_readv(14702,
> [{"\0\1\2\3\4\5\6\7\10\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37"...,
> 43269},
> {"\5\6\7\10\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37
> !\"#$"..., 18907},
> {"\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"...,
> 3203}, {"cdefghijklmnopqrstuvwxyz{|}~\177\200\201\202"..., 34621}], 4,
> [{0x9570c0, 24638}, {0x95d110, 35640}, {0x965c50, 19802}, {0x96a9c0, 490},
> {0x96abc0, 8624}, {0x96cd80, 3571}, {0x96db80, 2114}, {0x96e3d0, 2374},
> {0x96ed20, 1139}, {0x96f1a0, 1608}], 10, 0) = 100000
> [pid 14703] write(1, "process_vm_readv03 1 \33[1;32m"...,
> 89process_vm_readv03 1 TPASS : child 1: all bytes are correctly received.
> ) = 89
> ...

> # uname -r
> 3.10.0-514.55.4.el7.x86_64

> # rpm -q glibc
> glibc-2.17-157.el7_3.5.x86_64

> --
> Regards,
> Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190215/21715672/attachment.html>

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist
  2019-02-15 13:53           ` Jan Stancek
@ 2019-02-16  7:18             ` Li Wang
  2019-02-16 10:28               ` Jan Stancek
  0 siblings, 1 reply; 23+ messages in thread
From: Li Wang @ 2019-02-16  7:18 UTC (permalink / raw)
  To: ltp

On Fri, Feb 15, 2019 at 9:53 PM Jan Stancek <jstancek@redhat.com> wrote:

>
>
> ------------------------------
>
> Hi Jason,
>
> A new failure was occured after applying this new patch.
>
> From our observation, the latest process_vm_readv03.c failed with
> process_vm_readv() Invalid argument error on rhel7.3 platfrom. We suspect
> that this problem maybe caused by glibc or compiler, because if compile the
> test program with -O0 it get pass, but with the ltp
> default optimization -O2 it get fail.  Also, if we revert this new patch,
> the test PASS whatever with -O2 and -O0, that's very strange.
>
>
> One difference is that the extra function promoted int to long.
>

Good catch.

> Can you try with patch below? (Note that I dropped also root requirement,
> man page
> says that it has same requirements as ptrace - you should be able to read
> from processes you own)
>
> This change works for me(one comment in below).

But there still have a tiny question, in the syscall tracing log, I noticed
a process_vm_readv() calling does not get this failure in function
fetch_remote_addrs, what makes it difference with other two calls is
something I'm thinking now.

====Tracing log without '0L' change====
12211 process_vm_readv(12211, 0, 0, 0, 0, 140728898420736) = -1 EINVAL
(Invalid argument)
...
12213 process_vm_readv(12212,
[{"\300`\334\0\0\0\0\0`\2\335\0\0\0\0\0\340\26\335\0\0\0\0\0\220h\335\0\0\0\0\0"...,
80}], 1, [{0xdc6060, 80}], 1, 0) = 80
...
12213 process_vm_readv(12212, 0x7ffecef1e330, 4, 0xdc60c0, 10,
140728898420736) = -1 EINVAL (Invalid argument)



>
> diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> index 45f7c92e499c..1cec442b3456 100644
> --- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> +++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> @@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void)
>         remote.iov_len = len;
>
>         TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
> -                        1, &remote, 1, 0));
> +                        1, &remote, 1, 0L));
>

To make things more safely, probably we'd better change all the integer
parameter too?

-                        1, &remote, 1, 0));
+                        1L, &remote, 1L, 0L));

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190216/ba233afa/attachment-0001.html>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist
  2019-02-16  7:18             ` Li Wang
@ 2019-02-16 10:28               ` Jan Stancek
  2019-02-22 18:29                 ` Jan Stancek
  0 siblings, 1 reply; 23+ messages in thread
From: Jan Stancek @ 2019-02-16 10:28 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> On Fri, Feb 15, 2019 at 9:53 PM Jan Stancek <jstancek@redhat.com> wrote:
> 
> >
> >
> > ------------------------------
> >
> > Hi Jason,
> >
> > A new failure was occured after applying this new patch.
> >
> > From our observation, the latest process_vm_readv03.c failed with
> > process_vm_readv() Invalid argument error on rhel7.3 platfrom. We suspect
> > that this problem maybe caused by glibc or compiler, because if compile the
> > test program with -O0 it get pass, but with the ltp
> > default optimization -O2 it get fail.  Also, if we revert this new patch,
> > the test PASS whatever with -O2 and -O0, that's very strange.
> >
> >
> > One difference is that the extra function promoted int to long.
> >
> 
> Good catch.
> 
> > Can you try with patch below? (Note that I dropped also root requirement,
> > man page
> > says that it has same requirements as ptrace - you should be able to read
> > from processes you own)
> >
> > This change works for me(one comment in below).
> 
> But there still have a tiny question, in the syscall tracing log, I noticed
> a process_vm_readv() calling does not get this failure in function
> fetch_remote_addrs, what makes it difference with other two calls is
> something I'm thinking now.

"Garbage" on stack most likely. On x86_64, 6th parameter is passed
via stack, glibc copies quadword:

ENTRY (syscall)
        movq %rdi, %rax         /* Syscall number -> rax.  */
        movq %rsi, %rdi         /* shift arg1 - arg5.  */
        movq %rdx, %rsi
        movq %rcx, %rdx
        movq %r8, %r10
        movq %r9, %r8
        movq 8(%rsp),%r9        /* arg6 is on the stack.  */
        syscall                 /* Do the system call.  */

> 
> ====Tracing log without '0L' change====
> 12211 process_vm_readv(12211, 0, 0, 0, 0, 140728898420736) = -1 EINVAL
> (Invalid argument)
> ...
> 12213 process_vm_readv(12212,
> [{"\300`\334\0\0\0\0\0`\2\335\0\0\0\0\0\340\26\335\0\0\0\0\0\220h\335\0\0\0\0\0"...,
> 80}], 1, [{0xdc6060, 80}], 1, 0) = 80
> ...
> 12213 process_vm_readv(12212, 0x7ffecef1e330, 4, 0xdc60c0, 10,
> 140728898420736) = -1 EINVAL (Invalid argument)
> 
> 
> 
> >
> > diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > index 45f7c92e499c..1cec442b3456 100644
> > --- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > +++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > @@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void)
> >         remote.iov_len = len;
> >
> >         TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
> > -                        1, &remote, 1, 0));
> > +                        1, &remote, 1, 0L));
> >
> 
> To make things more safely, probably we'd better change all the integer
> parameter too?
> 
> -                        1, &remote, 1, 0));
> +                        1L, &remote, 1L, 0L));

Agreed, let's match all parameters types as before commit:
 9b02cd465f70 ("syscalls/cma: test case should return TCONF if syscall doesn't exist")

> 
> --
> Regards,
> Li Wang
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist
  2019-02-16 10:28               ` Jan Stancek
@ 2019-02-22 18:29                 ` Jan Stancek
  2019-02-23  6:21                   ` Caspar Zhang
  0 siblings, 1 reply; 23+ messages in thread
From: Jan Stancek @ 2019-02-22 18:29 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> 
> 
> ----- Original Message -----
> > On Fri, Feb 15, 2019 at 9:53 PM Jan Stancek <jstancek@redhat.com> wrote:
> > 
> > >
> > >
> > > ------------------------------
> > >
> > > Hi Jason,
> > >
> > > A new failure was occured after applying this new patch.
> > >
> > > From our observation, the latest process_vm_readv03.c failed with
> > > process_vm_readv() Invalid argument error on rhel7.3 platfrom. We suspect
> > > that this problem maybe caused by glibc or compiler, because if compile
> > > the
> > > test program with -O0 it get pass, but with the ltp
> > > default optimization -O2 it get fail.  Also, if we revert this new patch,
> > > the test PASS whatever with -O2 and -O0, that's very strange.
> > >
> > >
> > > One difference is that the extra function promoted int to long.
> > >
> > 
> > Good catch.
> > 
> > > Can you try with patch below? (Note that I dropped also root requirement,
> > > man page
> > > says that it has same requirements as ptrace - you should be able to read
> > > from processes you own)
> > >
> > > This change works for me(one comment in below).
> > 
> > But there still have a tiny question, in the syscall tracing log, I noticed
> > a process_vm_readv() calling does not get this failure in function
> > fetch_remote_addrs, what makes it difference with other two calls is
> > something I'm thinking now.
> 
> "Garbage" on stack most likely. On x86_64, 6th parameter is passed
> via stack, glibc copies quadword:
> 
> ENTRY (syscall)
>         movq %rdi, %rax         /* Syscall number -> rax.  */
>         movq %rsi, %rdi         /* shift arg1 - arg5.  */
>         movq %rdx, %rsi
>         movq %rcx, %rdx
>         movq %r8, %r10
>         movq %r9, %r8
>         movq 8(%rsp),%r9        /* arg6 is on the stack.  */
>         syscall                 /* Do the system call.  */
> 
> > 
> > ====Tracing log without '0L' change====
> > 12211 process_vm_readv(12211, 0, 0, 0, 0, 140728898420736) = -1 EINVAL
> > (Invalid argument)
> > ...
> > 12213 process_vm_readv(12212,
> > [{"\300`\334\0\0\0\0\0`\2\335\0\0\0\0\0\340\26\335\0\0\0\0\0\220h\335\0\0\0\0\0"...,
> > 80}], 1, [{0xdc6060, 80}], 1, 0) = 80
> > ...
> > 12213 process_vm_readv(12212, 0x7ffecef1e330, 4, 0xdc60c0, 10,
> > 140728898420736) = -1 EINVAL (Invalid argument)
> > 
> > 
> > 
> > >
> > > diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > > b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > > index 45f7c92e499c..1cec442b3456 100644
> > > --- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > > +++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > > @@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void)
> > >         remote.iov_len = len;
> > >
> > >         TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
> > > -                        1, &remote, 1, 0));
> > > +                        1, &remote, 1, 0L));
> > >
> > 
> > To make things more safely, probably we'd better change all the integer
> > parameter too?
> > 
> > -                        1, &remote, 1, 0));
> > +                        1L, &remote, 1L, 0L));
> 
> Agreed, let's match all parameters types as before commit:
>  9b02cd465f70 ("syscalls/cma: test case should return TCONF if syscall
>  doesn't exist")

So, it looks like this thread has stalled. I'll look into posting a patch,
unless I hear someone is already working on it.

Regards,
Jan

> 
> > 
> > --
> > Regards,
> > Li Wang
> > 
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist
  2019-02-22 18:29                 ` Jan Stancek
@ 2019-02-23  6:21                   ` Caspar Zhang
  2019-02-25  8:22                     ` [LTP] [PATCH] syscalls/cma: fix the failure of compiling with O2 option Jason Xing
  0 siblings, 1 reply; 23+ messages in thread
From: Caspar Zhang @ 2019-02-23  6:21 UTC (permalink / raw)
  To: ltp

On Fri, Feb 22, 2019 at 01:29:27PM -0500, Jan Stancek wrote:
>
>
> ----- Original Message -----
[snip]
> > > > diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > > > b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > > > index 45f7c92e499c..1cec442b3456 100644
> > > > --- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > > > +++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> > > > @@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void)
> > > >         remote.iov_len = len;
> > > >
> > > >         TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
> > > > -                        1, &remote, 1, 0));
> > > > +                        1, &remote, 1, 0L));
> > > >
> > >
> > > To make things more safely, probably we'd better change all the integer
> > > parameter too?
> > >
> > > -                        1, &remote, 1, 0));
> > > +                        1L, &remote, 1L, 0L));
> >
> > Agreed, let's match all parameters types as before commit:
> >  9b02cd465f70 ("syscalls/cma: test case should return TCONF if syscall
> >  doesn't exist")
>
> So, it looks like this thread has stalled. I'll look into posting a patch,
> unless I hear someone is already working on it.

Hi Jan,

Jason told me he was looking into it, I'll double confirm with him about
the progress. Will update ASAP.

Thanks,
Caspar

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH] syscalls/cma: fix the failure of compiling with O2 option
  2019-02-23  6:21                   ` Caspar Zhang
@ 2019-02-25  8:22                     ` Jason Xing
  2019-02-25 10:34                       ` Li Wang
  2019-02-25 10:47                       ` Jan Stancek
  0 siblings, 2 replies; 23+ messages in thread
From: Jason Xing @ 2019-02-25  8:22 UTC (permalink / raw)
  To: ltp

This issue is triggered by the commit 9b02cd465f70 which I wrote. If
compile the process_vm_readv03.c with O2 option and run, it will return
TFAIL. By casting the int type to long type in the ltp_syscall calling
functions can we avoid this failure.

Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
---
 testcases/kernel/syscalls/cma/process_vm_readv03.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c b/testcases/kernel/syscalls/cma/process_vm_readv03.c
index 45f7c92..e15ffee 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
@@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void)
 	remote.iov_len = len;
 
 	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
-			 1, &remote, 1, 0));
+			 1L, &remote, 1L, 0L));
 	if (TEST_RETURN != len)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 
@@ -213,8 +213,8 @@ static void child_invoke(int *bufsz_arr)
 	tst_resm(TINFO, "child 1: %d local iovecs initialized.",
 		 NUM_LOCAL_VECS);
 
-	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local, NUM_LOCAL_VECS,
-				   remote, nr_iovecs, 0));
+	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local, (long)NUM_LOCAL_VECS,
+				   remote, (long)nr_iovecs, 0L));
 	if (TEST_RETURN != bufsz)
 		tst_brkm(TBROK | TERRNO, tst_exit, "process_vm_readv");
 
@@ -248,7 +248,7 @@ static void setup(void)
 	tst_require_root();
 
 	/* Just a sanity check of the existence of syscall */
-	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0);
+	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0L, NULL, 0L, 0L);
 
 	nr_iovecs = nflag ? SAFE_STRTOL(NULL, nr_opt, 1, IOV_MAX) : 10;
 	bufsz = sflag ? SAFE_STRTOL(NULL, sz_opt, NUM_LOCAL_VECS, LONG_MAX)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH] syscalls/cma: fix the failure of compiling with O2 option
  2019-02-25  8:22                     ` [LTP] [PATCH] syscalls/cma: fix the failure of compiling with O2 option Jason Xing
@ 2019-02-25 10:34                       ` Li Wang
  2019-02-25 10:47                       ` Jan Stancek
  1 sibling, 0 replies; 23+ messages in thread
From: Li Wang @ 2019-02-25 10:34 UTC (permalink / raw)
  To: ltp

On Mon, Feb 25, 2019 at 4:22 PM Jason Xing <
kerneljasonxing@linux.alibaba.com> wrote:

> This issue is triggered by the commit 9b02cd465f70 which I wrote. If
> compile the process_vm_readv03.c with O2 option and run, it will return
> TFAIL. By casting the int type to long type in the ltp_syscall calling
> functions can we avoid this failure.
>
> Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
> ---
>  testcases/kernel/syscalls/cma/process_vm_readv03.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> index 45f7c92..e15ffee 100644
> --- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> +++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> @@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void)
>         remote.iov_len = len;
>
>         TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
> -                        1, &remote, 1, 0));
> +                        1L, &remote, 1L, 0L));
>         if (TEST_RETURN != len)
>                 tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
>
> @@ -213,8 +213,8 @@ static void child_invoke(int *bufsz_arr)
>         tst_resm(TINFO, "child 1: %d local iovecs initialized.",
>                  NUM_LOCAL_VECS);
>
> -       TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local,
> NUM_LOCAL_VECS,
> -                                  remote, nr_iovecs, 0));
> +       TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local,
> (long)NUM_LOCAL_VECS,
> +                                  remote, (long)nr_iovecs, 0L));
>

Maybe cast them into 'unsigned long' type is better? otherwise this patch
LGTM.

Cut from linux manual page:
------------------
ssize_t process_vm_readv(pid_t pid,
                                           const struct iovec *local_iov,
                                           unsigned long liovcnt,
                                           const struct iovec *remote_iov,
                                           unsigned long riovcnt,
                                           unsigned long flags);

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190225/b534ae24/attachment.html>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH] syscalls/cma: fix the failure of compiling with O2 option
  2019-02-25  8:22                     ` [LTP] [PATCH] syscalls/cma: fix the failure of compiling with O2 option Jason Xing
  2019-02-25 10:34                       ` Li Wang
@ 2019-02-25 10:47                       ` Jan Stancek
  2019-02-25 13:16                         ` Caspar Zhang
  2019-02-26  2:00                         ` [LTP] [PATCH] " Jason Xing
  1 sibling, 2 replies; 23+ messages in thread
From: Jan Stancek @ 2019-02-25 10:47 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> This issue is triggered by the commit 9b02cd465f70 which I wrote. If
> compile the process_vm_readv03.c with O2 option and run, it will return
> TFAIL. By casting the int type to long type in the ltp_syscall calling
> functions can we avoid this failure.
> 
> Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
> ---
>  testcases/kernel/syscalls/cma/process_vm_readv03.c | 8 ++++----

What about other tests that were changed by commit 9b02cd465f70 ?

>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> index 45f7c92..e15ffee 100644
> --- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
> +++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
> @@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void)
>  	remote.iov_len = len;
>  
>  	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
> -			 1, &remote, 1, 0));
> +			 1L, &remote, 1L, 0L));
>  	if (TEST_RETURN != len)
>  		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
>  
> @@ -213,8 +213,8 @@ static void child_invoke(int *bufsz_arr)
>  	tst_resm(TINFO, "child 1: %d local iovecs initialized.",
>  		 NUM_LOCAL_VECS);
>  
> -	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local, NUM_LOCAL_VECS,
> -				   remote, nr_iovecs, 0));
> +	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local,
> (long)NUM_LOCAL_VECS,
> +				   remote, (long)nr_iovecs, 0L));
>  	if (TEST_RETURN != bufsz)
>  		tst_brkm(TBROK | TERRNO, tst_exit, "process_vm_readv");
>  
> @@ -248,7 +248,7 @@ static void setup(void)
>  	tst_require_root();
>  
>  	/* Just a sanity check of the existence of syscall */
> -	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0);
> +	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0L, NULL, 0L, 0L);
>  
>  	nr_iovecs = nflag ? SAFE_STRTOL(NULL, nr_opt, 1, IOV_MAX) : 10;
>  	bufsz = sflag ? SAFE_STRTOL(NULL, sz_opt, NUM_LOCAL_VECS, LONG_MAX)
> --
> 1.8.3.1
> 
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH] syscalls/cma: fix the failure of compiling with O2 option
  2019-02-25 10:47                       ` Jan Stancek
@ 2019-02-25 13:16                         ` Caspar Zhang
  2019-02-26  1:42                           ` [LTP] [PATCH v2] " Jason Xing
  2019-02-26  2:00                         ` [LTP] [PATCH] " Jason Xing
  1 sibling, 1 reply; 23+ messages in thread
From: Caspar Zhang @ 2019-02-25 13:16 UTC (permalink / raw)
  To: ltp

On Mon, Feb 25, 2019 at 05:47:25AM -0500, Jan Stancek wrote:
>
>
> ----- Original Message -----
> > This issue is triggered by the commit 9b02cd465f70 which I wrote. If
> > compile the process_vm_readv03.c with O2 option and run, it will return
> > TFAIL. By casting the int type to long type in the ltp_syscall calling
> > functions can we avoid this failure.
> >
> > Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
> > ---
> >  testcases/kernel/syscalls/cma/process_vm_readv03.c | 8 ++++----
>
> What about other tests that were changed by commit 9b02cd465f70 ?

I downgraded my glibc from 2.17-196 (a centos 7.4 version) to
2.17-157 was able to reproduce this issue. I also tried modifying
the params in all `TEST(ltp_syscall(__NR_process_vm...` calls, seemd
that this is the only one causes (and solves) the failure:

        TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local, NUM_LOCAL_VECS,
-                                  remote, nr_iovecs, 0));
+                                  remote, nr_iovecs, 0UL));

If we have enough time we might want to do a bisect between
glibc-2.17-157 and 196 to dig into the real problem behind the simple
fix, but for now I'm agree to convert all int params to correct unsigned
long changed by this commit, so that we can get rid of any potential
failures.

Jason, can you make an updated patch to include Li Wang's and Jan's
advices?

Thanks,
Caspar

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v2] syscalls/cma: fix the failure of compiling with O2 option
  2019-02-25 13:16                         ` Caspar Zhang
@ 2019-02-26  1:42                           ` Jason Xing
  2019-02-26  2:22                             ` [LTP] [PATCH v3] " Jason Xing
  0 siblings, 1 reply; 23+ messages in thread
From: Jason Xing @ 2019-02-26  1:42 UTC (permalink / raw)
  To: ltp

This issue is triggered by the commit 9b02cd465f70 which I wrote. If
compile the process_vm_readv03.c with O2 option and run, it will return
TFAIL. By casting the int type to unsigned long type in the ltp_syscall
calling functions can we avoid this failure.

Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
---
 testcases/kernel/syscalls/cma/process_vm_readv03.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c b/testcases/kernel/syscalls/cma/process_vm_readv03.c
index 45f7c92..f09dfb0 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
@@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void)
 	remote.iov_len = len;
 
 	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
-			 1, &remote, 1, 0));
+			 1UL, &remote, 1UL, 0UL));
 	if (TEST_RETURN != len)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 
@@ -213,8 +213,9 @@ static void child_invoke(int *bufsz_arr)
 	tst_resm(TINFO, "child 1: %d local iovecs initialized.",
 		 NUM_LOCAL_VECS);
 
-	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local, NUM_LOCAL_VECS,
-				   remote, nr_iovecs, 0));
+	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local,
+			    (unsigned long)NUM_LOCAL_VECS, remote,
+			    (unsigned long)nr_iovecs, 0UL));
 	if (TEST_RETURN != bufsz)
 		tst_brkm(TBROK | TERRNO, tst_exit, "process_vm_readv");
 
@@ -248,7 +249,7 @@ static void setup(void)
 	tst_require_root();
 
 	/* Just a sanity check of the existence of syscall */
-	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0);
+	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0UL, NULL, 0UL, 0UL);
 
 	nr_iovecs = nflag ? SAFE_STRTOL(NULL, nr_opt, 1, IOV_MAX) : 10;
 	bufsz = sflag ? SAFE_STRTOL(NULL, sz_opt, NUM_LOCAL_VECS, LONG_MAX)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH] syscalls/cma: fix the failure of compiling with O2 option
  2019-02-25 10:47                       ` Jan Stancek
  2019-02-25 13:16                         ` Caspar Zhang
@ 2019-02-26  2:00                         ` Jason Xing
  1 sibling, 0 replies; 23+ messages in thread
From: Jason Xing @ 2019-02-26  2:00 UTC (permalink / raw)
  To: ltp



On 2019/2/25 下午6:47, Jan Stancek wrote:
>
>
> ----- Original Message -----
>> This issue is triggered by the commit 9b02cd465f70 which I wrote. If
>> compile the process_vm_readv03.c with O2 option and run, it will return
>> TFAIL. By casting the int type to long type in the ltp_syscall calling
>> functions can we avoid this failure.
>>
>> Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
>> ---
>>  testcases/kernel/syscalls/cma/process_vm_readv03.c | 8 ++++----
>
> What about other tests that were changed by commit 9b02cd465f70 ?
>

After testing all the process_vm_* cases with O0 and O2 options, we find 
that only process_vm_readv03 encounters this problem.

>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c
>> b/testcases/kernel/syscalls/cma/process_vm_readv03.c
>> index 45f7c92..e15ffee 100644
>> --- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
>> +++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
>> @@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void)
>>  	remote.iov_len = len;
>>
>>  	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
>> -			 1, &remote, 1, 0));
>> +			 1L, &remote, 1L, 0L));
>>  	if (TEST_RETURN != len)
>>  		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
>>
>> @@ -213,8 +213,8 @@ static void child_invoke(int *bufsz_arr)
>>  	tst_resm(TINFO, "child 1: %d local iovecs initialized.",
>>  		 NUM_LOCAL_VECS);
>>
>> -	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local, NUM_LOCAL_VECS,
>> -				   remote, nr_iovecs, 0));
>> +	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local,
>> (long)NUM_LOCAL_VECS,
>> +				   remote, (long)nr_iovecs, 0L));
>>  	if (TEST_RETURN != bufsz)
>>  		tst_brkm(TBROK | TERRNO, tst_exit, "process_vm_readv");
>>
>> @@ -248,7 +248,7 @@ static void setup(void)
>>  	tst_require_root();
>>
>>  	/* Just a sanity check of the existence of syscall */
>> -	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0);
>> +	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0L, NULL, 0L, 0L);
>>
>>  	nr_iovecs = nflag ? SAFE_STRTOL(NULL, nr_opt, 1, IOV_MAX) : 10;
>>  	bufsz = sflag ? SAFE_STRTOL(NULL, sz_opt, NUM_LOCAL_VECS, LONG_MAX)
>> --
>> 1.8.3.1
>>
>>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v3] syscalls/cma: fix the failure of compiling with O2 option
  2019-02-26  1:42                           ` [LTP] [PATCH v2] " Jason Xing
@ 2019-02-26  2:22                             ` Jason Xing
  2019-02-26  3:17                               ` Li Wang
  2019-02-26 16:03                               ` Jan Stancek
  0 siblings, 2 replies; 23+ messages in thread
From: Jason Xing @ 2019-02-26  2:22 UTC (permalink / raw)
  To: ltp

This issue is triggered by the commit 9b02cd465f70 which I wrote. If
compile the process_vm_readv03.c with O2 option and run, it will return
TFAIL. By casting the int type to unsigned long type in the ltp_syscall
calling functions can we avoid this failure. Thus I modify all the
testcases which might be affected by the previous commit.

Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
---
 testcases/kernel/syscalls/cma/process_vm_readv02.c  | 4 ++--
 testcases/kernel/syscalls/cma/process_vm_readv03.c  | 9 +++++----
 testcases/kernel/syscalls/cma/process_vm_writev02.c | 4 ++--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/testcases/kernel/syscalls/cma/process_vm_readv02.c b/testcases/kernel/syscalls/cma/process_vm_readv02.c
index e1fc32a..68e1bea 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv02.c
@@ -135,7 +135,7 @@ static void child_invoke(void)
 
 	tst_resm(TINFO, "child 1: reading string from same memory location.");
 	TEST(ltp_syscall(__NR_process_vm_readv, pids[0],
-			 &local, 1, &remote, 1, 0));
+			 &local, 1UL, &remote, 1UL, 0UL));
 	if (TEST_RETURN != len)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 	if (strncmp(lp, tst_string, len) != 0)
@@ -150,7 +150,7 @@ static void setup(void)
 	tst_require_root();
 
 	/* Just a sanity check of the existence of syscall */
-	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0);
+	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0UL, NULL, 0UL, 0UL);
 
 	tst_tmpdir();
 	TST_CHECKPOINT_INIT(cleanup);
diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c b/testcases/kernel/syscalls/cma/process_vm_readv03.c
index 45f7c92..f09dfb0 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
@@ -181,7 +181,7 @@ static long *fetch_remote_addrs(void)
 	remote.iov_len = len;
 
 	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], &local,
-			 1, &remote, 1, 0));
+			 1UL, &remote, 1UL, 0UL));
 	if (TEST_RETURN != len)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 
@@ -213,8 +213,9 @@ static void child_invoke(int *bufsz_arr)
 	tst_resm(TINFO, "child 1: %d local iovecs initialized.",
 		 NUM_LOCAL_VECS);
 
-	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local, NUM_LOCAL_VECS,
-				   remote, nr_iovecs, 0));
+	TEST(ltp_syscall(__NR_process_vm_readv, pids[0], local,
+			    (unsigned long)NUM_LOCAL_VECS, remote,
+			    (unsigned long)nr_iovecs, 0UL));
 	if (TEST_RETURN != bufsz)
 		tst_brkm(TBROK | TERRNO, tst_exit, "process_vm_readv");
 
@@ -248,7 +249,7 @@ static void setup(void)
 	tst_require_root();
 
 	/* Just a sanity check of the existence of syscall */
-	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0, NULL, 0, 0);
+	ltp_syscall(__NR_process_vm_readv, getpid(), NULL, 0UL, NULL, 0UL, 0UL);
 
 	nr_iovecs = nflag ? SAFE_STRTOL(NULL, nr_opt, 1, IOV_MAX) : 10;
 	bufsz = sflag ? SAFE_STRTOL(NULL, sz_opt, NUM_LOCAL_VECS, LONG_MAX)
diff --git a/testcases/kernel/syscalls/cma/process_vm_writev02.c b/testcases/kernel/syscalls/cma/process_vm_writev02.c
index b1edba5..2e7a8d6 100644
--- a/testcases/kernel/syscalls/cma/process_vm_writev02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_writev02.c
@@ -172,7 +172,7 @@ static void child_write(void)
 
 	tst_resm(TINFO, "child 2: write to the same memory location.");
 	TEST(ltp_syscall(__NR_process_vm_writev, pids[0], &local,
-			 1, &remote, 1, 0));
+			 1UL, &remote, 1UL, 0UL));
 	if (TEST_RETURN != bufsz)
 		tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
 }
@@ -182,7 +182,7 @@ static void setup(void)
 	tst_require_root();
 
 	/* Just a sanity check of the existence of syscall */
-	ltp_syscall(__NR_process_vm_writev, getpid(), NULL, 0, NULL, 0, 0);
+	ltp_syscall(__NR_process_vm_writev, getpid(), NULL, 0UL, NULL, 0UL, 0UL);
 
 	bufsz =
 	    sflag ? SAFE_STRTOL(NULL, sz_opt, 1, LONG_MAX - PADDING_SIZE * 2)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v3] syscalls/cma: fix the failure of compiling with O2 option
  2019-02-26  2:22                             ` [LTP] [PATCH v3] " Jason Xing
@ 2019-02-26  3:17                               ` Li Wang
  2019-02-26 16:03                               ` Jan Stancek
  1 sibling, 0 replies; 23+ messages in thread
From: Li Wang @ 2019-02-26  3:17 UTC (permalink / raw)
  To: ltp

On Tue, Feb 26, 2019 at 10:22 AM Jason Xing <
kerneljasonxing@linux.alibaba.com> wrote:

> This issue is triggered by the commit 9b02cd465f70 which I wrote. If
> compile the process_vm_readv03.c with O2 option and run, it will return
> TFAIL. By casting the int type to unsigned long type in the ltp_syscall
> calling functions can we avoid this failure. Thus I modify all the
> testcases which might be affected by the previous commit.
>
> Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>
>
Reviewed-by: Li Wang <liwang@redhat.com>

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190226/a7ad216d/attachment.html>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [LTP] [PATCH v3] syscalls/cma: fix the failure of compiling with O2 option
  2019-02-26  2:22                             ` [LTP] [PATCH v3] " Jason Xing
  2019-02-26  3:17                               ` Li Wang
@ 2019-02-26 16:03                               ` Jan Stancek
  1 sibling, 0 replies; 23+ messages in thread
From: Jan Stancek @ 2019-02-26 16:03 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> This issue is triggered by the commit 9b02cd465f70 which I wrote. If
> compile the process_vm_readv03.c with O2 option and run, it will return
> TFAIL. By casting the int type to unsigned long type in the ltp_syscall
> calling functions can we avoid this failure. Thus I modify all the
> testcases which might be affected by the previous commit.
> 
> Signed-off-by: Jason Xing <kerneljasonxing@linux.alibaba.com>

Pushed.

Thanks,
Jan

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2019-02-26 16:03 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03  9:43 [LTP] [PATCH] syscalls/cma: test case should return TCONF if syscall doesn't exist Jason Xing
2018-12-03  9:58 ` Jan Stancek
2018-12-04  2:49   ` Jason Xing
2018-12-04  8:54     ` Jan Stancek
2018-12-05 13:43       ` [LTP] [PATCH v2 1/2] " Jason Xing
2018-12-05 13:43         ` [LTP] [PATCH v2 2/2] lapi/syscalls: Add syscall numbers for process_vm_readv/_writev Jason Xing
2018-12-05 22:07           ` Petr Vorel
2018-12-06  3:37             ` Jason Xing
2019-02-15 10:50         ` [LTP] [PATCH v2 1/2] syscalls/cma: test case should return TCONF if syscall doesn't exist Li Wang
2019-02-15 13:53           ` Jan Stancek
2019-02-16  7:18             ` Li Wang
2019-02-16 10:28               ` Jan Stancek
2019-02-22 18:29                 ` Jan Stancek
2019-02-23  6:21                   ` Caspar Zhang
2019-02-25  8:22                     ` [LTP] [PATCH] syscalls/cma: fix the failure of compiling with O2 option Jason Xing
2019-02-25 10:34                       ` Li Wang
2019-02-25 10:47                       ` Jan Stancek
2019-02-25 13:16                         ` Caspar Zhang
2019-02-26  1:42                           ` [LTP] [PATCH v2] " Jason Xing
2019-02-26  2:22                             ` [LTP] [PATCH v3] " Jason Xing
2019-02-26  3:17                               ` Li Wang
2019-02-26 16:03                               ` Jan Stancek
2019-02-26  2:00                         ` [LTP] [PATCH] " Jason Xing

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.