diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2017-04-20 16:07:53 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2017-04-20 16:07:53 +0000 |
commit | fd52bc599d337c0abf4747c96640dbf23d2af11c (patch) | |
tree | c973bcbbddab8e39948b581c1b84b96264e4b38c /sys/arch | |
parent | 6e2f0a13cd85db8adb0a3efaeb24bd189a807d95 (diff) |
Get TCB address using the RDHWR instruction instead of __get_tcb().
This gives fast access to the address on systems that implement
the UserLocal register. TCB caching is still used when running
in the single-threaded mode in order not to penalize old systems.
The kernel counterpart of this change must be in place before
using this diff!
With guenther@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/mips64/include/tcb.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/arch/mips64/include/tcb.h b/sys/arch/mips64/include/tcb.h index 3c1ab597ea7..6e7a6b7bedc 100644 --- a/sys/arch/mips64/include/tcb.h +++ b/sys/arch/mips64/include/tcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcb.h,v 1.3 2017/04/20 15:42:26 visa Exp $ */ +/* $OpenBSD: tcb.h,v 1.4 2017/04/20 16:07:52 visa Exp $ */ /* * Copyright (c) 2011 Philip Guenther <guenther@openbsd.org> @@ -42,6 +42,25 @@ __mips64_set_tcb(struct proc *p, void *tcb) /* ELF TLS ABI calls for small TCB, with static TLS data after it */ #define TLS_VARIANT 1 +static inline void * +__mips64_get_tcb(void) +{ + void *tcb; + + /* + * This invokes emulation in kernel if the system does not implement + * the RDHWR instruction or the UserLocal register. + */ + __asm__ volatile ( + " .set push\n" + " .set mips64r2\n" + " rdhwr %0, $29\n" + " .set pop\n" : "=r" (tcb)); + return tcb; +} + +#define TCB_GET() __mips64_get_tcb() + #endif /* _KERNEL */ #endif /* _MACHINE_TCB_H_ */ |