get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2217955/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2217955,
    "url": "http://patchwork.ozlabs.org/api/patches/2217955/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/opensbi/patch/20260331055858.305207-3-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": "<20260331055858.305207-3-dave.patel@riscstar.com>",
    "list_archive_url": null,
    "date": "2026-03-31T05:58:56",
    "name": "[v3,2/3] lib: sbi: Add floating-point context save/restore support.",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "8ad54c5869c6b441199ccf86b6b1d1c73de77d21",
    "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/20260331055858.305207-3-dave.patel@riscstar.com/mbox/",
    "series": [
        {
            "id": 498123,
            "url": "http://patchwork.ozlabs.org/api/series/498123/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/opensbi/list/?series=498123",
            "date": "2026-03-31T05:58:55",
            "name": "Add eager FP and RISC-V vector context switching support",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/498123/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2217955/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2217955/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=bnzORaND;\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=W51nHtaj;\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 4flHW55Z2nz1yGT\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 16:59:13 +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 1w7S83-0000000CKYf-0NvZ;\n\tTue, 31 Mar 2026 05:59:07 +0000",
            "from mail-wm1-x333.google.com ([2a00:1450:4864:20::333])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w7S81-0000000CKX3-062T\n\tfor opensbi@lists.infradead.org;\n\tTue, 31 Mar 2026 05:59:06 +0000",
            "by mail-wm1-x333.google.com with SMTP id\n 5b1f17b1804b1-486fb14227cso69278705e9.3\n        for <opensbi@lists.infradead.org>;\n Mon, 30 Mar 2026 22:59:04 -0700 (PDT)",
            "from Dev-EliteBook.Home (97e782b0.skybroadband.com.\n [151.231.130.176])\n        by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-43cf1db08e6sm35915544f8f.0.2026.03.30.22.59.02\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Mon, 30 Mar 2026 22:59:02 -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=tc9EpuvcsVGES9qimHbq/EJJA7nsfd9e6rvPu/gP29Y=; b=bnzORaNDCN2Jwc\n\tfd/9iPMS27kC60RYTPnLOILyw/MZaViOk8OJvaZTO3OlijWfupT9GOR2Gohb8fF+DErau3ROcSguh\n\t2VFhEu3KaoIiQwNm8OjKUr8s/hupss531h4Hc49UR6npSMOPnSStQZdmFSrIk70kQubwDCGT/a0aE\n\t8xlVbu/UN62ItvtPiO0LZklBbO8eYV1nr2c86BTdc8r6Ia60JGiGTFucOBI4i3/5xcX6F7CGzkv6w\n\ttzV//TP/k2jaPQamOj2ilowSrHF/KS7tyoUi1BXaFgFFBDO2PmoaJBo/fUVrjd08S42GS01ZWyYHW\n\tae9vGVGsPnr3NvdXPyXQ==;",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1774936743;\n x=1775541543; 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=rF4AlPXplwEkmNk42TwEFuUE0VAO3k/9JlQOg+s5rI0=;\n        b=W51nHtajSOcagUV2j3GmD1/pnRRavZb7lmFxd4kUPe/dV3DZo8nZ+2Senov90YAvdn\n         Bn7yI8S+c0lKF2l8nkeMXaJObR72fqvC0+J2bGQJ5v3fAuUjHTnIobk/YKqcYw8dfh43\n         s1iv/a7lNMaIw1FmKmtQgOZs/pmrEBW3kY8JO3tuD65HQk7j9LtVnTlxsLdFTvPC77Fx\n         Z3dWkHLBDxyLxayV/cikUw7xfwfa3VSAM+WsdbwQVsT28thVolCpp6VtO2n08hfn/JAk\n         iB3RBveqjPWI4r0Wqzxgj2Ui8KcYiPlh4utYJ0d1ZA/h58m06m4K6MVj4K9OO9gYbTXz\n         1Q/Q=="
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1774936743; x=1775541543;\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=rF4AlPXplwEkmNk42TwEFuUE0VAO3k/9JlQOg+s5rI0=;\n        b=aqAghg8qeqZbmk76fOgNW9IzfkMKgN8hJc2xJoTcUSr7SQNadr1Ly5NBLWq/32p2po\n         AlV5nTLLiU8bPA57ob4Q/M2E2VGd5EqI9oFGhyD53n+t92meHQrcwGTU/Guv6t5RONXn\n         ZukzgIPSEbOYQtEtuU29+VTg85fly0JrOX3xaMOQxEXVQ9qnBDKKNKFf4ozHvLIcQYGl\n         ibnKW64bh4bU4YVZZ1VxTP1eQ19OMUHTzfOMf4YFBzURoM7xJmrPg8euiExtEDNE4a/8\n         pNT78bqrdXTUG9kQg2EVGrbDHrFMUEyNY2WIw+cy8Tz85nzSu4yb3W01lcHAj5nqqMX4\n         Kt6Q==",
        "X-Forwarded-Encrypted": "i=1;\n AJvYcCVSRzLuwjN+RyLMa0zIsiw7apRJO/3fG/zY+tep2VP6TYlIA21YnG2cbN26STj9gFSir7vfdQhj@lists.infradead.org",
        "X-Gm-Message-State": "AOJu0YxQxKg4+HRfAFslMhLpGUgUafHnz2x6SCjKpEyHeoEsTu3oXrIb\n\tCooW1G/gs+Z19RQFeVtvn9dB7+Sew3rOjkRB6zPZMcp08UdrJtWo2XvBp/a8LN8orSE=",
        "X-Gm-Gg": "ATEYQzxgkX0qV8ZnE/8oDyAY4vrnHTssB6FMVYYQ8zpe7M6LjNRXshiVDmBkmnu/fL+\n\tiDb5Jy4fBieUgMZ3w7KJVsOcLPnJsnphKqp64U7leqUllrajlule8gXH+qsJEIfK6o91FC91MPg\n\t9m/BTyt61szEp/iy/xMFDQ2tf7MCvs3SFP+Qjx3zhd/eEyo58T3p0CPoneDhed2WWK8geZAXxHu\n\tulB2Isn1xi8YoP6c5ZvZTK4PuTkb/TuGE7m9BbnoD0SHdgkFEgRN/3KB9YkRfTWo8PcS3BtPzwN\n\tMRvaAMqzMxP4LnTk6+339rNbUmeCgGpx1PxCn4fSkf5MhW+eKRC2WgoZqWsXj6clChEjViPhXGf\n\tgoGLQo1mMUd4UT+9Ar9nPtlsFIydqw3PoYZxgsbgr3PR7+GlSOBPPeN4MbJWggAhIpMj8y5e7XD\n\tXpwsNpfX3I0TjjKwCc33nNZ8q6qbfOWZ8zK2iVo1EOSRL89fUH/GvWw+5w5ixwDeA+gY+RCT0ql\n\tNEFKg==",
        "X-Received": "by 2002:a05:600c:46c4:b0:485:3a03:ceca with SMTP id\n 5b1f17b1804b1-48727f0e53bmr271390855e9.23.1774936743115;\n        Mon, 30 Mar 2026 22:59:03 -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 2/3] lib: sbi: Add floating-point context save/restore\n support.",
        "Date": "Tue, 31 Mar 2026 06:58:56 +0100",
        "Message-ID": "<20260331055858.305207-3-dave.patel@riscstar.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20260331055858.305207-1-dave.patel@riscstar.com>",
        "References": "<20260331055858.305207-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-20260330_225905_104025_74CE53E4 ",
        "X-CRM114-Status": "GOOD (  16.23  )",
        "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> Add support for\n    saving and restoring RISC-V floating-point (F/D) extension state in\n OpenSBI.\n    This introduces a floating-point context structure and helper routines to\n    perform full context save and res [...]\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:333 listed in]\n                             [list.dnswl.org]\n  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record\n -0.0 SPF_PASS               SPF: sender matches 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=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "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\nAdd support for saving and restoring RISC-V floating-point (F/D) extension\nstate in OpenSBI. This introduces a floating-point context structure and\nhelper routines to perform full context save and restore.\n\nThe floating-point context includes storage for all 32 FPi registers (f0–f31)\nalong with the fcsr control and status register. The register state is saved\nand restored using double-precision load/store instructions (fsd/fld), and\nsingle-precision load/store instructions (fsw/flw) on an RV64 system with\nF and D-extension support.\n\nThe implementation follows an eager context switching model where the entire\nFP state is saved and restored on every context switch. This avoids the need\nfor trap-based lazy management and keeps the design simple and deterministic.\n\nSigned-off-by: Dave Patel <dave.patel@riscstar.com>\"\n---\n include/sbi/sbi_fp.h |  36 ++++++++\n lib/sbi/objects.mk   |   1 +\n lib/sbi/sbi_fp.c     | 191 +++++++++++++++++++++++++++++++++++++++++++\n lib/sbi/sbi_vector.c |  24 +++---\n 4 files changed, 240 insertions(+), 12 deletions(-)\n create mode 100644 include/sbi/sbi_fp.h\n create mode 100644 lib/sbi/sbi_fp.c\n\n--\n2.43.0",
    "diff": "diff --git a/include/sbi/sbi_fp.h b/include/sbi/sbi_fp.h\nnew file mode 100644\nindex 00000000..8079bb3b\n--- /dev/null\n+++ b/include/sbi/sbi_fp.h\n@@ -0,0 +1,36 @@\n+/* SPDX-License-Identifier: GPL-2.0\n+ *\n+ * Copyright (c) 2026 RISCstar Solutions.\n+ *\n+ * Authors:\n+ *   Dave Patel <dave.patel@riscstar.com>\n+ */\n+#ifndef __SBI_FP_H__\n+#define __SBI_FP_H__\n+\n+#include <sbi/riscv_encoding.h>\n+#include <sbi/sbi_types.h>\n+\n+#if defined(__riscv_f) || defined(__riscv_d)\n+\n+#include <stdint.h>\n+\n+struct sbi_fp_context {\n+#if __riscv_d\n+\tuint64_t f[32];\n+#else\n+\tuint32_t f[32];\n+#endif\n+\tuint32_t fcsr;\n+} __aligned(16);\n+\n+#else /* No FP (e.g., Zve32x) */\n+\n+struct sbi_fp_context { };\n+\n+#endif //defined(__riscv_f) || defined(__riscv_d)\n+\n+void sbi_fp_save(struct sbi_fp_context *dst);\n+void sbi_fp_restore(const struct sbi_fp_context *src);\n+\n+#endif //__SBI_VECTOR_H__\ndiff --git a/lib/sbi/objects.mk b/lib/sbi/objects.mk\nindex 5c0caf39..ca560c2e 100644\n--- a/lib/sbi/objects.mk\n+++ b/lib/sbi/objects.mk\n@@ -107,3 +107,4 @@ libsbi-objs-y += sbi_unpriv.o\n libsbi-objs-y += sbi_expected_trap.o\n libsbi-objs-y += sbi_cppc.o\n libsbi-objs-y += sbi_vector.o\n+libsbi-objs-y += sbi_fp.o\ndiff --git a/lib/sbi/sbi_fp.c b/lib/sbi/sbi_fp.c\nnew file mode 100644\nindex 00000000..5d72b72e\n--- /dev/null\n+++ b/lib/sbi/sbi_fp.c\n@@ -0,0 +1,191 @@\n+/* SPDX-License-Identifier: GPL-2.0\n+ *\n+ * Copyright (c) 2026 RISCstar Solutions.\n+ *\n+ * Authors:\n+ *   Dave Patel <dave.patel@riscstar.com>\n+ */\n+\n+#include <sbi/riscv_asm.h>\n+#include <sbi/riscv_encoding.h>\n+#include <sbi/sbi_fp.h>\n+\n+#if defined(__riscv_f) || defined(__riscv_d)\n+\n+void sbi_fp_save(struct sbi_fp_context *dst)\n+{\n+\tif (!dst)\n+\t\treturn;\n+\n+#if defined(__riscv_d)\n+\tasm volatile(\n+\t\t\"fsd f0,  0(%0)\\n\"\n+\t\t\"fsd f1,  8(%0)\\n\"\n+\t\t\"fsd f2,  16(%0)\\n\"\n+\t\t\"fsd f3,  24(%0)\\n\"\n+\t\t\"fsd f4,  32(%0)\\n\"\n+\t\t\"fsd f5,  40(%0)\\n\"\n+\t\t\"fsd f6,  48(%0)\\n\"\n+\t\t\"fsd f7,  56(%0)\\n\"\n+\t\t\"fsd f8,  64(%0)\\n\"\n+\t\t\"fsd f9,  72(%0)\\n\"\n+\t\t\"fsd f10, 80(%0)\\n\"\n+\t\t\"fsd f11, 88(%0)\\n\"\n+\t\t\"fsd f12, 96(%0)\\n\"\n+\t\t\"fsd f13, 104(%0)\\n\"\n+\t\t\"fsd f14, 112(%0)\\n\"\n+\t\t\"fsd f15, 120(%0)\\n\"\n+\t\t\"fsd f16, 128(%0)\\n\"\n+\t\t\"fsd f17, 136(%0)\\n\"\n+\t\t\"fsd f18, 144(%0)\\n\"\n+\t\t\"fsd f19, 152(%0)\\n\"\n+\t\t\"fsd f20, 160(%0)\\n\"\n+\t\t\"fsd f21, 168(%0)\\n\"\n+\t\t\"fsd f22, 176(%0)\\n\"\n+\t\t\"fsd f23, 184(%0)\\n\"\n+\t\t\"fsd f24, 192(%0)\\n\"\n+\t\t\"fsd f25, 200(%0)\\n\"\n+\t\t\"fsd f26, 208(%0)\\n\"\n+\t\t\"fsd f27, 216(%0)\\n\"\n+\t\t\"fsd f28, 224(%0)\\n\"\n+\t\t\"fsd f29, 232(%0)\\n\"\n+\t\t\"fsd f30, 240(%0)\\n\"\n+\t\t\"fsd f31, 248(%0)\\n\"\n+\t\t:\n+\t\t: \"r\"(dst->f)\n+\t\t: \"memory\"\n+\t);\n+#else\n+\tasm volatile(\n+\t\t\"fsw f0,  0(%0)\\n\"\n+\t\t\"fsw f1,  4(%0)\\n\"\n+\t\t\"fsw f2,  8(%0)\\n\"\n+\t\t\"fsw f3,  12(%0)\\n\"\n+\t\t\"fsw f4,  16(%0)\\n\"\n+\t\t\"fsw f5,  20(%0)\\n\"\n+\t\t\"fsw f6,  24(%0)\\n\"\n+\t\t\"fsw f7,  28(%0)\\n\"\n+\t\t\"fsw f8,  32(%0)\\n\"\n+\t\t\"fsw f9,  36(%0)\\n\"\n+\t\t\"fsw f10, 40(%0)\\n\"\n+\t\t\"fsw f11, 44(%0)\\n\"\n+\t\t\"fsw f12, 48(%0)\\n\"\n+\t\t\"fsw f13, 52(%0)\\n\"\n+\t\t\"fsw f14, 56(%0)\\n\"\n+\t\t\"fsw f15, 60(%0)\\n\"\n+\t\t\"fsw f16, 64(%0)\\n\"\n+\t\t\"fsw f17, 68(%0)\\n\"\n+\t\t\"fsw f18, 72(%0)\\n\"\n+\t\t\"fsw f19, 76(%0)\\n\"\n+\t\t\"fsw f20, 80(%0)\\n\"\n+\t\t\"fsw f21, 84(%0)\\n\"\n+\t\t\"fsw f22, 88(%0)\\n\"\n+\t\t\"fsw f23, 92(%0)\\n\"\n+\t\t\"fsw f24, 96(%0)\\n\"\n+\t\t\"fsw f25, 100(%0)\\n\"\n+\t\t\"fsw f26, 104(%0)\\n\"\n+\t\t\"fsw f27, 108(%0)\\n\"\n+\t\t\"fsw f28, 112(%0)\\n\"\n+\t\t\"fsw f29, 116(%0)\\n\"\n+\t\t\"fsw f30, 120(%0)\\n\"\n+\t\t\"fsw f31, 124(%0)\\n\"\n+\t\t:\n+\t\t: \"r\"(dst->f)\n+\t\t: \"memory\"\n+\t);\n+#endif //__riscv_d\n+\n+\tdst->fcsr = csr_read(CSR_FCSR);\n+}\n+\n+void sbi_fp_restore(const struct sbi_fp_context *src)\n+{\n+\tif (!src)\n+\t\treturn;\n+\n+#if defined(__riscv_d)\n+\tasm volatile(\n+\t\t\"fld f0,  0(%0)\\n\"\n+\t\t\"fld f1,  8(%0)\\n\"\n+\t\t\"fld f2,  16(%0)\\n\"\n+\t\t\"fld f3,  24(%0)\\n\"\n+\t\t\"fld f4,  32(%0)\\n\"\n+\t\t\"fld f5,  40(%0)\\n\"\n+\t\t\"fld f6,  48(%0)\\n\"\n+\t\t\"fld f7,  56(%0)\\n\"\n+\t\t\"fld f8,  64(%0)\\n\"\n+\t\t\"fld f9,  72(%0)\\n\"\n+\t\t\"fld f10, 80(%0)\\n\"\n+\t\t\"fld f11, 88(%0)\\n\"\n+\t\t\"fld f12, 96(%0)\\n\"\n+\t\t\"fld f13, 104(%0)\\n\"\n+\t\t\"fld f14, 112(%0)\\n\"\n+\t\t\"fld f15, 120(%0)\\n\"\n+\t\t\"fld f16, 128(%0)\\n\"\n+\t\t\"fld f17, 136(%0)\\n\"\n+\t\t\"fld f18, 144(%0)\\n\"\n+\t\t\"fld f19, 152(%0)\\n\"\n+\t\t\"fld f20, 160(%0)\\n\"\n+\t\t\"fld f21, 168(%0)\\n\"\n+\t\t\"fld f22, 176(%0)\\n\"\n+\t\t\"fld f23, 184(%0)\\n\"\n+\t\t\"fld f24, 192(%0)\\n\"\n+\t\t\"fld f25, 200(%0)\\n\"\n+\t\t\"fld f26, 208(%0)\\n\"\n+\t\t\"fld f27, 216(%0)\\n\"\n+\t\t\"fld f28, 224(%0)\\n\"\n+\t\t\"fld f29, 232(%0)\\n\"\n+\t\t\"fld f30, 240(%0)\\n\"\n+\t\t\"fld f31, 248(%0)\\n\"\n+\t\t:\n+\t\t: \"r\"(src->f)\n+\t\t: \"memory\"\n+\t);\n+#else\n+\n+\tasm volatile(\n+\t\t\"flw f0,   0(%0)\\n\"\n+\t\t\"flw f1,   4(%0)\\n\"\n+\t\t\"flw f2,   8(%0)\\n\"\n+\t\t\"flw f3,  12(%0)\\n\"\n+\t\t\"flw f4,  16(%0)\\n\"\n+\t\t\"flw f5,  20(%0)\\n\"\n+\t\t\"flw f6,  24(%0)\\n\"\n+\t\t\"flw f7,  28(%0)\\n\"\n+\t\t\"flw f8,  32(%0)\\n\"\n+\t\t\"flw f9,  36(%0)\\n\"\n+\t\t\"flw f10, 40(%0)\\n\"\n+\t\t\"flw f11, 44(%0)\\n\"\n+\t\t\"flw f12, 48(%0)\\n\"\n+\t\t\"flw f13, 52(%0)\\n\"\n+\t\t\"flw f14, 56(%0)\\n\"\n+\t\t\"flw f15, 60(%0)\\n\"\n+\t\t\"flw f16, 64(%0)\\n\"\n+\t\t\"flw f17, 68(%0)\\n\"\n+\t\t\"flw f18, 72(%0)\\n\"\n+\t\t\"flw f19, 76(%0)\\n\"\n+\t\t\"flw f20, 80(%0)\\n\"\n+\t\t\"flw f21, 84(%0)\\n\"\n+\t\t\"flw f22, 88(%0)\\n\"\n+\t\t\"flw f23, 92(%0)\\n\"\n+\t\t\"flw f24, 96(%0)\\n\"\n+\t\t\"flw f25, 100(%0)\\n\"\n+\t\t\"flw f26, 104(%0)\\n\"\n+\t\t\"flw f27, 108(%0)\\n\"\n+\t\t\"flw f28, 112(%0)\\n\"\n+\t\t\"flw f29, 116(%0)\\n\"\n+\t\t\"flw f30, 120(%0)\\n\"\n+\t\t\"flw f31, 124(%0)\\n\"\n+\t\t:\n+\t\t: \"r\"(src->f)\n+\t\t: \"memory\"\n+\t);\n+\n+#endif\n+\n+\tcsr_write(CSR_FCSR, src->fcsr);\n+}\n+#else\n+void sbi_fp_save(struct sbi_fp_context *dst) {}\n+void sbi_fp_restore(const struct sbi_fp_context *src) {}\n+#endif // FP present\ndiff --git a/lib/sbi/sbi_vector.c b/lib/sbi/sbi_vector.c\nindex 497d7f94..5a3f34d7 100644\n--- a/lib/sbi/sbi_vector.c\n+++ b/lib/sbi/sbi_vector.c\n@@ -50,8 +50,8 @@ void sbi_vector_save(struct sbi_vector_context *dst)\n \tif (!dst)\n \t\treturn;\n\n-#define READ_CSR(dst, csr) (\t\t\t\t\\\n-\tdo {\t\t\t\t\t\t\\\n+#define READ_CSR(dst, csr) \t\t\t\t\\\n+\t{\t\t\t\t\t\t\\\n \t\tasm volatile(\t\t\t\t\\\n \t\t\t\"\t.option push\\n\\t\"\t\\\n \t\t\t\"\t.option arch, +v\\n\\t\"\t\\\n@@ -60,7 +60,7 @@ void sbi_vector_save(struct sbi_vector_context *dst)\n \t\t\t:\t\"=r\"(dst)\t\t\\\n \t\t\t:\t\t\t\t\\\n \t\t\t:\t\"memory\");\t\t\\\n-\t} while (0))\n+\t}\n\n \t/* Step 1: Save CSRs */\n \tREAD_CSR(dst->vtype,  vtype);\n@@ -80,13 +80,13 @@ void sbi_vector_save(struct sbi_vector_context *dst)\n \tuint8_t *base = dst->vregs;\n\n \t/* Step 3: Save vector registers */\n-#define SAVE_VREG(i) (\t\t\t\t\t\t\\\n-\tasm volatile(\t\t\t\t\t\t\\\n+#define SAVE_VREG(i) \t\t\t\t\t\t\\\n+\t{asm volatile(\t\t\t\t\t\t\\\n \t\t\"\t.option push\\n\\t\"\t\t\t\\\n \t\t\"\t.option arch, +v\\n\\t\"\t\t\t\\\n \t\t\"\tvse8.v v\" #i \", (%0)\\n\\t\"\t\t\\\n \t\t\"\t.option pop\\n\\t\"\t\t\t\\\n-\t\t::\t\"r\"(base + (i) * vlenb)\t: \"memory\"))\n+\t\t::\t\"r\"(base + (i) * vlenb)\t: \"memory\"); }\n\n \tSAVE_VREG(0);\n \tSAVE_VREG(1);\n@@ -139,13 +139,13 @@ void sbi_vector_restore(const struct sbi_vector_context *src)\n \tvsetvl(src->vl, src->vtype);\n\n \t/* Step 2: Restore vector registers */\n-#define RESTORE_VREG(i) (\t\t\t\t\t\\\n-\tasm volatile(\t\t\t\t\t\t\\\n+#define RESTORE_VREG(i) \t\t\t\t\t\\\n+\t{asm volatile(\t\t\t\t\t\t\\\n \t\t\"\t.option push\\n\\t\"\t\t\t\\\n \t\t\"\t.option arch, +v\\n\\t\"\t\t\t\\\n \t\t\"\tvle8.v v\" #i \", (%0)\\n\\t\"\t\t\\\n \t\t\"\t.option pop\\n\\t\"\t\t\t\\\n-\t\t::\t\"r\"(base + (i) * vlenb) : \"memory\"))\n+\t\t::\t\"r\"(base + (i) * vlenb) : \"memory\"); }\n\n \tRESTORE_VREG(0);\n \tRESTORE_VREG(1);\n@@ -182,15 +182,15 @@ void sbi_vector_restore(const struct sbi_vector_context *src)\n #undef RESTORE_VREG\n\n \t/* Step 3: Restore CSR's last */\n-#define WRITE_CSR(csr, val) (\t\t\t\\\n-\tasm volatile(\t\t\t\t\\\n+#define WRITE_CSR(csr, val) \t\t\t\\\n+\t{ asm volatile(\t\t\t\t\\\n \t\t\"\t.option push\\n\\t\"\t\\\n \t\t\"\t.option arch, +v\\n\\t\"\t\\\n \t\t\"\tcsrw \" #csr \", %0\\n\\t\"\t\\\n \t\t\"\t.option pop\\n\\t\"\t\\\n \t\t:\t\t\t\t\\\n \t\t:\t\"r\"(val)\t\t\\\n-\t\t:\t\"memory\"))\n+\t\t:\t\"memory\"); }\n\n \t/* Restore CSRs first */\n \tWRITE_CSR(vtype,  src->vtype);\n",
    "prefixes": [
        "v3",
        "2/3"
    ]
}