From nobody Tue Oct 06 19:10:42 2026 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 4hzm7C2GMQz6Z4gK for ; Tue, 06 Oct 2026 19:10:47 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hzm7C1hGQz4L1X for ; Tue, 06 Oct 2026 19:10:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791313847; 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=mAq9WhhLvU5eGN67ahVxMKG5w6p60gwjTRhNG/+nJ1o=; b=jXQoB36mcBYOgmDxPMW6Ym07+PbfXgupyfu7Nur0wGEmPH2QaKNNUCJKwUcWAURzm15Q5L PwnFsW+6rMqEA5gUP6NmvaCImqzRhb+aqtzX9/xeIFxSaEs7v51SjmE6clPT3kUYrJVGf5 HqWynqOGz878FEXTwqeXN07TASI9ff+0uAwwFs+qDHlpCphqRmB2AfdmpizwKYUwT4zoZP M8DgnUm1enLlbtkAS29XzybD5gQKh0SUmOAQpjFGu4tYssjSHHE5W6gAY8tPL1inee5Hnb f7SdR2YB2aHZMcPmBa3wIlaIlclFxMDetaYwPJ7nwOBg9dyGo2IzLyWG7pcHDA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791313847; b=BqRV+odPFLpY6ZiwjEWex3Hb+c9YjCRLt+juCgy3M1ZrJkwQaTr5Tyj03QJ8ynrk4oDWcG WySXD5k9w9F/Bv89g9iobN0Xn9RET/Sizwa57OeAAHr8bQNRbn3ELKIBN0sOuMVZ70Qytf Iq+NNCnvpivJtMvs8kwrLWbYwETuy7HiC7vei5kqABIWn63QxuSa5J6mgiA43aNyxSkhMh z9khpiJGgMFdRtsWh062rkq+I/3/gMiYrZOIerzJ3JExqkAuxX7Txi5NCuF+w6GbYn1uiA RBPER3c9HnKoy3x+Y82aHMRCk0qht67FLLDoaC+8Tr+/c1hKCII7AX0ZFKX30g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791313847; 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=mAq9WhhLvU5eGN67ahVxMKG5w6p60gwjTRhNG/+nJ1o=; b=eZHaliQUr5+OR7lwVrxxja1kLOCNvBXKMJ8RUi+5KLAtLTqoDCuDIgtauj/EO8lteAK+gT YePyZZGD87p9b2VY/S9qdWSK5HgF+AZJF5mr97tEiO6mPCSd4ZiC/7AM9OFCEOdAauYF/G KzN6OChvt4dhT/AbZzBYc9c+pwZQcTWxKxnKGK8MCmd30zSxjq/SYqNRIO5EVp0Rogs1Oa fpqSzQRNhpsrvhHPm/o1MHV08pXxtqw+rAhSdrIzO6JLD8oNFaT8ebsvwFswHRkGe9VzmT QLW3uuEQfeDL7j6t96qHOKUleD5I6pEhg/zFCe4ZMwZ8/io/5fjCtR+mOqzIsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hzm7C0lQszJsN for ; Tue, 06 Oct 2026 19:10:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 41b9b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 06 Oct 2026 19:10:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ruslan Bukin Subject: git: 3e01ebda6829 - main - riscv: support the new "riscv,isa-extensions" string-array. 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: br X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3e01ebda68291db307a5e6c23d4995c638be9228 Auto-Submitted: auto-generated Date: Tue, 06 Oct 2026 19:10:42 +0000 Message-Id: <6ac547b2.41b9b.2c404c63@gitrepo.freebsd.org> The branch main has been updated by br: URL: https://cgit.FreeBSD.org/src/commit/?id=3e01ebda68291db307a5e6c23d4995c638be9228 commit 3e01ebda68291db307a5e6c23d4995c638be9228 Author: Ruslan Bukin AuthorDate: 2026-10-06 18:55:39 +0000 Commit: Ruslan Bukin CommitDate: 2026-10-06 19:09:04 +0000 riscv: support the new "riscv,isa-extensions" string-array. Support the new "riscv,isa-extensions" property on RISC-V hart nodes in FDT. The "riscv,isa" property is deprecated, but cannot be removed because doing so would break compatibility with existing DTBs. The new properties replace it: "riscv,isa-base" describes the base ISA and "riscv,isa-extensions" is a string array containing the supported ISA extensions. The "riscv,isa-extensions" property can be relatively large; on the Spacemit K3 SoC it is approximately 300 bytes. The FreeBSD OFW interface does not provide access to the underlying FDT property data without copying it, and memory allocation is not possible this early. So allocate a static buffer for the property instead. Reuse the existing parse_riscv_isa() implementation to parse both the new extension property and the legacy "riscv,isa" property. Reviewed by: bnovkov, mhorne Sponsored by: EPSRC ("UKRI3001: CHERI Research Centre") Differential Revision: https://reviews.freebsd.org/D60209 --- sys/riscv/riscv/identcpu.c | 106 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/sys/riscv/riscv/identcpu.c b/sys/riscv/riscv/identcpu.c index ca1b2b9ae1af..81e8afde8499 100644 --- a/sys/riscv/riscv/identcpu.c +++ b/sys/riscv/riscv/identcpu.c @@ -86,6 +86,8 @@ bool has_zicbom; bool has_zicboz; bool has_zicbop; +static char isa_extensions[PAGE_SIZE]; + struct cpu_desc { const char *cpu_mvendor_name; const char *cpu_march_name; @@ -271,14 +273,7 @@ parse_riscv_isa(struct cpu_desc *desc, char *isa, int len) { int i; - /* Check the string prefix. */ - if (strncmp(isa, ISA_PREFIX, ISA_PREFIX_LEN) != 0) { - printf("%s: Unrecognized ISA string: %s\n", __func__, isa); - return (-1); - } - - i = ISA_PREFIX_LEN; - while (i < len) { + for (i = 0; i < len; ) { switch(isa[i]) { case 'a': case 'b': @@ -372,14 +367,82 @@ parse_cbo_fdt(struct cpu_desc *desc, phandle_t node) desc->cboz_block_size = 0; } +static int +parse_isa_extensions(phandle_t node, u_int cpu, struct cpu_desc *desc) +{ + ssize_t len, off, i; + char *ext; + + len = OF_getprop(node, "riscv,isa-extensions", isa_extensions, + sizeof(isa_extensions)); + if (len == -1) + return (ESRCH); + if (len > sizeof(isa_extensions)) + panic("isa_extensions string truncated"); + + for (i = 0; i < len; i++) + isa_extensions[i] = tolower(isa_extensions[i]); + + for (off = 0; off < len; ) { + ext = isa_extensions + off; + if (*ext == '\0') + break; + if (bootverbose) + printf("riscv extension: %s\n", ext); + parse_riscv_isa(desc, ext, strlen(ext)); + off += strlen(ext) + 1; + } + + return (0); +} + +static int +parse_riscv_isa_legacy(phandle_t node, u_int cpu, struct cpu_desc *desc) +{ + u_int hart; + ssize_t len; + int i; + + hart = pcpu_find(cpu)->pc_hart; + + len = OF_getprop(node, "riscv,isa", isa_extensions, + sizeof(isa_extensions)); + if (len == -1) { + printf("%s: could not find 'riscv,isa' property " + "for CPU %d, hart %u\n", __func__, cpu, hart); + return (ESRCH); + } + if (len > sizeof(isa_extensions)) + panic("isa string truncated"); + + if (bootverbose) + printf("hart %d isa: %s\n", hart, isa_extensions); + + /* + * The string is specified to be lowercase, but let's be + * certain. + */ + for (i = 0; i < len; i++) + isa_extensions[i] = tolower(isa_extensions[i]); + + /* Check the string prefix. */ + if (strncmp(isa_extensions, ISA_PREFIX, ISA_PREFIX_LEN) != 0) { + printf("%s: Unrecognized ISA string: %s\n", __func__, + isa_extensions); + return (-1); + } + + return (parse_riscv_isa(desc, &isa_extensions[ISA_PREFIX_LEN], + len - ISA_PREFIX_LEN)); +} + static void identify_cpu_features_fdt(u_int cpu, struct cpu_desc *desc) { - char isa[1024]; phandle_t node; - ssize_t len; pcell_t reg; u_int hart; + int error; node = OF_finddevice("/cpus"); if (node == -1) { @@ -403,26 +466,17 @@ identify_cpu_features_fdt(u_int cpu, struct cpu_desc *desc) reg != hart) continue; - len = OF_getprop(node, "riscv,isa", isa, sizeof(isa)); - KASSERT(len <= sizeof(isa), ("ISA string truncated")); - if (len == -1) { - printf("%s: could not find 'riscv,isa' property " + error = parse_isa_extensions(node, cpu, desc); + if (error != 0) { + /* Fall-back to the legacy riscv,isa string. */ + error = parse_riscv_isa_legacy(node, cpu, desc); + } + if (error != 0) { + printf("%s: could not parse ISA string " "for CPU %d, hart %u\n", __func__, cpu, hart); return; } - if (bootverbose) - printf("hart %d isa: %s\n", hart, isa); - - /* - * The string is specified to be lowercase, but let's be - * certain. - */ - for (int i = 0; i < len; i++) - isa[i] = tolower(isa[i]); - if (parse_riscv_isa(desc, isa, len) != 0) - return; - /* Check MMU features. */ parse_mmu_fdt(desc, node);