aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2023-05-28 14:06:23 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2023-05-28 14:06:23 +0000
commit185bd9fa3096595350ebe7bcd7e0ddcf17773030 (patch)
tree939e10a9ffff16d77d9ef7f09ac83ab7d3781a20
parenta463dd810851fdae5efcb8f8205d742ebf221bc8 (diff)
downloadsrc-185bd9fa3096595350ebe7bcd7e0ddcf17773030.tar.gz
src-185bd9fa3096595350ebe7bcd7e0ddcf17773030.zip
linux(4): Simplify %r10 restoring on amd64
Restore %r10 at system call entry to avoid doing this multiply times. Differential Revision: https://reviews.freebsd.org/D40154 MFC after: 1 month
-rw-r--r--sys/amd64/linux/linux_machdep.c6
-rw-r--r--sys/amd64/linux/linux_sysvec.c6
2 files changed, 3 insertions, 9 deletions
diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c
index 6ac0ab0cd3d7..155ea918cd0a 100644
--- a/sys/amd64/linux/linux_machdep.c
+++ b/sys/amd64/linux/linux_machdep.c
@@ -350,12 +350,6 @@ linux_ptrace_getregs_machdep(struct thread *td, pid_t pid,
linux_msg(td, "PT_LWPINFO failed with error %d", error);
return (error);
}
- if ((lwpinfo.pl_flags & PL_FLAG_SCE) != 0) {
- /*
- * Undo the mangling done in exception.S:fast_syscall_common().
- */
- l_regset->r10 = l_regset->rcx;
- }
if ((lwpinfo.pl_flags & (PL_FLAG_SCE | PL_FLAG_SCX)) != 0) {
/*
* In Linux, the syscall number - passed to the syscall
diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c
index 89d388dc6cf8..422cfbe7c5ba 100644
--- a/sys/amd64/linux/linux_sysvec.c
+++ b/sys/amd64/linux/linux_sysvec.c
@@ -167,6 +167,9 @@ linux_fetch_syscall_args(struct thread *td)
else
sa->callp = &p->p_sysent->sv_table[sa->code];
+ /* Restore r10 earlier to avoid doing this multiply times. */
+ frame->tf_r10 = frame->tf_rcx;
+
td->td_retval[0] = 0;
return (0);
}
@@ -181,7 +184,6 @@ linux_set_syscall_retval(struct thread *td, int error)
switch (error) {
case 0:
frame->tf_rax = td->td_retval[0];
- frame->tf_r10 = frame->tf_rcx;
break;
case ERESTART:
@@ -192,7 +194,6 @@ linux_set_syscall_retval(struct thread *td, int error)
*
*/
frame->tf_rip -= frame->tf_err;
- frame->tf_r10 = frame->tf_rcx;
break;
case EJUSTRETURN:
@@ -200,7 +201,6 @@ linux_set_syscall_retval(struct thread *td, int error)
default:
frame->tf_rax = bsd_to_linux_errno(error);
- frame->tf_r10 = frame->tf_rcx;
break;
}