get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2230809,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2230809/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/opensbi/patch/20260430045528.420437-2-npiggin@gmail.com/",
    "project": {
        "id": 67,
        "url": "http://patchwork.ozlabs.org/api/1.1/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": ""
    },
    "msgid": "<20260430045528.420437-2-npiggin@gmail.com>",
    "date": "2026-04-30T04:55:18",
    "name": "[1/7] lib: sbi: Introduce pmp_t type",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "f913372a6c7a07746ffacd40c3e2c09eb678345e",
    "submitter": {
        "id": 69518,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/69518/?format=api",
        "name": "Nicholas Piggin",
        "email": "npiggin@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/opensbi/patch/20260430045528.420437-2-npiggin@gmail.com/mbox/",
    "series": [
        {
            "id": 502193,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/502193/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/opensbi/list/?series=502193",
            "date": "2026-04-30T04:55:18",
            "name": "Make PMP encoding usable for non-hart PMPs",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/502193/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2230809/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2230809/checks/",
    "tags": {},
    "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=j5LvNGNL;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=jA07QGVn;\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 4g5hhF0Qxvz1yGq\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 14:55:52 +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 1wIJRA-00000004g3M-3hbu;\n\tThu, 30 Apr 2026 04:55:44 +0000",
            "from mail-pf1-f178.google.com ([209.85.210.178])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wIJR8-00000004g2d-3epp\n\tfor opensbi@lists.infradead.org;\n\tThu, 30 Apr 2026 04:55:43 +0000",
            "by mail-pf1-f178.google.com with SMTP id\n d2e1a72fcca58-83178c0f29cso367755b3a.0\n        for <opensbi@lists.infradead.org>;\n Wed, 29 Apr 2026 21:55:42 -0700 (PDT)",
            "from localhost ([124.158.97.178])\n        by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-834ed80ec94sm3805750b3a.52.2026.04.29.21.55.39\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Wed, 29 Apr 2026 21:55:40 -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=vTX88+rWtXnkDhF4pELdykMOAghwi/nze8nN/alXf38=; b=j5LvNGNLI7KhiQ\n\tIedkBszXKIGo07jTB2jArfmCD0TpJE8QNL7a3fYC+j7yfLOwbb0VJnD9P04NKu5HTrz398DT9LATq\n\t8s+o1I3jEFlWbSBcx4AQBz000WflqQkT7hqIRj1apeDthZpb+qjGCDGQpjwzFrgYRDimzGnJi2mCr\n\tfxAfJ74gntlLFHhsAh/domDKwWQNQuPByXfoC80tqfYb8/m+RxRhPX+I3DqHcWyec7VuQnCj8anYx\n\tHFkrNuYEU+TDCJsvOm5I64ccvwXm8/LnvlKW5ARKUTryM1qFTCYpLkV+eGRqNC0v21N7M5nGPSc5M\n\tMWXormvPKRzfu91pQh3w==;",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1777524941; x=1778129741;\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=X1LLKCFvi1GEObqYGvHfiap+a5f2X0XLlziBBakRm+c=;\n        b=jA07QGVnvtfEW6OXL+9Gb7TAVszjG5HIQ+WoKIr/CvlTaJehfqVOnfPu+UAsL2Krqa\n         D1Wm/A4nBdFVY9WJHtKzOO0yYVazv1OO80mkQifiB6gmb8CzJAQIdzLn8SJQqQOuWwph\n         ZGOukpqIIC+oEolDLXaNH1Ehfe94l1MT/U997Vcp7Auqwq8/PqhP6sR/inK/ZHrG7eav\n         fcEbpwnvYXZqm9i/jBV92uBtWEypL7E9wmWcyvVHt9QCYPa2nP9A30bK/LHriMscWkfc\n         hFjyJw53mTa66kAZmUhVTqp9/ep+tqpiSXf058KyFqCJzp7hHwGEfQeKcDCqWLm8Tox9\n         fZUA=="
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1777524941; x=1778129741;\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=X1LLKCFvi1GEObqYGvHfiap+a5f2X0XLlziBBakRm+c=;\n        b=du7kCNNZuZDQsQYBaXlF6EBdkGtq6hhWgvcR1IdRBzYwVxw5fvuWbS6xNUH5yooJCR\n         i/g+/5oNlAm46c8KvStm1W+ACwSQJLwmTub05X+6CTvhujllo73qN0cI7WNHHH6EAxKq\n         PD7dINQwlesCIPgFXmGp+7wZFKK412PcZelSVcCk+pHl1Q5aTW+awkr3QNQU8tAx+u01\n         tq4GOapWz+eg/4p/z4QwyL7mD+kxGUEQ2uCdl+Kr6Oa3sDYjFC+p7KXe8960hh3HlMcP\n         kw1VDMqXbcM/Az+vBYzVxVR8ahAvfW31rP7guBitMBd/MjJcpuBN7mRfIsbDChQ6v9aM\n         Z0VQ==",
        "X-Gm-Message-State": "AOJu0YxLh53sXey63zCcbn7cpptIKqNmw39wMx19DleGnXIdGtYllGuJ\n\tIltyAXAetNC5KgTIsziCXZrs96WK9N3ubOOR/VtVjyTn4Pgt8dxW4IE5CTPErg==",
        "X-Gm-Gg": "AeBDietnzwc8Ok8Snwakjh+X4xEkqF/HTZ1VBualvBlhhaeT8ccmHFcKj0HJCFPo6Rm\n\tj0ncyDeChpa3u978aO3WIxX91iA7D490TvjQVdHfKLVorCD/AoxzbYVjH4Io59A+ZLf8rFIGmTb\n\tVIswXYLysDzvoC0qKurhJI6ohbAKzJ36xXQbYSVg/Itr4xEPqGI7fEMbzXkjZXt8ONE2fFHZ7tp\n\tsA07jCMnooJipfrMPytysJ+4yi1POy4nrV3HgwJsmBpHKHVyDSKYyazW3ucusiSYye1YQ1dxn7E\n\tkgV41ykMSp6bOk5pL/BFUFrltIiWPmCQq0HJx1sBqlekuuyLlIwuSFDFgaj/xSXUw1ZFMYqVtLw\n\tO/M57zuVfRI2JfovCYVV8r0ZRA4L3qtbQv59U6rGckwqaUhGTUALccvhU8saMsYGsJvEkryWHhy\n\tKwd7bat2SN/zVSF+rQaNG6xu1vNDNdrCZZVDuwFgd+1U8/nIEyuqd3xg==",
        "X-Received": "by 2002:a05:6a00:1a8b:b0:82f:6e9:d1ba with SMTP id\n d2e1a72fcca58-834fdc480bcmr1667516b3a.37.1777524941021;\n        Wed, 29 Apr 2026 21:55:41 -0700 (PDT)",
        "From": "Nicholas Piggin <npiggin@gmail.com>",
        "To": "opensbi@lists.infradead.org",
        "Cc": "Nicholas Piggin <npiggin@gmail.com>",
        "Subject": "[PATCH 1/7] lib: sbi: Introduce pmp_t type",
        "Date": "Thu, 30 Apr 2026 14:55:18 +1000",
        "Message-ID": "<20260430045528.420437-2-npiggin@gmail.com>",
        "X-Mailer": "git-send-email 2.53.0",
        "In-Reply-To": "<20260430045528.420437-1-npiggin@gmail.com>",
        "References": "<20260430045528.420437-1-npiggin@gmail.com>",
        "MIME-Version": "1.0",
        "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ",
        "X-CRM114-CacheID": "sfid-20260429_215542_914094_28FF926D ",
        "X-CRM114-Status": "GOOD (  12.66  )",
        "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:  To help abstract details of PMP encoding and access, add a\n    new pmp_t type which contains address and cfg in the format of the riscv\n   CSRs. There is no functional change. Signed-off-by: Nicholas Piggin ---\n lib/sbi/riscv_asm.c\n    | 41 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+),\n 15 deletions(-)    \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                             [209.85.210.178 listed in 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_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 -0.1 DKIM_VALID_EF          Message has a valid DKIM or DK signature from\n                             envelope-from domain\n -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n                             [score: 0.0000]\n  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail\n provider\n                             [npiggin(at)gmail.com]\n  0.0 RCVD_IN_MSPIKE_H3      RBL: Good reputation (+3)\n                             [209.85.210.178 listed in wl.mailspike.net]\n  0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders",
        "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": "To help abstract details of PMP encoding and access, add a new pmp_t\ntype which contains address and cfg in the format of the riscv CSRs.\nThere is no functional change.\n\nSigned-off-by: Nicholas Piggin <npiggin@gmail.com>\n---\n lib/sbi/riscv_asm.c | 41 ++++++++++++++++++++++++++---------------\n 1 file changed, 26 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/lib/sbi/riscv_asm.c b/lib/sbi/riscv_asm.c\nindex 3e44320f..acb6b5e6 100644\n--- a/lib/sbi/riscv_asm.c\n+++ b/lib/sbi/riscv_asm.c\n@@ -272,6 +272,12 @@ void csr_write_num(int csr_num, unsigned long val)\n #undef switchcase_csr_write\n }\n \n+struct pmp {\n+\tunsigned long addr;\n+\tu8 cfg;\n+};\n+typedef struct pmp pmp_t;\n+\n static unsigned long ctz(unsigned long x)\n {\n \tunsigned long ret = 0;\n@@ -335,7 +341,8 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,\n {\n \tint pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;\n \tunsigned long cfgmask, pmpcfg;\n-\tunsigned long addrmask, pmpaddr;\n+\tunsigned long addrmask;\n+\tpmp_t pmp;\n \n \t/* check parameters */\n \tif (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)\n@@ -356,25 +363,26 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,\n \t/* encode PMP config */\n \tprot &= ~PMP_A;\n \tprot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;\n-\tcfgmask = ~(0xffUL << pmpcfg_shift);\n-\tpmpcfg\t= (csr_read_num(pmpcfg_csr) & cfgmask);\n-\tpmpcfg |= ((prot << pmpcfg_shift) & ~cfgmask);\n+\tpmp.cfg = prot;\n \n \t/* encode PMP address */\n \tif (log2len == PMP_SHIFT) {\n-\t\tpmpaddr = (addr >> PMP_SHIFT);\n+\t\tpmp.addr = (addr >> PMP_SHIFT);\n \t} else {\n \t\tif (log2len == __riscv_xlen) {\n-\t\t\tpmpaddr = -1UL;\n+\t\t\tpmp.addr = -1UL;\n \t\t} else {\n \t\t\taddrmask = (1UL << (log2len - PMP_SHIFT)) - 1;\n-\t\t\tpmpaddr\t = ((addr >> PMP_SHIFT) & ~addrmask);\n-\t\t\tpmpaddr |= (addrmask >> 1);\n+\t\t\tpmp.addr = ((addr >> PMP_SHIFT) & ~addrmask);\n+\t\t\tpmp.addr |= (addrmask >> 1);\n \t\t}\n \t}\n \n \t/* write csrs */\n-\tcsr_write_num(pmpaddr_csr, pmpaddr);\n+\tcsr_write_num(pmpaddr_csr, pmp.addr);\n+\tcfgmask = ~(0xffUL << pmpcfg_shift);\n+\tpmpcfg  = (csr_read_num(pmpcfg_csr) & cfgmask);\n+\tpmpcfg |= (((unsigned long)pmp.cfg << pmpcfg_shift) & ~cfgmask);\n \tcsr_write_num(pmpcfg_csr, pmpcfg);\n \n \treturn 0;\n@@ -384,8 +392,9 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,\n \t    unsigned long *log2len)\n {\n \tint pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;\n-\tunsigned long cfgmask, pmpcfg, prot;\n+\tunsigned long cfgmask, prot;\n \tunsigned long t1, addr, len;\n+\tpmp_t pmp;\n \n \t/* check parameters */\n \tif (n >= PMP_COUNT || !prot_out || !addr_out || !log2len)\n@@ -404,14 +413,16 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,\n #endif\n \tpmpaddr_csr = CSR_PMPADDR0 + n;\n \n-\t/* decode PMP config */\n \tcfgmask = (0xffUL << pmpcfg_shift);\n-\tpmpcfg\t= csr_read_num(pmpcfg_csr) & cfgmask;\n-\tprot\t= pmpcfg >> pmpcfg_shift;\n+\tpmp.cfg = (csr_read_num(pmpcfg_csr) & cfgmask) >> pmpcfg_shift;\n+\tpmp.addr = csr_read_num(pmpaddr_csr);\n+\n+\t/* decode PMP config */\n+\tprot = pmp.cfg;\n \n \t/* decode PMP address */\n \tif ((prot & PMP_A) == PMP_A_NAPOT) {\n-\t\taddr = csr_read_num(pmpaddr_csr);\n+\t\taddr = pmp.addr;\n \t\tif (addr == -1UL) {\n \t\t\taddr\t= 0;\n \t\t\tlen\t= __riscv_xlen;\n@@ -421,7 +432,7 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,\n \t\t\tlen\t= (t1 + PMP_SHIFT + 1);\n \t\t}\n \t} else {\n-\t\taddr\t= csr_read_num(pmpaddr_csr) << PMP_SHIFT;\n+\t\taddr\t= pmp.addr << PMP_SHIFT;\n \t\tlen\t= PMP_SHIFT;\n \t}\n \n",
    "prefixes": [
        "1/7"
    ]
}