NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-mips/59064 (jemalloc switch to 5.3 broke userland)



The following reply was made to PR port-mips/59064; it has been noted by GNATS.

From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
To: Rin Okuyama <rokuyama.rk%gmail.com@localhost>
Cc: Martin Husemann <martin%duskware.de@localhost>, gnats-bugs%netbsd.org@localhost,
	port-mips-maintainer%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
	netbsd-bugs%netbsd.org@localhost, martin%NetBSD.org@localhost
Subject: Re: port-mips/59064 (jemalloc switch to 5.3 broke userland)
Date: Sun, 13 Apr 2025 22:24:04 +0000

 This is a multi-part message in MIME format.
 --=_rFLsIlDMAmZS54PhaM3eE2ii5a8qA3Zz
 
 > Date: Sun, 13 Apr 2025 12:42:29 +0000
 > From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
 > 
 > > Date: Sun, 13 Apr 2025 13:39:54 +0900
 > > From: Rin Okuyama <rokuyama.rk%gmail.com@localhost>
 > > 
 > > I forgot to mention, but userland works even with "initial-exec"
 > > TLS model on QEMU and GXemul for mips somehow. Emulation may be
 > > not precise enough, or our TLS handling relays on some undefined
 > > H/W behaviors?
 > 
 > Is this for emulating the  RDHWR $3,$29  instruction, 0x7c03e83b?
 
 I just tried the attached program on an erlite3 and it seemed to work
 fine, at least for this simple case:
 
 # ./rdhwr
 tcb_syscall 0x10010d70
 tcb_rdhwr 0x10010d70
 
 Will try running atf tests once I finish a build from _after_ the
 bsd.lib.mk change (cleverly kicked off a build from _just before_ it
 and then installed that a couple hours later and realized oops).
 
 --=_rFLsIlDMAmZS54PhaM3eE2ii5a8qA3Zz
 Content-Type: text/plain; charset="ISO-8859-1"; name="rdhwr"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="rdhwr.c"
 
 #include <machine/lwp_private.h>
 
 #include <lwp.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 
 struct tls_tcb tcb_storage[0x8000];
 
 __noinline
 static struct tls_tcb *
 gettcb_rdhwr(void)
 {
 	struct tls_tcb *tcb;
 
 	asm(".set push\n\t"
 	    ".set mips32r2\n\t"
 	    "rdhwr $3,$29\n\t"
 	    "move %[tcb],$3\n\t"
 	    ".set pop"
 	    : [tcb]"=3Dr"(tcb)
 	    :
 	    : "$3");
 
 	return tcb - (TLS_TP_OFFSET/sizeof(*tcb) + 1);
 }
 
 int
 main(void)
 {
 	char buf[1024];
 	struct tls_tcb *tcb_rdhwr, *tcb_syscall;
 
 	__lwp_settcb(tcb_storage);
 
 	tcb_syscall =3D __lwp_gettcb_fast();
 	snprintf_ss(buf, sizeof(buf), "tcb_syscall %p\n", tcb_syscall);
 	(void)write(STDOUT_FILENO, buf, strlen(buf));
 
 	tcb_rdhwr =3D gettcb_rdhwr();
 	snprintf_ss(buf, sizeof(buf), "tcb_rdhwr %p\n", tcb_rdhwr);
 	(void)write(STDOUT_FILENO, buf, strlen(buf));
 
 	return 0;
 }
 
 --=_rFLsIlDMAmZS54PhaM3eE2ii5a8qA3Zz--
 


Home | Main Index | Thread Index | Old Index