diff options
author | Andrew Turner <andrew@FreeBSD.org> | 2018-01-09 14:33:05 +0000 |
---|---|---|
committer | Andrew Turner <andrew@FreeBSD.org> | 2018-01-09 14:33:05 +0000 |
commit | 4bb409fb8d8757d8c3cc0221d65150a57e444139 (patch) | |
tree | 8df36b542d92ca54a279bb59d3993d8dbdeb45e1 | |
parent | 091da2dfa536fe4ae8ac1e5c807296196b6d2184 (diff) | |
download | src-4bb409fb8d8757d8c3cc0221d65150a57e444139.tar.gz src-4bb409fb8d8757d8c3cc0221d65150a57e444139.zip |
Add a framework to install CPU errata on arm64. Each erratum can encode
a mask and value to compare with the Main ID Register. If these match then a
function is called to handle the installation of the erratum workaround.
No errata are currently handled, however this will change soon in a future
commit.
MFC after: 1 week
Sponsored by: DARPA, AFRL
Notes
Notes:
svn path=/head/; revision=327727
-rw-r--r-- | sys/arm64/arm64/cpu_errata.c | 68 | ||||
-rw-r--r-- | sys/arm64/arm64/machdep.c | 1 | ||||
-rw-r--r-- | sys/arm64/arm64/mp_machdep.c | 1 | ||||
-rw-r--r-- | sys/arm64/include/cpu.h | 1 | ||||
-rw-r--r-- | sys/conf/files.arm64 | 1 |
5 files changed, 72 insertions, 0 deletions
diff --git a/sys/arm64/arm64/cpu_errata.c b/sys/arm64/arm64/cpu_errata.c new file mode 100644 index 000000000000..915c6453d643 --- /dev/null +++ b/sys/arm64/arm64/cpu_errata.c @@ -0,0 +1,68 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2018 Andrew Turner + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/pcpu.h> + +#include <machine/cpu.h> + +typedef void (cpu_quirk_install)(void); +struct cpu_quirks { + cpu_quirk_install *quirk_install; + u_int midr_mask; + u_int midr_value; +}; + +static cpu_quirk_install install_psci_bp_hardening; + +static struct cpu_quirks cpu_quirks[] = { +}; + +void +install_cpu_errata(void) +{ + u_int midr; + size_t i; + + midr = get_midr(); + + for (i = 0; i < nitems(cpu_quirks); i++) { + if ((midr & cpu_quirks[i].midr_mask) == + cpu_quirks[i].midr_value) { + cpu_quirks[i].quirk_install(); + } + } +} diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index 157081d68dd4..8df2d3226d8a 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -172,6 +172,7 @@ cpu_startup(void *dummy) undef_init(); identify_cpu(); + install_cpu_errata(); vm_ksubmap_init(&kmi); bufinit(); diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index 2b2d7f8fbe2c..9ea0a2ba400c 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -282,6 +282,7 @@ init_secondary(uint64_t cpu) * runtime chip identification. */ identify_cpu(); + install_cpu_errata(); intr_pic_init_secondary(); diff --git a/sys/arm64/include/cpu.h b/sys/arm64/include/cpu.h index 51e86c1e7671..a35584def97b 100644 --- a/sys/arm64/include/cpu.h +++ b/sys/arm64/include/cpu.h @@ -150,6 +150,7 @@ void cpu_halt(void) __dead2; void cpu_reset(void) __dead2; void fork_trampoline(void); void identify_cpu(void); +void install_cpu_errata(void); void print_cpu_features(u_int); void swi_vm(void *v); diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index b4df2843e93a..a4e86bc35ffb 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -96,6 +96,7 @@ arm64/arm64/bzero.S standard arm64/arm64/clock.c standard arm64/arm64/copyinout.S standard arm64/arm64/copystr.c standard +arm64/arm64/cpu_errata.c standard arm64/arm64/cpufunc_asm.S standard arm64/arm64/db_disasm.c optional ddb arm64/arm64/db_interface.c optional ddb |