svn commit: r199900 - in projects/ppc64/sys/powerpc: aim powerpc
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Sun Nov 29 17:25:33 UTC 2009
Author: nwhitehorn
Date: Sun Nov 29 17:25:32 2009
New Revision: 199900
URL: http://svn.freebsd.org/changeset/base/199900
Log:
Add TLS support for 64-bit binaries and move both TLS setting and syscall
returns to powerpc/exec_machdep.c, which is meant to handle userland ABI
details.
Modified:
projects/ppc64/sys/powerpc/aim/vm_machdep.c
projects/ppc64/sys/powerpc/powerpc/exec_machdep.c
Modified: projects/ppc64/sys/powerpc/aim/vm_machdep.c
==============================================================================
--- projects/ppc64/sys/powerpc/aim/vm_machdep.c Sun Nov 29 10:53:34 2009 (r199899)
+++ projects/ppc64/sys/powerpc/aim/vm_machdep.c Sun Nov 29 17:25:32 2009 (r199900)
@@ -81,7 +81,6 @@
#include <sys/kernel.h>
#include <sys/mbuf.h>
#include <sys/sf_buf.h>
-#include <sys/syscall.h>
#include <sys/sysctl.h>
#include <sys/sysent.h>
#include <sys/unistd.h>
@@ -438,60 +437,6 @@ cpu_thread_swapout(struct thread *td)
}
void
-cpu_set_syscall_retval(struct thread *td, int error)
-{
- struct proc *p;
- struct trapframe *tf;
- int fixup;
-
- if (error == EJUSTRETURN)
- return;
-
- p = td->td_proc;
- tf = td->td_frame;
-
- if (tf->fixreg[0] == SYS___syscall &&
- (p->p_sysent->sv_flags & SV_ILP32)) {
- int code = tf->fixreg[FIRSTARG + 1];
- if (p->p_sysent->sv_mask)
- code &= p->p_sysent->sv_mask;
- fixup = (code != SYS_freebsd6_lseek && code != SYS_lseek) ?
- 1 : 0;
- } else
- fixup = 0;
-
- switch (error) {
- case 0:
- if (fixup) {
- /*
- * 64-bit return, 32-bit syscall. Fixup byte order
- */
- tf->fixreg[FIRSTARG] = 0;
- tf->fixreg[FIRSTARG + 1] = td->td_retval[0];
- } else {
- tf->fixreg[FIRSTARG] = td->td_retval[0];
- tf->fixreg[FIRSTARG + 1] = td->td_retval[1];
- }
- tf->cr &= ~0x10000000; /* XXX: Magic number */
- break;
- case ERESTART:
- /*
- * Set user's pc back to redo the system call.
- */
- tf->srr0 -= 4;
- break;
- default:
- if (p->p_sysent->sv_errsize) {
- error = (error < p->p_sysent->sv_errsize) ?
- p->p_sysent->sv_errtbl[error] : -1;
- }
- tf->fixreg[FIRSTARG] = error;
- tf->cr |= 0x10000000; /* XXX: Magic number */
- break;
- }
-}
-
-void
cpu_set_upcall(struct thread *td, struct thread *td0)
{
struct pcb *pcb2;
@@ -555,10 +500,3 @@ cpu_set_upcall_kse(struct thread *td, vo
td->td_retval[1] = 0;
}
-int
-cpu_set_user_tls(struct thread *td, void *tls_base)
-{
-
- td->td_frame->fixreg[2] = (register_t)tls_base + 0x7008;
- return (0);
-}
Modified: projects/ppc64/sys/powerpc/powerpc/exec_machdep.c
==============================================================================
--- projects/ppc64/sys/powerpc/powerpc/exec_machdep.c Sun Nov 29 10:53:34 2009 (r199899)
+++ projects/ppc64/sys/powerpc/powerpc/exec_machdep.c Sun Nov 29 17:25:32 2009 (r199900)
@@ -75,6 +75,7 @@ __FBSDID("$FreeBSD: projects/ppc64/sys/p
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/signalvar.h>
+#include <sys/syscall.h>
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <sys/ucontext.h>
@@ -845,3 +846,68 @@ freebsd32_swapcontext(struct thread *td,
#endif
+void
+cpu_set_syscall_retval(struct thread *td, int error)
+{
+ struct proc *p;
+ struct trapframe *tf;
+ int fixup;
+
+ if (error == EJUSTRETURN)
+ return;
+
+ p = td->td_proc;
+ tf = td->td_frame;
+
+ if (tf->fixreg[0] == SYS___syscall &&
+ (p->p_sysent->sv_flags & SV_ILP32)) {
+ int code = tf->fixreg[FIRSTARG + 1];
+ if (p->p_sysent->sv_mask)
+ code &= p->p_sysent->sv_mask;
+ fixup = (code != SYS_freebsd6_lseek && code != SYS_lseek) ?
+ 1 : 0;
+ } else
+ fixup = 0;
+
+ switch (error) {
+ case 0:
+ if (fixup) {
+ /*
+ * 64-bit return, 32-bit syscall. Fixup byte order
+ */
+ tf->fixreg[FIRSTARG] = 0;
+ tf->fixreg[FIRSTARG + 1] = td->td_retval[0];
+ } else {
+ tf->fixreg[FIRSTARG] = td->td_retval[0];
+ tf->fixreg[FIRSTARG + 1] = td->td_retval[1];
+ }
+ tf->cr &= ~0x10000000; /* XXX: Magic number */
+ break;
+ case ERESTART:
+ /*
+ * Set user's pc back to redo the system call.
+ */
+ tf->srr0 -= 4;
+ break;
+ default:
+ if (p->p_sysent->sv_errsize) {
+ error = (error < p->p_sysent->sv_errsize) ?
+ p->p_sysent->sv_errtbl[error] : -1;
+ }
+ tf->fixreg[FIRSTARG] = error;
+ tf->cr |= 0x10000000; /* XXX: Magic number */
+ break;
+ }
+}
+
+int
+cpu_set_user_tls(struct thread *td, void *tls_base)
+{
+
+ if (td->td_proc->p_sysent->sv_flags & SV_LP64)
+ td->td_frame->fixreg[13] = (register_t)tls_base + 0x8000;
+ else
+ td->td_frame->fixreg[2] = (register_t)tls_base + 0x7008;
+ return (0);
+}
+
More information about the svn-src-projects
mailing list