parasite: pass parameter regs as pointer

Submitted by Andrei Vagin on July 7, 2016, 5:59 a.m.

Details

Message ID 1467871170-907-1-git-send-email-avagin@openvz.org
State Accepted
Series "parasite: pass parameter regs as pointer"
Commit c477a98de4427c11bcd5106c7163894267905db0
Headers show

Commit Message

Andrei Vagin July 7, 2016, 5:59 a.m.
From: Andrew Vagin <avagin@virtuozzo.com>

CID 163751 (#1 of 1): Big parameter passed by value (PASS_BY_VALUE)
pass_by_value: Passing parameter regs of type user_regs_struct_t (size 224 bytes) by value.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
---
 criu/arch/aarch64/include/asm/types.h |  6 +++---
 criu/parasite-syscall.c               | 14 +++++++-------
 2 files changed, 10 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/arch/aarch64/include/asm/types.h b/criu/arch/aarch64/include/asm/types.h
index 2c7c475..51c0a31 100644
--- a/criu/arch/aarch64/include/asm/types.h
+++ b/criu/arch/aarch64/include/asm/types.h
@@ -54,9 +54,9 @@  typedef struct {
 typedef struct user_pt_regs user_regs_struct_t;
 
 
-#define REG_RES(regs)		((u64)(regs).regs[0])
-#define REG_IP(regs)		((u64)(regs).pc)
-#define REG_SYSCALL_NR(regs)	((u64)(regs).regs[8])
+#define REG_RES(r)		((u64)(r).regs[0])
+#define REG_IP(r)		((u64)(r).pc)
+#define REG_SYSCALL_NR(r)	((u64)(r).regs[8])
 
 #define user_regs_native(pregs)			true
 #define core_is_compat(core)			false
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index cc78bc6..0366e7b 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -1019,17 +1019,17 @@  static bool task_is_trapped(int status, pid_t pid)
 	return false;
 }
 
-static inline int is_required_syscall(user_regs_struct_t regs, pid_t pid,
+static inline int is_required_syscall(user_regs_struct_t *regs, pid_t pid,
 		const int sys_nr, const int sys_nr_compat)
 {
-	const char *mode = user_regs_native(&regs) ? "native" : "compat";
-	int req_sysnr = user_regs_native(&regs) ? sys_nr : sys_nr_compat;
+	const char *mode = user_regs_native(regs) ? "native" : "compat";
+	int req_sysnr = user_regs_native(regs) ? sys_nr : sys_nr_compat;
 
 	pr_debug("%d (%s) is going to execute the syscall %lu, required is %d\n",
-		pid, mode, REG_SYSCALL_NR(regs), req_sysnr);
-	if (user_regs_native(&regs) && (REG_SYSCALL_NR(regs) == sys_nr))
+		pid, mode, REG_SYSCALL_NR(*regs), req_sysnr);
+	if (user_regs_native(regs) && (REG_SYSCALL_NR(*regs) == sys_nr))
 		return true;
-	if (!user_regs_native(&regs) && (REG_SYSCALL_NR(regs) == sys_nr_compat))
+	if (!user_regs_native(regs) && (REG_SYSCALL_NR(*regs) == sys_nr_compat))
 		return true;
 
 	return false;
@@ -1079,7 +1079,7 @@  int parasite_stop_on_syscall(int tasks,
 			return -1;
 		}
 
-		if (is_required_syscall(regs, pid, sys_nr, sys_nr_compat)) {
+		if (is_required_syscall(&regs, pid, sys_nr, sys_nr_compat)) {
 			/*
 			 * The process is going to execute the required syscall,
 			 * the next stop will be on the exit from this syscall

Comments

Dmitry Safonov July 7, 2016, 12:08 p.m.
On 07/07/2016 08:59 AM, Andrey Vagin wrote:
> From: Andrew Vagin <avagin@virtuozzo.com>
>
> CID 163751 (#1 of 1): Big parameter passed by value (PASS_BY_VALUE)
> pass_by_value: Passing parameter regs of type user_regs_struct_t (size 224 bytes) by value.
>
> Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>

Thanks!
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Pavel Emelianov July 13, 2016, 1:36 p.m.
Applied