From owner-svn-src-all@freebsd.org Wed May 20 19:51:40 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 95FD42F38B2; Wed, 20 May 2020 19:51:40 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49S3Km3XwCz3RtH; Wed, 20 May 2020 19:51:40 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 74F4621651; Wed, 20 May 2020 19:51:40 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04KJpekP038660; Wed, 20 May 2020 19:51:40 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04KJpeYw038659; Wed, 20 May 2020 19:51:40 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005201951.04KJpeYw038659@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 20 May 2020 19:51:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361291 - head/sys/mips/mips X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/mips/mips X-SVN-Commit-Revision: 361291 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2020 19:51:40 -0000 Author: jhb Date: Wed May 20 19:51:39 2020 New Revision: 361291 URL: https://svnweb.freebsd.org/changeset/base/361291 Log: 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 Modified: head/sys/mips/mips/freebsd32_machdep.c head/sys/mips/mips/pm_machdep.c Modified: head/sys/mips/mips/freebsd32_machdep.c ============================================================================== --- head/sys/mips/mips/freebsd32_machdep.c Wed May 20 19:45:22 2020 (r361290) +++ head/sys/mips/mips/freebsd32_machdep.c Wed May 20 19:51:39 2020 (r361291) @@ -68,8 +68,6 @@ #include #include -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, @@ -125,26 +123,6 @@ static Elf32_Brandinfo freebsd_brand_info = { 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) Modified: head/sys/mips/mips/pm_machdep.c ============================================================================== --- head/sys/mips/mips/pm_machdep.c Wed May 20 19:45:22 2020 (r361290) +++ head/sys/mips/mips/pm_machdep.c Wed May 20 19:51:39 2020 (r361291) @@ -441,11 +441,14 @@ exec_setregs(struct thread *td, struct image_params *i 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: * Setup any other CPU-Specific registers (Not MIPS Standard) @@ -470,7 +473,12 @@ exec_setregs(struct thread *td, struct image_params *i 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