From nobody Fri Oct 28 14:10:53 2022 X-Original-To: dev-commits-src-branches@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 4MzPbK3S4zz4gB5b; Fri, 28 Oct 2022 14:10:53 +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 4MzPbK2qBXz3j33; Fri, 28 Oct 2022 14:10:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666966253; 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=igI3vzYQaMkZsAd2IetGjHaWr4zlQuDbPSsEenvA8rw=; b=fAw+ElvE1hrbJ7VwralmWlBRH852d2ZcxFV/UsW0djcDvVdFEnK+I4M01VTdxtGMnKjjuj iBHQj2f9d0Y3tiDG/hC8aXpkgEWRCks2KtxJKBj70Px0R8g8nxsV8swC4b7J8a9tcAAg22 mwZ6Wq20IFuQTRwBl7twCv1TwQYqVsHJ0T3/HI+3tQnMOusWDlGeu6V1/UVIIpwpuDIuhG M7LyQx1DcpmLlorXJnw1JPOFuyOFaEAT4vb6TDR6dzP3A2JGWNAf/MUsXiRi462VFfcgyV XFvPjClizQtHKCtUaAVwwTO6O4bdQXOiXQHbCQCCSzO9smFNqN6LZeF2clfKIw== 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 4MzPbK1sc4zgjV; Fri, 28 Oct 2022 14:10:53 +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 29SEArwi037222; Fri, 28 Oct 2022 14:10:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29SEArBI037221; Fri, 28 Oct 2022 14:10:53 GMT (envelope-from git) Date: Fri, 28 Oct 2022 14:10:53 GMT Message-Id: <202210281410.29SEArBI037221@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: d0ede7bd59e5 - stable/13 - riscv: reject CPUs with mmu-type "riscv,none" List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: d0ede7bd59e5fa2222f80a17dd759eb50d38f6c1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666966253; 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=igI3vzYQaMkZsAd2IetGjHaWr4zlQuDbPSsEenvA8rw=; b=NUAfBpsEyeSV5/sS49LB7Q8/78UaXnlNMIGOq3+jcoPKMOvhN/cueQxjgreo60UVl7RQRG wWDYmtuVNp1s+eu/UUiI9xhWF4G+rxmBcoB8fK6yH10t9LoGnKgvvysGn4klNpmgl/QseK UbBguEXMCF8wk4v0qzbdp5c36gR95gGiWE8UN2tDopf7kMrqmdZH/gS6+88MRQV9RmPacL B+KZeVD9Dk/yRDLvdOpl9dY+WBGGu/2doYcxrMa+gtrC+DAH2rVn9qRBXXK/5taP6BoKgh TmbaKycklktzreIH+D7JVqbbDkor75TAzEO0FlFT2UbxENcqeEGiHoG0pCqagg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666966253; a=rsa-sha256; cv=none; b=GmSAnpP1u5yFnuJNacLJUPJEPW6nZ4IQTEfGRmvNVUWY1ZMUTVW0n6/qTHRlgkoUDCWkZ0 4EQBCw2/KFtFGBeiGWMSfHQYYFY1IhzT7ZdZBS5A54AknlSLXHQWt8vT8MfSHeh15DeUjw 3oZY69vahMSppcUbdWPjpoopBvHtQUHPmYsgRl4mWiWpLh0NCHQtS6F+tyCT0w6r2izHVo nJ5XsNWye9wvGmwNHG54GdNwXTtGXV4HyERmcFejF+yw+bg2hjANKMd2ON5cRa1niGoAPi 7EhK95a2sxUrd4jIck65qXuSfxmRYkUDUCN8mLwKWIaNXyBakLiTiqQn2gYlIg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=d0ede7bd59e5fa2222f80a17dd759eb50d38f6c1 commit d0ede7bd59e5fa2222f80a17dd759eb50d38f6c1 Author: Mitchell Horne AuthorDate: 2022-10-20 14:57:43 +0000 Commit: Mitchell Horne CommitDate: 2022-10-28 14:10:37 +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 (cherry picked from commit 330acb1883242b5362bb6ccf067de253d3549832) --- 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 418296deee15..3fb86c5f4c28 100644 --- a/sys/riscv/riscv/mp_machdep.c +++ b/sys/riscv/riscv/mp_machdep.c @@ -405,6 +405,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) { @@ -415,8 +429,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")); @@ -524,17 +537,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) {