{"id":2231987,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2231987/?format=json","web_url":"http://patchwork.ozlabs.org/project/opensbi/patch/20260501211627.3293126-2-evvoevod@tenstorrent.com/","project":{"id":67,"url":"http://patchwork.ozlabs.org/api/1.2/projects/67/?format=json","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":"<20260501211627.3293126-2-evvoevod@tenstorrent.com>","list_archive_url":null,"date":"2026-05-01T21:16:23","name":"[v2,1/5] include: sbi_scratch: Add tmp1 scratch space for RNMI context saving","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"de70eb0674ad29671b017ed94b2aa0fa4c0c2c15","submitter":{"id":92832,"url":"http://patchwork.ozlabs.org/api/1.2/people/92832/?format=json","name":"Evgeny Voevodin","email":"evvoevod@tenstorrent.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/opensbi/patch/20260501211627.3293126-2-evvoevod@tenstorrent.com/mbox/","series":[{"id":502498,"url":"http://patchwork.ozlabs.org/api/1.2/series/502498/?format=json","web_url":"http://patchwork.ozlabs.org/project/opensbi/list/?series=502498","date":"2026-05-01T21:16:26","name":"Add RISC-V Smrnmi extension support","version":2,"mbox":"http://patchwork.ozlabs.org/series/502498/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231987/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231987/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=mlCkZumn;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=tenstorrent.com header.i=@tenstorrent.com\n header.a=rsa-sha256 header.s=google header.b=CIMcvy2a;\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 4g6kPh24DJz23gj\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 02 May 2026 07:16:54 +1000 (AEST)","from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wIvE6-00000007gpc-1GSA;\n\tFri, 01 May 2026 21:16:46 +0000","from mail-dy1-x1334.google.com ([2607:f8b0:4864:20::1334])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wIvE3-00000007go5-2rlk\n\tfor opensbi@lists.infradead.org;\n\tFri, 01 May 2026 21:16:44 +0000","by mail-dy1-x1334.google.com with SMTP id\n 5a478bee46e88-2ef397ad64dso47413eec.3\n        for <opensbi@lists.infradead.org>;\n Fri, 01 May 2026 14:16:43 -0700 (PDT)","from ausc-rvsw-c-02.tenstorrent.com ([38.104.49.66])\n        by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2ee3b29b2casm5879308eec.14.2026.05.01.14.16.41\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Fri, 01 May 2026 14:16:41 -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=K3gp3YVnQEqjtGMimTn7eTyRlea7xVICP4yups0dz9Q=; b=mlCkZumnKRVUFM\n\tejoiekl+Yf9MLrWmOajHMKVvbOYgeXQwFO53wd3e0Df+IH/hFkWirlLzECBe4mwkVJ0hMcE7MXVfU\n\tCVGSNxuJQztu6IygenTe2rHOP/8Y32pV6ZoeCegUrt8JLSJh7UVk3Cq3n8FNayL9XqpAoO58qO85w\n\tXtI3AVCYrsPUZ9o3nVcj9OmlFvOzIugq/0Lq9xPo2uUpIZKrWym5e0PaN/2gAWC50gVkSaF4RhhZR\n\tbaezJdgdSORgHrkApA3GFT18NFTpR5emFWRbMhbiKQYeTHx9vv8Tu7RZmyZbAKU1yf4rGSfYKysyq\n\tWgJXVgx4McYHFlsuy6AQ==;","v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=tenstorrent.com; s=google; t=1777670202; x=1778275002;\n 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=EpB3YcnGU7X+N4SRTdXhRi2bV7L+1uKKq2fDYHJM7rw=;\n        b=CIMcvy2acCgh7GzI82ZFZkcICuTsRmNC5TCkYiEX9PpthPiM27d2ucdKUmFM72eMb9\n         Gg+dneQwnFJQroHuvBRa1NIf7ZQrlb4ghUQwUSAhDZgTgrgRO0jGiL8D0tzyETcfWwRk\n         mChQuit+rOAbIYA2w3pcQB3hC+lBeJu9yH6lQYA2GaRK6NE6ZNydA/LOLYLLbZrjX4ro\n         GYjvXxw3kaH/dKwiyzFJ2uk80BooIABsulFfF5h8yCEjXlMh9szstisQnLuy2ELotLX7\n         US30EDfiKqI1eQ9WrPrCcThiVcm+cpGaNuVNWhCO91gD5fLwq4Kb3VCn1n2mau5D7+Mp\n         rRpA=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1777670202; x=1778275002;\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=EpB3YcnGU7X+N4SRTdXhRi2bV7L+1uKKq2fDYHJM7rw=;\n        b=ixrxBzS+dhrQI++sl+w3zwxES9IR9VmRsv4rnSoMlca9HxEGQz9IYbp5bzYTiErSoW\n         AhHEs4YVNSsViDqmNYE8C/FNmOVhU8i/shwjL8KyAuk9l/8e5C7C0rKPf0DXHECNXF70\n         pwDe89KcGm/HIYvfFi41fmG6DfrZWFiY9LXEHp+0jtVFAPCoYYJlCpbbM9U0gv3qTw3A\n         rkLOMP02QXusH5FbKy9kIr8N5mMKmovyzuqJSC/qU31CYGPDQ+4vxeLRkRwmhYQx2lX7\n         77v2x6k7YY7KfqedmjvTy/qdibshUVISizPu52xMH7JQt/nzhAQe1HILu8U3MZaa+Vsn\n         p95w==","X-Gm-Message-State":"AOJu0YwXXbYVqnbvOcWdpdhFLbL0oK+xOSWUDuYU4sDOof9leManJVHO\n\tjiuYFYDseV0AuRRedK4M4s3ZAIywmz7aLoL9g5E6HoWXJ2B4VbRvE5VHZuCZnK7E6MdLZK7AgAC\n\tW8kBh","X-Gm-Gg":"AeBDietlNFyJ12rWsyj2NebPJmENyLw6kFSA7Z54zeJxtEDXMZFYFQIN+oqCArMLhJS\n\tOJ9d7MjkFKtrYVPaed/eh64GEfQy5EVdCWpLSyBTBChAGPMSC1l2wVvuXN+nrCUq+z5pR2va2qY\n\tynW0bdIy7/fMaiHe09M7bxKIpkGNNSZYP2JWkOdkJ3Rbk3+ghWdikZqefV4ACmCWPzGKmK9gKtm\n\tcm2ZKUHv8/2eaBhoWqN7JdNRr6ds/NL9/zh3jXcb4FnYFvUNTfCwb9G/bn5pxjvqmpZVIy3iTSp\n\tDX3Y1sVDIruhhWBahE9D1mzRqkf2GcCsVONHDe072jUbjHNRLR2Ga3/usY2AFMQTDoRJIYJkKMP\n\tUdvjGmt7Tf6FZnS5TyRKIM+1PPWkut9MLEE2HGFDEk4ojVXlbJCdTyMMYxcR7G1UCXEhZjBUtYL\n\tgVpFLNCQiia17TWnS8RrBvEQXm3XOuql94wubM4aQ9K9RTPF17TQrqSucAWbui","X-Received":"by 2002:a05:7300:e8a3:b0:2da:a813:a629 with SMTP id\n 5a478bee46e88-2efb7bdc0aemr235964eec.2.1777670202377;\n        Fri, 01 May 2026 14:16:42 -0700 (PDT)","From":"Evgeny Voevodin <evvoevod@tenstorrent.com>","To":"opensbi@lists.infradead.org","Cc":"Anup Patel <anup@brainfault.org>,\n\tNylon Chen <nylon.chen@sifive.com>,\n\tevvoevod@tenstorrent.com","Subject":"[PATCH v2 1/5] include: sbi_scratch: Add tmp1 scratch space for RNMI\n context saving","Date":"Fri,  1 May 2026 21:16:23 +0000","Message-ID":"<20260501211627.3293126-2-evvoevod@tenstorrent.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260501211627.3293126-1-evvoevod@tenstorrent.com>","References":"<20260501211627.3293126-1-evvoevod@tenstorrent.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20260501_141643_720656_5F732875 ","X-CRM114-Status":"GOOD (  10.13  )","X-Spam-Score":"-2.1 (--)","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:  RNMI handlers use MNSCRATCH instead of MSCRATCH and need\n separate\n    scratch space from regular trap handling. Add tmp1 for RNMI context while\n    tmp0 remains for regular traps. Signed-off-by: Evgeny Voevodin\n <evvoevod@tenstorrent.com>\n    Reviewed-by: Anup Patel <anup@brainfault.org> --- firmware/fw_base.S | 3\n   ++- include/sbi/sbi_scratch.h | 11 ++++++++--- 2 files changed, 10 in [...]    \n Content analysis details:   (-2.1 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                             [2607:f8b0:4864:20:0:0:0:1334 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_VALID_EF          Message has a valid DKIM or DK signature from\n                             envelope-from domain\n -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from\n author's\n                             domain\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":"RNMI handlers use MNSCRATCH instead of MSCRATCH and need separate scratch\nspace from regular trap handling. Add tmp1 for RNMI context while tmp0\nremains for regular traps.\n\nSigned-off-by: Evgeny Voevodin <evvoevod@tenstorrent.com>\nReviewed-by: Anup Patel <anup@brainfault.org>\n---\n firmware/fw_base.S        |  3 ++-\n include/sbi/sbi_scratch.h | 11 ++++++++---\n 2 files changed, 10 insertions(+), 4 deletions(-)","diff":"diff --git a/firmware/fw_base.S b/firmware/fw_base.S\nindex 63bb4473..cdb15429 100644\n--- a/firmware/fw_base.S\n+++ b/firmware/fw_base.S\n@@ -258,9 +258,10 @@ _scratch_init:\n \t/* Store hartid-to-scratch function address in scratch space */\n \tlla\ta4, _hartid_to_scratch\n \tREG_S\ta4, SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET(tp)\n-\t/* Clear trap_context and tmp0 in scratch space */\n+\t/* Clear trap_context, tmp0 and tmp1 in scratch space */\n \tREG_S\tzero, SBI_SCRATCH_TRAP_CONTEXT_OFFSET(tp)\n \tREG_S\tzero, SBI_SCRATCH_TMP0_OFFSET(tp)\n+\tREG_S\tzero, SBI_SCRATCH_TMP1_OFFSET(tp)\n \t/* Store firmware options in scratch space */\n \tMOV_3R\ts0, a0, s1, a1, s2, a2\n #ifdef FW_OPTIONS\ndiff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h\nindex 58d54628..a6edeb2d 100644\n--- a/include/sbi/sbi_scratch.h\n+++ b/include/sbi/sbi_scratch.h\n@@ -40,12 +40,14 @@\n #define SBI_SCRATCH_TRAP_CONTEXT_OFFSET\t\t(11 * __SIZEOF_POINTER__)\n /** Offset of tmp0 member in sbi_scratch */\n #define SBI_SCRATCH_TMP0_OFFSET\t\t\t(12 * __SIZEOF_POINTER__)\n+/** Offset of tmp1 member in sbi_scratch */\n+#define SBI_SCRATCH_TMP1_OFFSET\t\t\t(13 * __SIZEOF_POINTER__)\n /** Offset of options member in sbi_scratch */\n-#define SBI_SCRATCH_OPTIONS_OFFSET\t\t(13 * __SIZEOF_POINTER__)\n+#define SBI_SCRATCH_OPTIONS_OFFSET\t\t(14 * __SIZEOF_POINTER__)\n /** Offset of hartindex member in sbi_scratch */\n-#define SBI_SCRATCH_HARTINDEX_OFFSET\t\t(14 * __SIZEOF_POINTER__)\n+#define SBI_SCRATCH_HARTINDEX_OFFSET\t\t(15 * __SIZEOF_POINTER__)\n /** Offset of extra space in sbi_scratch */\n-#define SBI_SCRATCH_EXTRA_SPACE_OFFSET\t\t(15 * __SIZEOF_POINTER__)\n+#define SBI_SCRATCH_EXTRA_SPACE_OFFSET\t\t(16 * __SIZEOF_POINTER__)\n /** Maximum size of sbi_scratch (4KB) */\n #define SBI_SCRATCH_SIZE\t\t\t(0x1000)\n \n@@ -83,6 +85,8 @@ struct sbi_scratch {\n \tunsigned long trap_context;\n \t/** Temporary storage */\n \tunsigned long tmp0;\n+\t/** Temporary storage */\n+\tunsigned long tmp1;\n \t/** Options for OpenSBI library */\n \tunsigned long options;\n \t/** Index of the hart */\n@@ -106,6 +110,7 @@ assert_member_offset(struct sbi_scratch, platform_addr, SBI_SCRATCH_PLATFORM_ADD\n assert_member_offset(struct sbi_scratch, hartid_to_scratch, SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET);\n assert_member_offset(struct sbi_scratch, trap_context, SBI_SCRATCH_TRAP_CONTEXT_OFFSET);\n assert_member_offset(struct sbi_scratch, tmp0, SBI_SCRATCH_TMP0_OFFSET);\n+assert_member_offset(struct sbi_scratch, tmp1, SBI_SCRATCH_TMP1_OFFSET);\n assert_member_offset(struct sbi_scratch, options, SBI_SCRATCH_OPTIONS_OFFSET);\n assert_member_offset(struct sbi_scratch, hartindex, SBI_SCRATCH_HARTINDEX_OFFSET);\n \n","prefixes":["v2","1/5"]}