From f1f10f33cb6761c847fd59738b6fa84f6c087320 Mon Sep 17 00:00:00 2001 From: kettenis Date: Mon, 22 Nov 2021 19:22:59 +0000 Subject: [PATCH] Hack alert! Apple M1 systems still don't work with an MP kernel. In order to make progress (and protect myself from things dumping cores left and right when I run sysupgrade) abuse the hw.smt mechanism to only schedule processes on the primary CPU. ok deraadt@, patrick@ --- sys/arch/arm64/arm64/cpu.c | 7 ++++++- sys/arch/arm64/include/cpu.h | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c index 8d1618419a7..45694108c29 100644 --- a/sys/arch/arm64/arm64/cpu.c +++ b/sys/arch/arm64/arm64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.56 2021/10/24 17:52:28 mpi Exp $ */ +/* $OpenBSD: cpu.c,v 1.57 2021/11/22 19:22:59 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -605,6 +605,7 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) struct fdt_attach_args *faa = aux; struct cpu_info *ci; uint64_t mpidr = READ_SPECIALREG(mpidr_el1); + uint64_t midr = READ_SPECIALREG(midr_el1); uint64_t id_aa64mmfr1, sctlr; uint32_t opp; @@ -643,6 +644,10 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) int timeout = 10000; int len; + /* XXX SMP on Apple CPUs is busted. */ + if (CPU_IMPL(midr) == CPU_IMPL_APPLE) + ci->ci_smt_id = 1; + len = OF_getprop(ci->ci_node, "enable-method", buf, sizeof(buf)); if (strcmp(buf, "psci") == 0) { diff --git a/sys/arch/arm64/include/cpu.h b/sys/arch/arm64/include/cpu.h index 9f9e4761aae..109dd9c1141 100644 --- a/sys/arch/arm64/include/cpu.h +++ b/sys/arch/arm64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.22 2021/07/06 09:34:06 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.23 2021/11/22 19:22:59 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn * @@ -92,6 +92,11 @@ struct cpu_info { int ci_node; struct cpu_info *ci_self; +#define __HAVE_CPU_TOPOLOGY + u_int32_t ci_smt_id; + u_int32_t ci_core_id; + u_int32_t ci_pkg_id; + struct proc *ci_curproc; struct pmap *ci_curpm; struct proc *ci_fpuproc; -- 2.20.1