Merge freebsd32_exec_setregs() into exec_setregs() on MIPS.

The stack pointer was being decremented by 64k twice previously.

Reviewed by:	brooks
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24930
This commit is contained in:
John Baldwin 2020-05-20 19:51:39 +00:00
parent 697b271da9
commit 871c7dd2aa
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=361291
2 changed files with 13 additions and 27 deletions

View File

@ -68,8 +68,6 @@
#include <compat/freebsd32/freebsd32_util.h>
#include <compat/freebsd32/freebsd32_proto.h>
static void freebsd32_exec_setregs(struct thread *, struct image_params *,
uintptr_t);
static int get_mcontext32(struct thread *, mcontext32_t *, int);
static int set_mcontext32(struct thread *, mcontext32_t *);
static void freebsd32_sendsig(sig_t, ksiginfo_t *, sigset_t *);
@ -97,7 +95,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_stackprot = VM_PROT_ALL,
.sv_copyout_auxargs = __elfN(freebsd_copyout_auxargs),
.sv_copyout_strings = freebsd32_copyout_strings,
.sv_setregs = freebsd32_exec_setregs,
.sv_setregs = exec_setregs,
.sv_fixlimit = NULL,
.sv_maxssiz = NULL,
.sv_flags = SV_ABI_FREEBSD | SV_ILP32,
@ -126,26 +124,6 @@ SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST,
(sysinit_cfunc_t) elf32_insert_brand_entry,
&freebsd_brand_info);
static void
freebsd32_exec_setregs(struct thread *td, struct image_params *imgp,
uintptr_t stack)
{
exec_setregs(td, imgp, stack);
/*
* See comment in exec_setregs about running 32-bit binaries with 64-bit
* registers.
*/
td->td_frame->sp -= 65536;
/*
* Clear extended address space bit for userland.
*/
td->td_frame->sr &= ~MIPS_SR_UX;
td->td_md.md_tls_tcb_offset = TLS_TP_OFFSET + TLS_TCB_SIZE32;
}
int
set_regs32(struct thread *td, struct reg32 *regs)
{

View File

@ -441,10 +441,13 @@ exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
td->td_frame->t9 = imgp->entry_addr & ~3; /* abicall req */
td->td_frame->sr = MIPS_SR_KSU_USER | MIPS_SR_EXL | MIPS_SR_INT_IE |
(mips_rd_status() & MIPS_SR_INT_MASK);
#if defined(__mips_n32)
#if defined(__mips_n32) || defined(__mips_n64)
td->td_frame->sr |= MIPS_SR_PX;
#elif defined(__mips_n64)
td->td_frame->sr |= MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX;
#endif
#if defined(__mips_n64)
if (SV_PROC_FLAG(td->td_proc, SV_LP64))
td->td_frame->sr |= MIPS_SR_UX;
td->td_frame->sr |= MIPS_SR_KX;
#endif
/*
* FREEBSD_DEVELOPERS_FIXME:
@ -470,7 +473,12 @@ exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
PCPU_SET(fpcurthread, (struct thread *)0);
td->td_md.md_ss_addr = 0;
td->td_md.md_tls_tcb_offset = TLS_TP_OFFSET + TLS_TCB_SIZE;
#ifdef COMPAT_FREEBSD32
if (!SV_PROC_FLAG(td->td_proc, SV_LP64))
td->td_md.md_tls_tcb_offset = TLS_TP_OFFSET + TLS_TCB_SIZE32;
else
#endif
td->td_md.md_tls_tcb_offset = TLS_TP_OFFSET + TLS_TCB_SIZE;
}
int