Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2217130/?format=api
{ "id": 2217130, "url": "http://patchwork.ozlabs.org/api/patches/2217130/?format=api", "web_url": "http://patchwork.ozlabs.org/project/opensbi/patch/20260327171601.169103-4-dave.patel@riscstar.com/", "project": { "id": 67, "url": "http://patchwork.ozlabs.org/api/projects/67/?format=api", "name": "OpenSBI development", "link_name": "opensbi", "list_id": "opensbi.lists.infradead.org", "list_email": "opensbi@lists.infradead.org", "web_url": "https://github.com/riscv/opensbi", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "https://github.com/riscv/opensbi/commit/{}" }, "msgid": "<20260327171601.169103-4-dave.patel@riscstar.com>", "list_archive_url": null, "date": "2026-03-27T17:16:01", "name": "[v3,3/3] lib: sbi: domain FP/Vector context support for context switch", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "c7e7a89c536cded68cde6c67f484a51090b1b12c", "submitter": { "id": 92617, "url": "http://patchwork.ozlabs.org/api/people/92617/?format=api", "name": "Dave Patel", "email": "dave.patel@riscstar.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/opensbi/patch/20260327171601.169103-4-dave.patel@riscstar.com/mbox/", "series": [ { "id": 497803, "url": "http://patchwork.ozlabs.org/api/series/497803/?format=api", "web_url": "http://patchwork.ozlabs.org/project/opensbi/list/?series=497803", "date": "2026-03-27T17:15:58", "name": "Add eager FP and RISC-V vector context switching support", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/497803/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2217130/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2217130/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=tKcnl1YP;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=riscstar-com.20230601.gappssmtp.com\n header.i=@riscstar-com.20230601.gappssmtp.com header.a=rsa-sha256\n header.s=20230601 header.b=DHq/YMEt;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fj6kF2lLLz1yFr\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 28 Mar 2026 04:16:21 +1100 (AEDT)", "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w6An8-00000007qVz-47kX;\n\tFri, 27 Mar 2026 17:16:14 +0000", "from mail-wr1-x431.google.com ([2a00:1450:4864:20::431])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w6An6-00000007qTc-3CF6\n\tfor opensbi@lists.infradead.org;\n\tFri, 27 Mar 2026 17:16:14 +0000", "by mail-wr1-x431.google.com with SMTP id\n ffacd0b85a97d-43b8e8e7432so1916240f8f.1\n for <opensbi@lists.infradead.org>;\n Fri, 27 Mar 2026 10:16:12 -0700 (PDT)", "from Dev-EliteBook.Home (97e782b0.skybroadband.com.\n [151.231.130.176])\n by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-43b9192e3f9sm17150785f8f.7.2026.03.27.10.16.09\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 27 Mar 2026 10:16:09 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=P0NUEZYgVCGlX8CZSluM8SNkhbxi2Bp4OwGB5uZcI1c=; b=tKcnl1YPcvpzsA\n\tiZA1jtE2o9Q4/a+jNpHl7fQulBPpZB3PSPFZf2EucXAt6ggUQVGVP4r9PEgpaX40eT4QtdmIx53RD\n\tmgOjH80V/t+O8+MxKjJjP9AsZHtI8ocC4XtseUwGPtYcvdKlgKUzeRgXRvMgk2WGbegVB0IBKJidT\n\tW1gWZzTcHFCC/0XM+Ydh+JhTdk0ShpmE4TAaTOpQl5Lbu1YFbCa6l0bCYITWr/a90OkJVV8dIrYGc\n\tN8jNIYXdvBeu8gQCVfeElp0IOAiAzcooSSWhZ1jhiF5sggKGGIOsq3VXZqCTlaa7Xxnh/+sYjwupY\n\t/XwFH+eRtx4a5JrYvwWQ==;", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1774631771;\n x=1775236571; darn=lists.infradead.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=I+rIauy1Qs7HhuqXRDh0FGqM5SuPe+eQaQIqqjrRpr8=;\n b=DHq/YMEtJRNH8xNPbsTEzD86N0r+YxeLzKTpFB7vvumye4SnR9YmBL2WCwas5l3oMP\n DIQtIbrz4lc6umZK46vHwXoCHRpsff2tOkCAR3W0ee8slbayoSfddQT5EFZW8lJAiW7M\n uHv5mWne8BA+SQ0cxciKzM94rdctIyAsFHD3vMWbd8665Y8N8Ybentla2xaDrobS7jk3\n 1UHzsC/94At1GecnVRxTGythSRXmWnkeaquWUqG2POr9LdlYllLbfwdQRXuvMfeBbfc6\n zlViCK8DDTa1bbt0uxTzK3OG9wKjIYVYOTJv/+fhGTolBb/6NbAUk0ORs2LALGsH4TbP\n jELw==" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774631771; x=1775236571;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=I+rIauy1Qs7HhuqXRDh0FGqM5SuPe+eQaQIqqjrRpr8=;\n b=UxS8ylkeWpXO9JF7zHvRWymwjPe17QC1sXXOGnQVMvaghz60WetSooOBlAKWeXybZQ\n 2nZjk8nVOR9inAGwpLIh7QDpPd1Yc5GkJ1x5nREowNbnjGjFlT62c7bMbd8UYitojB5h\n L0P8WZla+zbQautCU8PLQRj7hVOTeMm72/iFUzPJBIEgoVnk0nrwLFy+hd1t4tDv7jKA\n O9VDtcGBI0peU/8e3AOL6XZLAYqN6rIjxlbZvsRVP43QBHk4mqVithlmttOodaCUck3J\n XAbSF6MCvuavAXyotGF/c+SWoVq4v0aifLZkjdnYaZkqS1jn/60ZCV6ZL8FnWG4Zfxra\n eNvQ==", "X-Forwarded-Encrypted": "i=1;\n AJvYcCXVFkU1qvWedikKp7ndCaB4/FaP/6O/jWSgSZn6KlgbFgzGNzbK0Lg5BBCqgEu/PPEdyLb9Mlse@lists.infradead.org", "X-Gm-Message-State": "AOJu0YzcWV5UwUoOEp+zIB/fzOyG9lLabRuMz561SQe2CjXA9a7/Uyls\n\t7JMWvt+yE1zgONC1a7Jhj8DSKQWBRjsp24paMygK14G1IzL+gU1pwrRgGgdj2hXZko8=", "X-Gm-Gg": "ATEYQzz0DdQjPsQSF3XdrMTBR6sLC20McbJibvxtUVRC6b0hKc0pDlBfDz7ncsYGFm6\n\tqZdybGUR16McWWGwkxoIl2sM0inbg4vNpwImE35yz/UzzESLY0HiU+ILK7IjzgIdXspnm+0oiqN\n\tLffgyC10cC3VFY33PyTIFZ01i+fiH6H0UIVsNaRXF8xxh97sMSn5cY9Mv0I3hmPU08d1gMAmkGB\n\tlvwh6xHw/52KlNefIjYj4RbYLTJ/rKrKnSxGNqkkuVUJ2r2QuSB2BiO5dskInDQgjydFgVd5DXe\n\tNdg4sa8WKD/O4+CJwQcqnJOx79bpC4fZRN9OaLlzkb2nJrYWvvngklcJxkeSqpiZZi2g7H5vCWP\n\tTNkHUpvwZYoeMriIems0u5IAIS5OwEpReOY5DtfkYU6dXgCconbZ956g4HlpvFYm5Q+bqrttf/N\n\tN+NsXa6mImoWHY3jLJsDVSkDoU1tP/ygsdcHPYzxWooUZ7hAQFqN5HuK+JoThbf/qImD7XXAanS\n\tglhBQ==", "X-Received": "by 2002:a05:6000:310c:b0:43b:3b80:6776 with SMTP id\n ffacd0b85a97d-43b9e9ee8f2mr6122613f8f.30.1774631770844;\n Fri, 27 Mar 2026 10:16:10 -0700 (PDT)", "From": "dave.patel@riscstar.com", "To": "Samuel Holland <samuel.holland@sifive.com>", "Cc": "Scott Bambrough <scott@riscstar.com>,\n\tRobin Randhawa <robin.randhawa@sifive.com>,\n\tAnup Patel <anup.patel@qti.qualcomm.com>,\n\tDave Patel <dave.patel@riscstar.com>,\n\tRay Mao <raymond.mao@riscstar.com>,\n\tAnup Patel <anuppate@qti.qualcomm.com>,\n\tDhaval <dhaval@rivosinc.com>,\n\tPeter Lin <peter.lin@sifive.com>,\n\topensbi@lists.infradead.org", "Subject": "[PATCH v3 3/3] lib: sbi: domain FP/Vector context support for context\n switch", "Date": "Fri, 27 Mar 2026 17:16:01 +0000", "Message-ID": "<20260327171601.169103-4-dave.patel@riscstar.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260327171601.169103-1-dave.patel@riscstar.com>", "References": "<20260327171601.169103-1-dave.patel@riscstar.com>", "MIME-Version": "1.0", "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ", "X-CRM114-CacheID": "sfid-20260327_101612_884417_FB84E24B ", "X-CRM114-Status": "GOOD ( 19.36 )", "X-Spam-Score": "-1.9 (-)", "X-Spam-Report": "Spam detection software,\n running on the system \"bombadil.infradead.org\",\n has NOT identified this incoming email as spam. The original\n message has been attached to this so you can view it or label\n similar future email. If you have any questions, see\n the administrator of that system for details.\n Content preview: From: Dave Patel <dave.patel@riscstar.com> This patch adds\n proper support for per-domain floating-point (FP) and vector (V) contexts\n in the domain context switch logic. Each domain now maintains its own FP\n and vector state, which is saved and [...]\n Content analysis details: (-1.9 points, 5.0 required)\n pts rule name description\n ---- ----------------------\n --------------------------------------------------\n -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no\n trust\n [2a00:1450:4864:20:0:0:0:431 listed in]\n [list.dnswl.org]\n -0.0 SPF_PASS SPF: sender matches SPF record\n 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record\n 0.1 DKIM_SIGNED Message has a DKIM or DK signature,\n not necessarily valid\n -0.1 DKIM_VALID Message has at least one valid DKIM or DK\n signature\n -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%\n [score: 0.0000]", "X-BeenThere": "opensbi@lists.infradead.org", "X-Mailman-Version": "2.1.34", "Precedence": "list", "List-Id": "<opensbi.lists.infradead.org>", "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/opensbi>,\n <mailto:opensbi-request@lists.infradead.org?subject=unsubscribe>", "List-Archive": "<http://lists.infradead.org/pipermail/opensbi/>", "List-Post": "<mailto:opensbi@lists.infradead.org>", "List-Help": "<mailto:opensbi-request@lists.infradead.org?subject=help>", "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/opensbi>,\n <mailto:opensbi-request@lists.infradead.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "\"opensbi\" <opensbi-bounces@lists.infradead.org>", "Errors-To": "opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org" }, "content": "From: Dave Patel <dave.patel@riscstar.com>\n\nThis patch adds proper support for per-domain floating-point (FP) and\nvector (V) contexts in the domain context switch logic. Each domain\nnow maintains its own FP and vector state, which is saved and restored\nduring domain switches.\n\nChanges include:\n\n- Added `fp_ctx` and `vec_ctx` members to `struct sbi_domain`.\n- Introduced `sbi_fp_domain_init/exit()` and `sbi_vector_domain_init/exit()`\n to allocate and free per-domain FP and vector context.\n- Modified `sbi_domain_register()` to initialize FP/Vector context per domain.\n- Updated `switch_to_next_domain_context()` to save/restore FP and vector\n contexts safely:\n - Ensures FS/VS fields in `mstatus` are enabled (set to Initial) only if Off.\n - Restores original FS/VS bits after context switch.\n - Adds NULL checks to handle domains without FP or Vector extensions.\n- Updated domain context deinit to free FP and vector contexts per domain.\n- Added runtime checks for FP and vector extensions where needed.\n- Corrected handling of MSTATUS FS/VS bits to avoid unsafe full-bit writes.\n\nThis improves support for multi-domain systems with FP and Vector\nextensions, and prevents corruption of FP/Vector state during domain\nswitches.\n\nSigned-off-by: Dave Patel <dave.patel@riscstar.com>\n---\n include/sbi/sbi_domain.h | 4 +++\n include/sbi/sbi_fp.h | 5 +++\n include/sbi/sbi_vector.h | 5 +++\n lib/sbi/sbi_domain.c | 22 ++++++++++++\n lib/sbi/sbi_domain_context.c | 42 +++++++++++++++++++++++\n lib/sbi/sbi_fp.c | 37 ++++++++++++++++++++\n lib/sbi/sbi_vector.c | 65 +++++++++++++++++++++++++++++-------\n 7 files changed, 168 insertions(+), 12 deletions(-)\n\n--\n2.43.0", "diff": "diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h\nindex 882b62c2..8f0bdbb6 100644\n--- a/include/sbi/sbi_domain.h\n+++ b/include/sbi/sbi_domain.h\n@@ -217,6 +217,10 @@ struct sbi_domain {\n \tbool fw_region_inited;\n \t/** per-domain wired-IRQ courier state */\n \tvoid *virq_priv;\n+ /** per-domain float context state */\n+\tvoid *fp_ctx;\n+ /** per-domain vector context state */\n+ \tvoid *vec_ctx;\n };\n\n /** The root domain instance */\ndiff --git a/include/sbi/sbi_fp.h b/include/sbi/sbi_fp.h\nindex 8079bb3b..6ba04b61 100644\n--- a/include/sbi/sbi_fp.h\n+++ b/include/sbi/sbi_fp.h\n@@ -10,6 +10,9 @@\n\n #include <sbi/riscv_encoding.h>\n #include <sbi/sbi_types.h>\n+#include <sbi/sbi_domain.h>\n+#include <sbi/sbi_error.h>\n+#include <sbi/sbi_console.h>\n\n #if defined(__riscv_f) || defined(__riscv_d)\n\n@@ -32,5 +35,7 @@ struct sbi_fp_context { };\n\n void sbi_fp_save(struct sbi_fp_context *dst);\n void sbi_fp_restore(const struct sbi_fp_context *src);\n+int sbi_fp_domain_init(struct sbi_domain *dom);\n+void sbi_fp_domain_exit(struct sbi_domain *dom);\n\n #endif //__SBI_VECTOR_H__\ndiff --git a/include/sbi/sbi_vector.h b/include/sbi/sbi_vector.h\nindex 4ecfaa0b..345be3bf 100644\n--- a/include/sbi/sbi_vector.h\n+++ b/include/sbi/sbi_vector.h\n@@ -10,6 +10,9 @@\n #define __SBI_VECTOR_H__\n\n #include <sbi/sbi_types.h>\n+#include <sbi/sbi_domain.h>\n+#include <sbi/sbi_error.h>\n+#include <sbi/sbi_console.h>\n\n #define SBI_MAX_VLENB CONFIG_SBI_MAX_VLENB\n\n@@ -25,6 +28,8 @@ struct sbi_vector_context {\n\n void sbi_vector_save(struct sbi_vector_context *dst);\n void sbi_vector_restore(const struct sbi_vector_context *src);\n+int sbi_vector_domain_init(struct sbi_domain *dom);\n+void sbi_vector_domain_exit(struct sbi_domain *dom);\n\n #endif //__SBI_VECTOR_H__\n\ndiff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c\nindex 498a1d56..cdc416b4 100644\n--- a/lib/sbi/sbi_domain.c\n+++ b/lib/sbi/sbi_domain.c\n@@ -19,6 +19,8 @@\n #include <sbi/sbi_scratch.h>\n #include <sbi/sbi_string.h>\n #include <sbi/sbi_virq.h>\n+#include <sbi/sbi_vector.h>\n+#include <sbi/sbi_fp.h>\n\n SBI_LIST_HEAD(domain_list);\n\n@@ -703,6 +705,26 @@ int sbi_domain_register(struct sbi_domain *dom,\n \t\treturn rc;\n \t}\n\n+\t/* Init per-domain floating context */\n+\trc = sbi_fp_domain_init(dom);\n+\tif (rc) {\n+\t\tsbi_printf(\"%s: fp init failed for %s (error %d)\\n\",\n+\t\t\t\t__func__, dom->name, rc);\n+\t\tsbi_list_del(&dom->node);\n+\t\treturn rc;\n+\t}\n+\n+#ifdef __riscv_v\n+ /* Init per-domain vector context */\n+\trc = sbi_vector_domain_init(dom);\n+\tif (rc) {\n+\t\tsbi_printf(\"%s: vec init failed for %s (error %d)\\n\",\n+\t\t\t\t__func__, dom->name, rc);\n+\t\tsbi_list_del(&dom->node);\n+\t\treturn rc;\n+\t}\n+#endif\n+\n \treturn 0;\n }\n\ndiff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c\nindex 158f4990..fb843a91 100644\n--- a/lib/sbi/sbi_domain_context.c\n+++ b/lib/sbi/sbi_domain_context.c\n@@ -18,6 +18,9 @@\n #include <sbi/sbi_domain_context.h>\n #include <sbi/sbi_platform.h>\n #include <sbi/sbi_trap.h>\n+#include <sbi/sbi_vector.h>\n+#include <sbi/sbi_fp.h>\n+\n\n /** Context representation for a hart within a domain */\n struct hart_context {\n@@ -143,6 +146,37 @@ static int switch_to_next_domain_context(struct hart_context *ctx,\n \tif (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSQOSID))\n \t\tctx->srmcfg\t= csr_swap(CSR_SRMCFG, dom_ctx->srmcfg);\n\n+ /* Read current mstatus */\n+ unsigned long mstatus = csr_read(CSR_MSTATUS);\n+ unsigned long new_mstatus = mstatus;\n+\n+ /* Ensure FS is enabled (not Off) */\n+ if ((mstatus & MSTATUS_FS) == 0)\n+ new_mstatus |= MSTATUS_FS;\n+\n+#ifdef __riscv_v\n+ /* Ensure VS is enabled (not Off) */\n+ if ((mstatus & MSTATUS_VS) == 0)\n+ new_mstatus |= MSTATUS_VS;\n+#endif\n+\n+ /* Update mstatus only if needed */\n+ if (new_mstatus != mstatus)\n+ csr_write(CSR_MSTATUS, new_mstatus);\n+\n+ /* Save current domain context and restore target domain's F and V context */\n+ sbi_fp_save(current_dom->fp_ctx);\n+ sbi_fp_restore(target_dom->fp_ctx);\n+#ifdef __riscv_v\n+ sbi_vector_save(current_dom->vec_ctx);\n+ sbi_vector_restore(target_dom->vec_ctx);\n+#endif\n+\n+ /* Restore original mstatus if we modified it */\n+ if (new_mstatus != mstatus) {\n+ csr_write(CSR_MSTATUS, mstatus);\n+ }\n+\n \t/* Save current trap state and restore target domain's trap state */\n \ttrap_ctx = sbi_trap_get_context(scratch);\n \tsbi_memcpy(&ctx->trap_ctx, trap_ctx, sizeof(*trap_ctx));\n@@ -286,5 +320,13 @@ int sbi_domain_context_init(void)\n\n void sbi_domain_context_deinit(void)\n {\n+ struct sbi_domain *dom;\n+ sbi_domain_for_each(dom) {\n+#ifdef __riscv_v\n+ sbi_vector_domain_exit(dom);\n+#endif\n+ sbi_fp_domain_exit(dom);\n+ }\n+\n \tsbi_domain_unregister_data(&dcpriv);\n }\ndiff --git a/lib/sbi/sbi_fp.c b/lib/sbi/sbi_fp.c\nindex 5d72b72e..37acb07c 100644\n--- a/lib/sbi/sbi_fp.c\n+++ b/lib/sbi/sbi_fp.c\n@@ -7,6 +7,7 @@\n */\n\n #include <sbi/riscv_asm.h>\n+#include <sbi/sbi_heap.h>\n #include <sbi/riscv_encoding.h>\n #include <sbi/sbi_fp.h>\n\n@@ -185,7 +186,43 @@ void sbi_fp_restore(const struct sbi_fp_context *src)\n\n \tcsr_write(CSR_FCSR, src->fcsr);\n }\n+\n+int sbi_fp_domain_init(struct sbi_domain *dom)\n+{\n+ if (!dom)\n+ return SBI_EINVAL;\n+\n+ if (dom->fp_ctx)\n+ return SBI_OK;\n+\n+ sbi_printf(\"[FPU] Init FP Context \\n\");\n+\n+ struct sbi_fp_context *fp;\n+ fp = sbi_zalloc(sizeof(*fp));\n+ if (!fp)\n+ return SBI_ENOMEM;\n+\n+ dom->fp_ctx = fp;\n+\n+ return SBI_OK;\n+}\n+\n+void sbi_fp_domain_exit(struct sbi_domain *dom)\n+{\n+ if (!dom || !dom->fp_ctx)\n+ return;\n+\n+ sbi_free(dom->fp_ctx);\n+ dom->fp_ctx = NULL;\n+}\n+\n #else\n+\n void sbi_fp_save(struct sbi_fp_context *dst) {}\n void sbi_fp_restore(const struct sbi_fp_context *src) {}\n+int sbi_fp_domain_init(struct sbi_domain *dom)\n+{\n+\treturn SBI_OK;\n+}\n+void sbi_fp_domain_exit(struct sbi_domain *dom) {}\n #endif // FP present\ndiff --git a/lib/sbi/sbi_vector.c b/lib/sbi/sbi_vector.c\nindex 5a3f34d7..959566c1 100644\n--- a/lib/sbi/sbi_vector.c\n+++ b/lib/sbi/sbi_vector.c\n@@ -12,21 +12,23 @@\n #include <sbi/sbi_vector.h>\n #include <sbi/sbi_types.h>\n #include <sbi/sbi_hart.h>\n+#include <sbi/sbi_heap.h>\n\n #ifdef OPENSBI_CC_SUPPORT_VECTOR\n+#define VLEN_MAX 65536\n\n static inline void vsetvl(ulong vl, ulong vtype)\n {\n- ulong tmp;\n-\n- asm volatile(\n-\t\".option push\\n\\t\"\n-\t\".option arch, +v\\n\\t\"\n-\t\"vsetvl %0, %1, %2\\n\\t\"\n-\t\".option pop\\n\\t\"\n-\t: \"=r\"(tmp)\n-\t: \"r\"(vl), \"r\"(vtype)\n-\t: \"memory\");\n+\tulong tmp;\n+\n+\tasm volatile(\n+\t\t\".option push\\n\\t\"\n+\t\t\".option arch, +v\\n\\t\"\n+\t\t\"vsetvl %0, %1, %2\\n\\t\"\n+\t\t\".option pop\\n\\t\"\n+\t\t: \"=r\"(tmp)\n+\t\t: \"r\"(vl), \"r\"(vtype)\n+\t\t: \"memory\");\n }\n\n static inline unsigned long vector_vlenb(void)\n@@ -64,7 +66,7 @@ void sbi_vector_save(struct sbi_vector_context *dst)\n\n \t/* Step 1: Save CSRs */\n \tREAD_CSR(dst->vtype, vtype);\n-\tREAD_CSR(dst->vl, vl);\n+\tREAD_CSR(dst->vl,\t vl);\n \tREAD_CSR(dst->vcsr, vcsr);\n \tREAD_CSR(dst->vstart, vstart);\n\n@@ -194,12 +196,41 @@ void sbi_vector_restore(const struct sbi_vector_context *src)\n\n \t/* Restore CSRs first */\n \tWRITE_CSR(vtype, src->vtype);\n-\tWRITE_CSR(vl, src->vl);\n+\tWRITE_CSR(vl,\t src->vl);\n \tWRITE_CSR(vcsr, src->vcsr);\n \tWRITE_CSR(vstart, src->vstart);\n #undef WRITE_CSR\n }\n\n+int sbi_vector_domain_init(struct sbi_domain *dom)\n+{\n+\tif (!dom)\n+\t\treturn SBI_EINVAL;\n+\n+\tif (dom->vec_ctx)\n+\t\treturn SBI_OK;\n+\n+\tsbi_printf(\"[Vector] Init Vector Context \\n\");\n+\n+\tstruct sbi_vector_context *v;\n+\tv = sbi_zalloc(sizeof(*v));\n+\tif (!v)\n+\t\treturn SBI_ENOMEM;\n+\n+\tdom->vec_ctx = v;\n+\n+\treturn SBI_OK;\n+}\n+\n+void sbi_vector_domain_exit(struct sbi_domain *dom)\n+{\n+\tif (!dom || !dom->vec_ctx)\n+\t\treturn;\n+\n+\tsbi_free(dom->vec_ctx);\n+\tdom->vec_ctx = NULL;\n+}\n+\n #else\n\n void sbi_vector_save(struct sbi_vector_context *dst)\n@@ -212,4 +243,14 @@ void sbi_vector_restore(const struct sbi_vector_context *src)\n \treturn;\n }\n\n+int sbi_vector_domain_init(struct sbi_domain *dom)\n+{\n+\treturn SBI_OK;\n+}\n+\n+void sbi_vector_domain_exit\n+{\n+\treturn;\n+}\n #endif /* OPENSBI_CC_SUPPORT_VECTOR */\n+\n", "prefixes": [ "v3", "3/3" ] }