Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.0/patches/2219639/?format=api
{ "id": 2219639, "url": "http://patchwork.ozlabs.org/api/1.0/patches/2219639/?format=api", "project": { "id": 3, "url": "http://patchwork.ozlabs.org/api/1.0/projects/3/?format=api", "name": "Linux MTD development", "link_name": "linux-mtd", "list_id": "linux-mtd.lists.infradead.org", "list_email": "linux-mtd@lists.infradead.org", "web_url": null, "scm_url": null, "webscm_url": null }, "msgid": "<20260403-winbond-v6-18-rc1-spi-nor-swp-v4-14-833dab5e7288@bootlin.com>", "date": "2026-04-03T16:09:32", "name": "[v4,14/27] mtd: spi-nor: swp: Simplify checking the locked/unlocked range", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b7efffb7c075e4c51929a4f7979e42f71355d4fa", "submitter": { "id": 73368, "url": "http://patchwork.ozlabs.org/api/1.0/people/73368/?format=api", "name": "Miquel Raynal", "email": "miquel.raynal@bootlin.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-mtd/patch/20260403-winbond-v6-18-rc1-spi-nor-swp-v4-14-833dab5e7288@bootlin.com/mbox/", "series": [ { "id": 498652, "url": "http://patchwork.ozlabs.org/api/1.0/series/498652/?format=api", "date": "2026-04-03T16:09:18", "name": "mtd: spi-nor: Enhance software protection", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/498652/mbox/" } ], "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2219639/checks/", "tags": {}, "headers": { "Return-Path": "\n <linux-mtd-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=jEq2GCod;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256\n header.s=dkim header.b=POaCsvSW;\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=linux-mtd-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 4fnNx10FjKz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 04 Apr 2026 03:10:29 +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 1w8h6E-00000002HTW-1msL;\n\tFri, 03 Apr 2026 16:10:22 +0000", "from smtpout-02.galae.net ([185.246.84.56])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w8h64-00000002HDx-3kCb\n\tfor linux-mtd@lists.infradead.org;\n\tFri, 03 Apr 2026 16:10:19 +0000", "from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233])\n\tby smtpout-02.galae.net (Postfix) with ESMTPS id 6ABC31A312B;\n\tFri, 3 Apr 2026 16:10:11 +0000 (UTC)", "from mail.galae.net (mail.galae.net [212.83.136.155])\n\tby smtpout-01.galae.net (Postfix) with ESMTPS id 3FBD3603C1;\n\tFri, 3 Apr 2026 16:10:11 +0000 (UTC)", "from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon)\n with ESMTPSA id 3F13010450102;\n\tFri, 3 Apr 2026 18:10:08 +0200 (CEST)" ], "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:Cc:To:In-Reply-To:References:Message-Id\n\t:MIME-Version:Subject:Date: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=mR6gKFXs+4FheDQCOF8j4RJnXrKYj5u+Qug6Cr+mXsg=; b=jEq2GCodIeqmGO\n\tilIa/6tV8X+ggGLTlUKtZJXja84P2+uWWVuGW4YBJlchume0zBuu2lxOkpVDt/k51eodxRII9fXHf\n\tzETZYapED1rG6vIpOYYAkxDyS98OY9GR1EL9MaeRxHznzAbTgBwAmpHQPp47noqttMrQKpNpFKPTR\n\t8tvJPVqebIJ5VAB+dRVwtbQoh04ln31d7enzRgK57xfqRk/0LGbZ8az7cBVh671Gi5Iu4ikPyIHkU\n\tGhf7QBnfIxaZdDU/YNx7n0HVIYh87hf0MpPPpRMoXvqda+aogJVIi8KGxXNOMLuWZM1rDr9L03q3G\n\tDNdsGIZdHKt2Wo7VDJWg==;", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim;\n\tt=1775232610; h=from:subject:date:message-id:to:cc:mime-version:content-type:\n\t content-transfer-encoding:in-reply-to:references;\n\tbh=myF1jFvrCgWbnH0NLIBXbT8w17K7kgr7HnwXrOW3SAM=;\n\tb=POaCsvSWv8pvL4ZxIPvr/kU4sumw6OyoWfrbwOe2J6TLuAhC7PwCME9zGOGgU4i0L+K5Lk\n\thZGbjToX16mDPh9uU4OC230WtiySEsFuDRMLn/o1jAZSGJI13DL2oszZJkrsU2/VBEkaK5\n\tXp2+He6lV21tLxJlBGh5y4CXDQ7vQ4qdDsrj3e0h22MyxToVnxm2oD2t8rRtFLWFYeXKBo\n\t3lSgc5KNJTfsVEl1OL/Z+L07d+ATfu/KayA8SiP3Ez6SY6yR9sPAK/PQbzJCoyPH+3ZBc2\n\tIaNnxR3HGT+yg/JilhioanY+yf1/kTtCOM77/hHFhcVfQdSWVJiLxCmXB359Bg==" ], "From": "Miquel Raynal <miquel.raynal@bootlin.com>", "Date": "Fri, 03 Apr 2026 18:09:32 +0200", "Subject": "[PATCH v4 14/27] mtd: spi-nor: swp: Simplify checking the\n locked/unlocked range", "MIME-Version": "1.0", "Message-Id": "\n <20260403-winbond-v6-18-rc1-spi-nor-swp-v4-14-833dab5e7288@bootlin.com>", "References": "\n <20260403-winbond-v6-18-rc1-spi-nor-swp-v4-0-833dab5e7288@bootlin.com>", "In-Reply-To": "\n <20260403-winbond-v6-18-rc1-spi-nor-swp-v4-0-833dab5e7288@bootlin.com>", "To": "Pratyush Yadav <pratyush@kernel.org>, Michael Walle <mwalle@kernel.org>,\n Takahiro Kuwano <takahiro.kuwano@infineon.com>,\n Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>,\n Jonathan Corbet <corbet@lwn.net>", "Cc": "Sean Anderson <sean.anderson@linux.dev>,\n Thomas Petazzoni <thomas.petazzoni@bootlin.com>,\n Steam Lin <STLin2@winbond.com>, linux-mtd@lists.infradead.org,\n linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,\n Miquel Raynal <miquel.raynal@bootlin.com>", "X-Mailer": "b4 0.14.3", "X-Last-TLS-Session-Version": "TLSv1.3", "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ", "X-CRM114-CacheID": "sfid-20260403_091013_130486_96E313B7 ", "X-CRM114-Status": "GOOD ( 11.73 )", "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: In both the locking/unlocking steps, at the end we verify\n whether we do not lock/unlock more than requested (in which case an error\n must be returned). While being possible to do that with very simple mask\n comparisons,\n it does not scale when adding extra locking features such as the CMP\n possibility.\n In order to make these checks slightly easier to re [...]\n Content analysis details: (-2.1 points, 5.0 required)\n pts rule name description\n ---- ----------------------\n --------------------------------------------------\n 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to\n Validity was blocked. See\n https://knowledge.validity.com/hc/en-us/articles/20961730681243\n for more information.\n [185.246.84.56 listed in sa-accredit.habeas.com]\n 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The\n query to Validity was blocked. See\n https://knowledge.validity.com/hc/en-us/articles/20961730681243\n for more information.\n [185.246.84.56 listed in\n sa-trusted.bondedsender.org]\n -0.0 SPF_HELO_PASS SPF: HELO matches 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_EF Message has a valid DKIM or DK signature from\n envelope-from domain\n -0.1 DKIM_VALID Message has at least one valid DKIM or DK\n signature\n -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n author's\n domain\n -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%\n [score: 0.0000]\n 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to\n Validity was blocked. See\n https://knowledge.validity.com/hc/en-us/articles/20961730681243\n for more information.\n [185.246.84.56 listed in\n bl.score.senderscore.com]", "X-BeenThere": "linux-mtd@lists.infradead.org", "X-Mailman-Version": "2.1.34", "Precedence": "list", "List-Id": "Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>", "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/linux-mtd>,\n <mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>", "List-Archive": "<http://lists.infradead.org/pipermail/linux-mtd/>", "List-Post": "<mailto:linux-mtd@lists.infradead.org>", "List-Help": "<mailto:linux-mtd-request@lists.infradead.org?subject=help>", "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n <mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "\"linux-mtd\" <linux-mtd-bounces@lists.infradead.org>", "Errors-To": "linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org" }, "content": "In both the locking/unlocking steps, at the end we verify whether we do\nnot lock/unlock more than requested (in which case an error must be\nreturned).\n\nWhile being possible to do that with very simple mask comparisons, it\ndoes not scale when adding extra locking features such as the CMP\npossibility. In order to make these checks slightly easier to read and\nmore future proof, use existing helpers to read the (future) status\nregister, extract the covered range, and compare it with very usual\nalgebric comparisons.\n\nSigned-off-by: Miquel Raynal <miquel.raynal@bootlin.com>\n---\n drivers/mtd/spi-nor/swp.c | 25 +++++++++++++++++--------\n 1 file changed, 17 insertions(+), 8 deletions(-)", "diff": "diff --git a/drivers/mtd/spi-nor/swp.c b/drivers/mtd/spi-nor/swp.c\nindex e2e423b20989..c45a9ddd5788 100644\n--- a/drivers/mtd/spi-nor/swp.c\n+++ b/drivers/mtd/spi-nor/swp.c\n@@ -198,7 +198,8 @@ static int spi_nor_sr_lock(struct spi_nor *nor, loff_t ofs, u64 len)\n \tu64 min_prot_len;\n \tint ret;\n \tu8 status_old[1] = {}, status_new[1] = {};\n-\tu8 bp_mask = spi_nor_get_sr_bp_mask(nor);\n+\tloff_t ofs_old, ofs_new;\n+\tu64 len_old, len_new;\n \tloff_t lock_len;\n \tbool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB;\n \tbool use_top;\n@@ -246,10 +247,6 @@ static int spi_nor_sr_lock(struct spi_nor *nor, loff_t ofs, u64 len)\n \tif (ret)\n \t\treturn ret;\n \n-\t/* Don't \"lock\" with no region! */\n-\tif (!(status_new[0] & bp_mask))\n-\t\treturn -EINVAL;\n-\n \t/*\n \t * Disallow further writes if WP# pin is neither left floating nor\n \t * wrongly tied to GND (that includes internal pull-downs).\n@@ -262,8 +259,16 @@ static int spi_nor_sr_lock(struct spi_nor *nor, loff_t ofs, u64 len)\n \tif (status_new[0] == status_old[0])\n \t\treturn 0;\n \n+\tspi_nor_get_locked_range_sr(nor, status_old, &ofs_old, &len_old);\n+\tspi_nor_get_locked_range_sr(nor, status_new, &ofs_new, &len_new);\n+\n+\t/* Don't \"lock\" with no region! */\n+\tif (!len_new)\n+\t\treturn -EINVAL;\n+\n \t/* Only modify protection if it will not unlock other areas */\n-\tif ((status_new[0] & bp_mask) < (status_old[0] & bp_mask))\n+\tif (len_old &&\n+\t (ofs_old < ofs_new || (ofs_new + len_new) < (ofs_old + len_old)))\n \t\treturn -EINVAL;\n \n \treturn spi_nor_write_sr_and_check(nor, status_new[0]);\n@@ -279,7 +284,8 @@ static int spi_nor_sr_unlock(struct spi_nor *nor, loff_t ofs, u64 len)\n \tu64 min_prot_len;\n \tint ret;\n \tu8 status_old[1], status_new[1];\n-\tu8 bp_mask = spi_nor_get_sr_bp_mask(nor);\n+\tloff_t ofs_old, ofs_new;\n+\tu64 len_old, len_new;\n \tloff_t lock_len;\n \tbool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB;\n \tbool use_top;\n@@ -344,7 +350,10 @@ static int spi_nor_sr_unlock(struct spi_nor *nor, loff_t ofs, u64 len)\n \t\treturn 0;\n \n \t/* Only modify protection if it will not lock other areas */\n-\tif ((status_new[0] & bp_mask) > (status_old[0] & bp_mask))\n+\tspi_nor_get_locked_range_sr(nor, status_old, &ofs_old, &len_old);\n+\tspi_nor_get_locked_range_sr(nor, status_new, &ofs_new, &len_new);\n+\tif (len_old && len_new &&\n+\t (ofs_new < ofs_old || (ofs_old + len_old) < (ofs_new + len_new)))\n \t\treturn -EINVAL;\n \n \treturn spi_nor_write_sr_and_check(nor, status_new[0]);\n", "prefixes": [ "v4", "14/27" ] }