diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2022-01-01 18:52:38 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2022-01-01 18:52:38 +0000 |
commit | 60c991aae884d5e9e686df7df6c758a7ffecf9c9 (patch) | |
tree | aef1042695c342ea2af9cf738bf27560927c9015 /sys/arch/arm64/include | |
parent | 3d36a01a9717514d3c9ddd7c2a988e24eae501b5 (diff) |
Rewrite the kernel FPU handling code. The new code saves the FPU state
in cpu_switch() instead of at the kernel edge and gets rid of the FPU
state tracking in struct cpu_info and struct pcb. This fixes the random
crashes seen with SMP kernels on Apple M1.
ok patrick@
Diffstat (limited to 'sys/arch/arm64/include')
-rw-r--r-- | sys/arch/arm64/include/armreg.h | 4 | ||||
-rw-r--r-- | sys/arch/arm64/include/cpu.h | 3 | ||||
-rw-r--r-- | sys/arch/arm64/include/fpu.h | 28 | ||||
-rw-r--r-- | sys/arch/arm64/include/pcb.h | 3 | ||||
-rw-r--r-- | sys/arch/arm64/include/vfp.h | 52 |
5 files changed, 32 insertions, 58 deletions
diff --git a/sys/arch/arm64/include/armreg.h b/sys/arch/arm64/include/armreg.h index fe96344af2a..51d0373c9bf 100644 --- a/sys/arch/arm64/include/armreg.h +++ b/sys/arch/arm64/include/armreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: armreg.h,v 1.17 2021/09/02 10:48:52 kettenis Exp $ */ +/* $OpenBSD: armreg.h,v 1.18 2022/01/01 18:52:37 kettenis Exp $ */ /*- * Copyright (c) 2013, 2014 Andrew Turner * Copyright (c) 2015 The FreeBSD Foundation @@ -159,7 +159,7 @@ #define ESR_ELx_EC_MASK (0x3f << 26) #define ESR_ELx_EXCEPTION(esr) (((esr) & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT) #define EXCP_UNKNOWN 0x00 /* Unkwn exception */ -#define EXCP_FP_SIMD 0x07 /* VFP/SIMD trap */ +#define EXCP_FP_SIMD 0x07 /* FP/SIMD trap */ #define EXCP_ILL_STATE 0x0e /* Illegal execution state */ #define EXCP_SVC 0x15 /* SVC trap */ #define EXCP_MSR 0x18 /* MSR/MRS trap */ diff --git a/sys/arch/arm64/include/cpu.h b/sys/arch/arm64/include/cpu.h index 109dd9c1141..c09ff800e25 100644 --- a/sys/arch/arm64/include/cpu.h +++ b/sys/arch/arm64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.23 2021/11/22 19:22:59 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.24 2022/01/01 18:52:37 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com> * @@ -99,7 +99,6 @@ struct cpu_info { struct proc *ci_curproc; struct pmap *ci_curpm; - struct proc *ci_fpuproc; u_int32_t ci_randseed; struct pcb *ci_curpcb; diff --git a/sys/arch/arm64/include/fpu.h b/sys/arch/arm64/include/fpu.h new file mode 100644 index 00000000000..74faa8dc0ba --- /dev/null +++ b/sys/arch/arm64/include/fpu.h @@ -0,0 +1,28 @@ +/* $OpenBSD: fpu.h,v 1.1 2022/01/01 18:52:37 kettenis Exp $ */ +/* + * Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _MACHINE_FPU_H +#define _MACHINE_FPU_H + +void fpu_save(struct proc *); +void fpu_load(struct proc *); +void fpu_drop(void); + +void fpu_kernel_enter(void); +void fpu_kernel_exit(void); + +#endif /* !_MACHINE_FPU_H */ diff --git a/sys/arch/arm64/include/pcb.h b/sys/arch/arm64/include/pcb.h index d56a1c1f7ab..968236180cc 100644 --- a/sys/arch/arm64/include/pcb.h +++ b/sys/arch/arm64/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.4 2018/07/04 17:52:29 drahn Exp $ */ +/* $OpenBSD: pcb.h,v 1.5 2022/01/01 18:52:37 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com> * @@ -38,7 +38,6 @@ struct pcb { caddr_t pcb_onfault; // On fault handler struct fpreg pcb_fpstate; // Floating Point state */ - struct cpu_info *pcb_fpcpu; void *pcb_tcb; }; diff --git a/sys/arch/arm64/include/vfp.h b/sys/arch/arm64/include/vfp.h deleted file mode 100644 index cc060163130..00000000000 --- a/sys/arch/arm64/include/vfp.h +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: vfp.h,v 1.4 2018/07/02 07:23:37 kettenis Exp $ */ -/*- - * Copyright (c) 2015 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Andrew Turner under - * sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: head/sys/arm64/include/vfp.h 281494 2015-04-13 14:43:10Z andrew $ - */ - -#ifndef _MACHINE_VFP_H_ -#define _MACHINE_VFP_H_ - -#ifdef _KERNEL - -#define VFP_KFPEN (1 << 20) -#define VFP_UFPEN (3 << 20) - -#ifndef LOCORE -void vfp_discard(struct proc *); -void vfp_save(void); -void vfp_enable(void); -int vfp_fault(vaddr_t, uint32_t, trapframe_t *, int); -void vfp_kernel_enter(void); -void vfp_kernel_exit(void); -#endif - -#endif - -#endif /* !_MACHINE_VFP_H_ */ |