diff options
author | 2016-09-24 21:02:31 +0000 | |
---|---|---|
committer | 2016-09-24 21:02:31 +0000 | |
commit | be8a232610dd06965695bf655916544e160f0de9 (patch) | |
tree | eb4f90b548854409d77d3ee50abf5223c262a64c | |
parent | Build install Config_heavy.pl during build not install (diff) | |
download | wireguard-openbsd-be8a232610dd06965695bf655916544e160f0de9.tar.xz wireguard-openbsd-be8a232610dd06965695bf655916544e160f0de9.zip |
Stick the thread control block pointer into a CPU register on ARMv7.
ok guenther@
-rw-r--r-- | sys/arch/arm/arm/cpuswitch7.S | 6 | ||||
-rw-r--r-- | sys/arch/arm/arm/genassym.cf | 3 | ||||
-rw-r--r-- | sys/arch/arm/include/pcb.h | 3 | ||||
-rw-r--r-- | sys/arch/arm/include/proc.h | 4 | ||||
-rw-r--r-- | sys/arch/arm/include/tcb.h | 30 |
5 files changed, 40 insertions, 6 deletions
diff --git a/sys/arch/arm/arm/cpuswitch7.S b/sys/arch/arm/arm/cpuswitch7.S index f9c75da8d6d..431a890dc94 100644 --- a/sys/arch/arm/arm/cpuswitch7.S +++ b/sys/arch/arm/arm/cpuswitch7.S @@ -1,4 +1,4 @@ -/* $OpenBSD: cpuswitch7.S,v 1.12 2016/08/26 11:59:04 kettenis Exp $ */ +/* $OpenBSD: cpuswitch7.S,v 1.13 2016/09/24 21:02:31 patrick Exp $ */ /* $NetBSD: cpuswitch.S,v 1.41 2003/11/15 08:44:18 scw Exp $ */ /* @@ -262,6 +262,10 @@ ENTRY(cpu_switchto) /* rem: r6 = new proc */ /* rem: r9 = new PCB */ + /* stick tcb into user visable register */ + ldr r3, [r9, #(PCB_TCB)] + mcr CP15_TPIDRURO(r3) + mrs r3, cpsr cps #(PSR_UND32_MODE) diff --git a/sys/arch/arm/arm/genassym.cf b/sys/arch/arm/arm/genassym.cf index 6322e932d96..3937b930c39 100644 --- a/sys/arch/arm/arm/genassym.cf +++ b/sys/arch/arm/arm/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.15 2016/03/24 08:52:30 mpi Exp $ +# $OpenBSD: genassym.cf,v 1.16 2016/09/24 21:02:31 patrick Exp $ # $NetBSD: genassym.cf,v 1.27 2003/11/04 10:33:16 dsl Exp$ # Copyright (c) 1982, 1990 The Regents of the University of California. @@ -99,6 +99,7 @@ member PCB_LR pcb_un.un_32.pcb32_lr member PCB_PC pcb_un.un_32.pcb32_pc member PCB_UND_SP pcb_un.un_32.pcb32_und_sp member pcb_onfault +member pcb_tcb # XXX use USER_SIZEOF in new code whenever possible define USER_SIZE sizeof(struct user) diff --git a/sys/arch/arm/include/pcb.h b/sys/arch/arm/include/pcb.h index 8e0b06a3baf..1f63d2bf044 100644 --- a/sys/arch/arm/include/pcb.h +++ b/sys/arch/arm/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.6 2015/05/05 02:13:46 guenther Exp $ */ +/* $OpenBSD: pcb.h,v 1.7 2016/09/24 21:02:31 patrick Exp $ */ /* $NetBSD: pcb.h,v 1.10 2003/10/13 21:46:39 scw Exp $ */ /* @@ -84,6 +84,7 @@ struct pcb { struct pcb_arm32 un_32; } pcb_un; struct fpe_sp_state pcb_fpstate; /* Floating Point state */ + void *pcb_tcb; }; #endif /* _ARM_PCB_H_ */ diff --git a/sys/arch/arm/include/proc.h b/sys/arch/arm/include/proc.h index 826968c4bd7..865d084fff2 100644 --- a/sys/arch/arm/include/proc.h +++ b/sys/arch/arm/include/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.3 2011/03/23 16:54:34 pirofti Exp $ */ +/* $OpenBSD: proc.h,v 1.4 2016/09/24 21:02:31 patrick Exp $ */ /* $NetBSD: proc.h,v 1.5 2003/03/01 04:36:39 thorpej Exp $ */ /* @@ -47,4 +47,6 @@ struct mdproc { void *pmc_state; /* port-specific pmc state */ }; +#define __HAVE_MD_TCB + #endif /* _ARM_PROC_H_ */ diff --git a/sys/arch/arm/include/tcb.h b/sys/arch/arm/include/tcb.h index 1305f9fb96d..4bba0e541eb 100644 --- a/sys/arch/arm/include/tcb.h +++ b/sys/arch/arm/include/tcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcb.h,v 1.1 2011/10/27 04:01:17 guenther Exp $ */ +/* $OpenBSD: tcb.h,v 1.2 2016/09/24 21:02:31 patrick Exp $ */ /* * Copyright (c) 2011 Philip Guenther <guenther@openbsd.org> @@ -21,13 +21,39 @@ #ifdef _KERNEL -#error "not yet" +#include <machine/pcb.h> + +static inline void +__arm_set_tcb(void *tcb) +{ + __asm volatile("mcr p15, 0, %0, c13, c0, 3\n" : : "r" (tcb)); +} + +#define TCB_GET(p) \ + ((struct pcb *)(p)->p_addr)->pcb_tcb + +#define TCB_SET(p, addr) \ + do { \ + ((struct pcb *)(p)->p_addr)->pcb_tcb = (addr); \ + __arm_set_tcb(addr); \ + } while (0) #else /* _KERNEL */ /* ELF TLS ABI calls for small TCB, with static TLS data after it */ #define TLS_VARIANT 1 +static inline void * +__arm_read_tcb(void) +{ + void *tcb; + __asm volatile("mrc p15, 0, %0, c13, c0, 3\n" : "=r" (tcb)); + return tcb; +} + +#define TCB_GET(p) \ + __arm_read_tcb() + #endif /* _KERNEL */ #endif /* _MACHINE_TCB_H_ */ |