-/* $OpenBSD: cpu.c,v 1.101 2023/11/23 19:54:30 patrick Exp $ */
+/* $OpenBSD: cpu.c,v 1.102 2023/12/26 09:19:15 kettenis Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
void cpu_flush_bp_noop(void);
void cpu_flush_bp_psci(void);
+void cpu_serror_apple(void);
#if NKSTAT > 0
void cpu_kstat_attach(struct cpu_info *ci);
* The architecture has been updated to explicitly tell us if
* we're not vulnerable to regular Spectre.
*/
-
id = READ_SPECIALREG(id_aa64pfr0_el1);
if (ID_AA64PFR0_CSV2(id) >= ID_AA64PFR0_CSV2_IMPL)
ci->ci_flush_bp = cpu_flush_bp_noop;
* But we might still be vulnerable to Spectre-BHB. If we know the
* CPU, we can add a branchy loop that cleans the BHB.
*/
-
if (impl == CPU_IMPL_ARM) {
switch (part) {
case CPU_PART_CORTEX_A72:
#endif
/* Prefer CLRBHB to mitigate Spectre-BHB. */
-
id = READ_SPECIALREG(id_aa64isar2_el1);
if (ID_AA64ISAR2_CLRBHB(id) >= ID_AA64ISAR2_CLRBHB_IMPL)
ci->ci_trampoline_vectors = (vaddr_t)trampoline_vectors_clrbhb;
/* ECBHB tells us Spectre-BHB is mitigated. */
-
id = READ_SPECIALREG(id_aa64mmfr1_el1);
if (ID_AA64MMFR1_ECBHB(id) >= ID_AA64MMFR1_ECBHB_IMPL)
ci->ci_trampoline_vectors = (vaddr_t)trampoline_vectors_none;
* The architecture has been updated to explicitly tell us if
* we're not vulnerable.
*/
-
id = READ_SPECIALREG(id_aa64pfr0_el1);
if (ID_AA64PFR0_CSV2(id) >= ID_AA64PFR0_CSV2_HCXT) {
ci->ci_flush_bp = cpu_flush_bp_noop;
ci->ci_trampoline_vectors = (vaddr_t)trampoline_vectors_none;
}
+ /*
+ * Apple CPUs provide detailed information for SError.
+ */
+ if (impl == CPU_IMPL_APPLE)
+ ci->ci_serror = cpu_serror_apple;
+
/*
* Print CPU features encoded in the ID registers.
*/
#endif
}
+void
+cpu_serror_apple(void)
+{
+ __asm volatile("dsb sy; isb" ::: "memory");
+ printf("l2c_err_sts 0x%llx\n", READ_SPECIALREG(s3_3_c15_c8_0));
+ printf("l2c_err_adr 0x%llx\n", READ_SPECIALREG(s3_3_c15_c9_0));
+ printf("l2c_err_inf 0x%llx\n", READ_SPECIALREG(s3_3_c15_c10_0));
+}
+
int
cpu_clockspeed(int *freq)
{
-/* $OpenBSD: trap.c,v 1.46 2023/06/10 19:30:48 kettenis Exp $ */
+/* $OpenBSD: trap.c,v 1.47 2023/12/26 09:19:15 kettenis Exp $ */
/*-
* Copyright (c) 2014 Andrew Turner
* All rights reserved.
userret(p);
}
+static void
+serror(struct trapframe *frame)
+{
+ struct cpu_info *ci = curcpu();
+ uint64_t esr, far;
+
+ esr = READ_SPECIALREG(esr_el1);
+ far = READ_SPECIALREG(far_el1);
+
+ printf("SError: %lx esr %llx far %0llx\n",
+ frame->tf_elr, esr, far);
+
+ if (ci->ci_serror)
+ ci->ci_serror();
+}
+
void
do_el0_error(struct trapframe *frame)
{
+ serror(frame);
panic("do_el0_error");
}
+void
+do_el1h_error(struct trapframe *frame)
+{
+ serror(frame);
+ panic("do_el1h_error");
+}
+
void
dumpregs(struct trapframe *frame)
{