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
This commit is contained in:
Andrew Turner 2018-01-09 14:33:05 +00:00
parent 091da2dfa5
commit 4bb409fb8d
5 changed files with 72 additions and 0 deletions

View file

@ -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();
}
}
}

View file

@ -172,6 +172,7 @@ cpu_startup(void *dummy)
undef_init();
identify_cpu();
install_cpu_errata();
vm_ksubmap_init(&kmi);
bufinit();

View file

@ -282,6 +282,7 @@ init_secondary(uint64_t cpu)
* runtime chip identification.
*/
identify_cpu();
install_cpu_errata();
intr_pic_init_secondary();

View file

@ -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);

View file

@ -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