git: 330acb188324 - main - riscv: reject CPUs with mmu-type "riscv,none"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 20 Oct 2022 15:04:27 UTC
The branch main has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=330acb1883242b5362bb6ccf067de253d3549832
commit 330acb1883242b5362bb6ccf067de253d3549832
Author: Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-10-20 14:57:43 +0000
Commit: Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-10-20 15:01:29 +0000
riscv: reject CPUs with mmu-type "riscv,none"
According to riscv/cpus.yaml in the device-tree docs, this property may
exist but indicate that the CPU does not have an MMU. Detect this
possibility.
Reviewed by: jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36980
---
sys/riscv/riscv/mp_machdep.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c
index 71eb9a56193e..e7e862d3772b 100644
--- a/sys/riscv/riscv/mp_machdep.c
+++ b/sys/riscv/riscv/mp_machdep.c
@@ -403,6 +403,20 @@ cpu_mp_probe(void)
}
#ifdef FDT
+static boolean_t
+cpu_check_mmu(u_int id __unused, phandle_t node, u_int addr_size __unused,
+ pcell_t *reg __unused)
+{
+ char type[32];
+
+ /* Check if this hart supports MMU. */
+ if (OF_getprop(node, "mmu-type", (void *)type, sizeof(type)) == -1 ||
+ strncmp(type, "riscv,none", 10) == 0)
+ return (0);
+
+ return (1);
+}
+
static boolean_t
cpu_init_fdt(u_int id, phandle_t node, u_int addr_size, pcell_t *reg)
{
@@ -413,8 +427,7 @@ cpu_init_fdt(u_int id, phandle_t node, u_int addr_size, pcell_t *reg)
int naps;
int error;
- /* Check if this hart supports MMU. */
- if (OF_getproplen(node, "mmu-type") < 0)
+ if (!cpu_check_mmu(id, node, addr_size, reg))
return (0);
KASSERT(id < MAXCPU, ("Too many CPUs"));
@@ -521,17 +534,6 @@ cpu_mp_announce(void)
{
}
-static boolean_t
-cpu_check_mmu(u_int id, phandle_t node, u_int addr_size, pcell_t *reg)
-{
-
- /* Check if this hart supports MMU. */
- if (OF_getproplen(node, "mmu-type") < 0)
- return (0);
-
- return (1);
-}
-
void
cpu_mp_setmaxid(void)
{