svn commit: r327727 - in head/sys: arm64/arm64 arm64/include conf
Andrew Turner
andrew at FreeBSD.org
Tue Jan 9 14:33:07 UTC 2018
Author: andrew
Date: Tue Jan 9 14:33:05 2018
New Revision: 327727
URL: https://svnweb.freebsd.org/changeset/base/327727
Log:
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
Added:
head/sys/arm64/arm64/cpu_errata.c (contents, props changed)
Modified:
head/sys/arm64/arm64/machdep.c
head/sys/arm64/arm64/mp_machdep.c
head/sys/arm64/include/cpu.h
head/sys/conf/files.arm64
Added: head/sys/arm64/arm64/cpu_errata.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/sys/arm64/arm64/cpu_errata.c Tue Jan 9 14:33:05 2018 (r327727)
@@ -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();
+ }
+ }
+}
Modified: head/sys/arm64/arm64/machdep.c
==============================================================================
--- head/sys/arm64/arm64/machdep.c Tue Jan 9 14:22:18 2018 (r327726)
+++ head/sys/arm64/arm64/machdep.c Tue Jan 9 14:33:05 2018 (r327727)
@@ -172,6 +172,7 @@ cpu_startup(void *dummy)
undef_init();
identify_cpu();
+ install_cpu_errata();
vm_ksubmap_init(&kmi);
bufinit();
Modified: head/sys/arm64/arm64/mp_machdep.c
==============================================================================
--- head/sys/arm64/arm64/mp_machdep.c Tue Jan 9 14:22:18 2018 (r327726)
+++ head/sys/arm64/arm64/mp_machdep.c Tue Jan 9 14:33:05 2018 (r327727)
@@ -282,6 +282,7 @@ init_secondary(uint64_t cpu)
* runtime chip identification.
*/
identify_cpu();
+ install_cpu_errata();
intr_pic_init_secondary();
Modified: head/sys/arm64/include/cpu.h
==============================================================================
--- head/sys/arm64/include/cpu.h Tue Jan 9 14:22:18 2018 (r327726)
+++ head/sys/arm64/include/cpu.h Tue Jan 9 14:33:05 2018 (r327727)
@@ -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);
Modified: head/sys/conf/files.arm64
==============================================================================
--- head/sys/conf/files.arm64 Tue Jan 9 14:22:18 2018 (r327726)
+++ head/sys/conf/files.arm64 Tue Jan 9 14:33:05 2018 (r327727)
@@ -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
More information about the svn-src-all
mailing list