From nobody Thu Oct 20 15:04:27 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MtW8q5xp9z4fXtg; Thu, 20 Oct 2022 15:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MtW8q5TpDz42mH; Thu, 20 Oct 2022 15:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666278267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yI+D9Sbcq2oDW4trrZlUsngrCrmkefuI8x7VBwyEdNE=; b=prdRhjCNGQlorwJX+dcsbYYeFi92DrJvRyxk4H/FMuJ3P9pfNyebW1Bu9PLZiNcETgvl13 qJid6243MAmrlDhoJJ+oSnx2Hc5KrYe2ouH3vNqOEYql6GWflM+YHB1C9KVpDGmYyyp610 OB62hBSHOq31eKkEIF89kFSJe89z0R+H/1PZvJz8cPJ/11mXywuIBALfcwohdqeuHs6pfp PFUeVzEknoSv3cVTOclNSDtM7T6uZ19H5AoFFoc1awDdPtR+jKcGFIBT4E2T6UjsjUKYrh zBi1CMemovHzWWNast455Q8o5bsJ+/CRx0qnZDO3ciqH2H4BnZX6opaLXBUPaw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MtW8q4YvVzv78; Thu, 20 Oct 2022 15:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29KF4RgF090664; Thu, 20 Oct 2022 15:04:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29KF4Rh1090663; Thu, 20 Oct 2022 15:04:27 GMT (envelope-from git) Date: Thu, 20 Oct 2022 15:04:27 GMT Message-Id: <202210201504.29KF4Rh1090663@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 330acb188324 - main - riscv: reject CPUs with mmu-type "riscv,none" List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 330acb1883242b5362bb6ccf067de253d3549832 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666278267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yI+D9Sbcq2oDW4trrZlUsngrCrmkefuI8x7VBwyEdNE=; b=fSNU8z3qRM9TB3vuKkAGGLwVyXzgWJ7xtrsBBR6vtsyWzdiggHbgje8lxVuuTu/Wc/B/j3 sqMHGCC+52vhzYDZ1tXCRP7+6hf8M/LPIGQSk9SbJoIMyW4DfZzafk7R6YR6LL3Voqq6bv SL5/soj7SZvTzq/IctIj+YFGIunRW1mL97nEHnEg5tD3iVmK2exKNlL/2A3a1Yefs4zw+M PEw0b8bHeHYMoc34vDkceTLAX0pwUqVZwEVf9bCv/hTnF8lq+YLHXoK/QZZF1pvjW/JVr+ ooMkaYwl9BEnCcOEKZvPfjFngE9pF7A4YXrOIKp3xYM8EMmngS8jY0/+2sW9FQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666278267; a=rsa-sha256; cv=none; b=ElrxSoA9nIRqwzkYExEW3pNcu9Aulv0UvY5kOQOLkX9DyEtjlskQ5K+cK+L+fM0l1Vmf2e bFHy/b50/0lY5nEJbsIgo5FeOx3EPD4xkY3J7w/HchiVyBcmMFuIb4v6vnSF5aBnncExJo xlX4+3Y2yuJ0YIGNuJK4wSKyob5JzmPAtvYda7Qg1Hatlqx614fazKe7W+0ftyjkI+n+LG xuSq5yJDM/saBf5g40+jcpntLwOgobJ/VoO8O9tuDQF77gwJbqEGEJiX8UMqAb5cj9ioZz rZmboWCfYd9fIfxHbd9Wf04mIa9pMFxVIWASWtIQnzUs+kYklR9YF5YR+PX7HA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=330acb1883242b5362bb6ccf067de253d3549832 commit 330acb1883242b5362bb6ccf067de253d3549832 Author: Mitchell Horne AuthorDate: 2022-10-20 14:57:43 +0000 Commit: Mitchell Horne 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) {