From patchwork Thu Apr 1 15:15:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 413617 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp649667jai; Thu, 1 Apr 2021 08:16:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL7jXZlDmKUdmLDDoncfJOoBaUDXR8bVjekkdZKuRXkSXeurgpBrK3TfdDnNZ+N276Ro/R X-Received: by 2002:adf:b355:: with SMTP id k21mr10415619wrd.156.1617290209855; Thu, 01 Apr 2021 08:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617290209; cv=none; d=google.com; s=arc-20160816; b=eqDQPzAiNJcNAtlOPMESZgKdT6cEcx0Rfo09/5bjz1V2zz0uKDq4OgqzlnCZEpO15w oOFpNbV38TGAEoI1O41GKwM7OPsVh+oC35iXCFzQlBAVsmq6GDmvSMTLIsHGXFaLHOWt m1FSsxDo9/UHGnBcxlT6YKPfInJKboICchHEnwO+HYOFo1HI4s49Gt8bnmeHyliY/i/7 PLKouLrujj2imSPew2bT/82mJ3H8BuA3R1K1oP1R52022TIbEYFgOVYuobkhsRa372V4 MWFL5qC4qU0KIm3sHp8873F0oLdiefWMEfkkQdrNm2MSfAiP+LaKVVtJlA15m/vgVNwt Gsrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature; bh=scZ+poTeHQybBfq+baOf/dHebHrzUI4PLmGHoF+1Es0=; b=DBuCV9wVeK7VtbydES9//tqtv3EPLMNJjXyR7H1BBwE40YUPPFaA8krc8eWpzVFML5 9CXhNYPlXEAfHxYDx79a8kB4sdiiqmFSCH1I0UO/ToG10C9VLG1hQ+Pgo5yOee6y20PJ kY/DkDEh4CucpEC5LTE/6E5u78Yzv4oCq2X7oHA1I/jg2pvcWBGl/0NSwAq7HxE3MNvT Hsy95JzwAXb3wGXvFFgLrDA6DiAe3K4yGNbMtiih30EGYnvCSfCyiQ9V6+ngPVOAsZuR 7BBbcfVMgJpVi8V/rBEkvvCI9UjvqbBB73VGWw+o3IL1t95FisdtToIyCP+ocRYpCmZa raAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=desiato.20200630 header.b=AfTX1WYH; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V2SSL0Pi; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:8b0:10b:1:d65d:64ff:fe57:4e05 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from desiato.infradead.org (desiato.infradead.org. [2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by mx.google.com with ESMTPS id x12si5893594wmj.67.2021.04.01.08.16.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 08:16:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:8b0:10b:1:d65d:64ff:fe57:4e05 as permitted sender) client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=desiato.20200630 header.b=AfTX1WYH; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V2SSL0Pi; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:8b0:10b:1:d65d:64ff:fe57:4e05 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=scZ+poTeHQybBfq+baOf/dHebHrzUI4PLmGHoF+1Es0=; b=AfTX1WYHhViXichou9wQwgu2fR ZB00E6EDS+B42EFp53SmQ7EQ9cavhMe/G5fpyasJlk/lXkxupMG2ZRK5pZBFKjcL3pORfQleuSJx9 b0iBMNQ2/UUMpNKCQSmBPSdEdZ+DnRk2V+vY4CHQJMijQRwL5eNTbFMejxq2+ctFPEyFwyl64piMK 6BQmjUWri8CDXEv0m3eB7dLZ4TmbWvU2TQ1a83RrFReSY8pUp9DNrkKdUGs5aUpqTKC6+3oqgb2dl YhMJdCiTSnv2wbzZXPhTC1I4bGGmPE0XWMPF58cZsLtMsUFLay/NUhqsuZ/ldT20559IA5o2WZEUQ nUXIh3dA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lRz2d-009yXU-M5; Thu, 01 Apr 2021 15:15:27 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lRz2X-009yVk-MU for linux-mtd@lists.infradead.org; Thu, 01 Apr 2021 15:15:24 +0000 Received: by mail-pf1-x433.google.com with SMTP id g15so1706002pfq.3 for ; Thu, 01 Apr 2021 08:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6hVxFcdqIWJsoJww2TX8Rs1EJ/1vV+wVzt8D6tZZ7vg=; b=V2SSL0Pi5+6mu3HiAmhqpMolEG4wuNHWrS2TVrZcHy9mpYl3rGgtq+Quq5UKfKlA1I /BowUj9PF06X3mwejz+A4ImVUz1iLhRkAI/qCJOcgCwIqKZc3JwpB3ayur3M+v4rFPbW qzqua/OwHMqEnMrnCeD5ilTR7H+RN7GToXmaWcsZm+rGNfI1TNTSPwt/YJInMBXTrTBW 3upl4/jMJQO1dt97S5SFBr5aIAbFfQFPB+2CT8kyYstKqt4IBwjxzAsTgAuJSrte02a6 tURtcps7W2BPrmm+TvkaQUW13BHkhx01llGLVuHVJxAlN1voarzqxgybOJ4FFV7QHIbG 9mng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6hVxFcdqIWJsoJww2TX8Rs1EJ/1vV+wVzt8D6tZZ7vg=; b=UrIcjQW9u6IBUwJnRe0n0TYq4Bp9i4/Vf6VOsbGUxqC59Kk+0xoyxArM5iNJvL4ALZ RUH1DiLN8gJYiCntbHdmfzQc204LHDAGyPGCyFFGnli63mo/1U8k7CvD56WB3ZdwyhQJ 6dULmEZ03yMloh6gJuk5HUKIr+jDBd8Tagc/dB69NMcI4/2KessdboCsVMbrStlvb8Vf vQBgQuWNAcbj2CRTzQgEaEmUJYMUNTejlljFjE19BlVYC0fLi6ee0C1pDv5941RLPF3a 1IxH9X6cqXn3Ihb6vgoXg/CMaWkSgrkkJrM3Ne4LhkjlcFUz1igsfmy8pc8JVA35ABKK 87xg== X-Gm-Message-State: AOAM5316lAXj+YWiyVOmEvWxOr9NW6pQ8Forb4QFsnSCpA53kG8FaVjd b3rdSXMs5FeaskH1amGrH9Kd X-Received: by 2002:a65:5a4a:: with SMTP id z10mr7745684pgs.240.1617290119691; Thu, 01 Apr 2021 08:15:19 -0700 (PDT) Received: from localhost.localdomain ([103.77.37.138]) by smtp.gmail.com with ESMTPSA id 35sm5652769pgr.14.2021.04.01.08.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 08:15:19 -0700 (PDT) From: Manivannan Sadhasivam To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, robh+dt@kernel.org Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, boris.brezillon@collabora.com, Daniele.Palmas@telit.com, bjorn.andersson@linaro.org, Manivannan Sadhasivam Subject: [PATCH v9 0/4] Add support for secure regions in NAND Date: Thu, 1 Apr 2021 20:45:04 +0530 Message-Id: <20210401151508.143075-1-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210401_161522_832848_8339EB16 X-CRM114-Status: GOOD ( 14.66 ) X-Spam-Score: 3.4 (+++) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On a typical end product, a vendor may choose to secure some regions in the NAND memory which are supposed to stay intact between FW upgrades. The access to those regions will be blocked by a secure e [...] Content analysis details: (3.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:433 listed in] [list.dnswl.org] 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [103.77.37.138 listed in zen.spamhaus.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org On a typical end product, a vendor may choose to secure some regions in the NAND memory which are supposed to stay intact between FW upgrades. The access to those regions will be blocked by a secure element like Trustzone. So the normal world software like Linux kernel should not touch these regions (including reading). So this series adds a property for declaring such secure regions in DT so that the driver can skip touching them. While at it, the Qcom NANDc DT binding is also converted to YAML format. Thanks, Mani Changes in v9: Based on review comments from Miquel: * Fixed the secure-regions check * Renamed the function to nand_region_is_secured() and used bool return * Moved the parsing function to nand_scan() * Added a patch to fix nand_cleanup in qcom driver Changes in v8: * Reworked the secure region check logic based on input from Boris * Removed the check where unnecessary in rawnand core. Changes in v7: * Made "size" u64 and fixed a warning reported by Kernel test bot Changes in v6: * Made use of "size" of the regions for comparision * Used "secure" instead of "sec" * Fixed the sizeof parameter in of_get_nand_secure_regions() Changes in v5: * Switched to "uint64-matrix" as suggested by Rob * Moved the whole logic from qcom driver to nand core as suggested by Boris Changes in v4: * Used "uint32-matrix" instead of "uint32-array" as per Rob's review. * Collected Rob's review tag for binding conversion patch Changes in v3: * Removed the nand prefix from DT property and moved the property parsing logic before nand_scan() in driver. Changes in v2: * Moved the secure-regions property to generic NAND binding as a NAND chip property and renamed it as "nand-secure-regions". Manivannan Sadhasivam (4): dt-bindings: mtd: Convert Qcom NANDc binding to YAML dt-bindings: mtd: Add a property to declare secure regions in NAND chips mtd: rawnand: Add support for secure regions in NAND memory mtd: rawnand: qcom: Add missing nand_cleanup() in error path .../bindings/mtd/nand-controller.yaml | 7 + .../devicetree/bindings/mtd/qcom,nandc.yaml | 196 ++++++++++++++++++ .../devicetree/bindings/mtd/qcom_nandc.txt | 142 ------------- drivers/mtd/nand/raw/nand_base.c | 107 +++++++++- drivers/mtd/nand/raw/qcom_nandc.c | 1 + include/linux/mtd/rawnand.h | 14 ++ 6 files changed, 324 insertions(+), 143 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/qcom,nandc.yaml delete mode 100644 Documentation/devicetree/bindings/mtd/qcom_nandc.txt -- 2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/