Date: Fri, 25 Sep 2020 17:13:46 +0000 (UTC) From: Justin Hibbits <jhibbits@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366162 - in head/sys/mips: include mips Message-ID: <202009251713.08PHDkog059795@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhibbits Date: Fri Sep 25 17:13:45 2020 New Revision: 366162 URL: https://svnweb.freebsd.org/changeset/base/366162 Log: Fix compat32 on mips64 Summary: Two bugs: * Elf32_Auxinfo is broken, using pointers in the union, which are 64-bits not 32. * freebsd32_sysarch() doesn't update the 'user local' register when handling MIPS_SET_TLS, leading to a NULL pointer dereference in the 32-bit application. Reviewed by: #mips, brooks MFC after: 1 week Sponsored by: Juniper Networks, Inc Differential Revision: https://reviews.freebsd.org/D26556 Modified: head/sys/mips/include/elf.h head/sys/mips/mips/freebsd32_machdep.c Modified: head/sys/mips/include/elf.h ============================================================================== --- head/sys/mips/include/elf.h Fri Sep 25 16:44:01 2020 (r366161) +++ head/sys/mips/include/elf.h Fri Sep 25 17:13:45 2020 (r366162) @@ -105,8 +105,6 @@ typedef struct { /* Auxiliary vector entry on initial int a_type; /* Entry type. */ union { int a_val; /* Integer value. */ - void *a_ptr; /* Address. */ - void (*a_fcn)(void); /* Function pointer (not used). */ } a_un; } Elf32_Auxinfo; Modified: head/sys/mips/mips/freebsd32_machdep.c ============================================================================== --- head/sys/mips/mips/freebsd32_machdep.c Fri Sep 25 16:44:01 2020 (r366161) +++ head/sys/mips/mips/freebsd32_machdep.c Fri Sep 25 17:13:45 2020 (r366162) @@ -58,6 +58,7 @@ #include <vm/vm.h> #include <vm/vm_param.h> +#include <machine/cpuinfo.h> #include <machine/md_var.h> #include <machine/reg.h> #include <machine/sigframe.h> @@ -455,6 +456,17 @@ freebsd32_sysarch(struct thread *td, struct freebsd32_ switch (uap->op) { case MIPS_SET_TLS: td->td_md.md_tls = (void *)(intptr_t)uap->parms; + + /* + * If there is an user local register implementation (ULRI) + * update it as well. Add the TLS and TCB offsets so the + * value in this register is adjusted like in the case of the + * rdhwr trap() instruction handler. + */ + if (cpuinfo.userlocal_reg == true) { + mips_wr_userlocal((unsigned long)(uap->parms + + td->td_md.md_tls_tcb_offset)); + } return (0); case MIPS_GET_TLS: tlsbase = (int32_t)(intptr_t)td->td_md.md_tls;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009251713.08PHDkog059795>