Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4647027rwb; Mon, 31 Jul 2023 09:57:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlG/9FKA9hq4nm0PkIfH2g2SmBWOYXVmufIPCa4M2biQYIcBwoVsgkT6QSTM4seWM6TSq+Pl X-Received: by 2002:a05:6808:198e:b0:3a7:1cca:f99f with SMTP id bj14-20020a056808198e00b003a71ccaf99fmr8006391oib.34.1690822639664; Mon, 31 Jul 2023 09:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690822639; cv=none; d=google.com; s=arc-20160816; b=m+gDtBo2V8+acjH/kEnKX4nRO0TsmqR3eCMUuNfnus5CfAh7vxVLpB/C0vfedgmSHV 7+uUzLVg0+f4EwBsciVvKFp54+In5ejO2HOlKbibL6da3D06aDznelGiKWa5hKsrMBP3 KXhXm21ogzxP1Hwi7oF17IiU5Opnc9BVjc0bqLpeFPhOs7nvuZ19LGQTtdInibprdBUo mCEHgPeJkJ3lKztc4ZgTqxrARas5iF9+JjREuQM+lzS1iMgyJRMF5lUx+mbyLy2m6E2/ cJVBhbR7uWLtltuIWMo0s5dSnAYVL1OfrLmegX35z1nOe2wAOKMVF4dttxeo6thzps8q q1vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=UUM9DVE4fY1+nFfIlnL7tbB5QPeWl2QG53zMk2DkVGg=; fh=X/0+zTlj7dbOlX8zLoC0oT1Hnmh2UNZtwJdV8xW3ErY=; b=aQ+nT8rEfbWpwWAsrUMVkOrKaBDA2VF/q2nH7tCP/q/WyX9S8g3ki3oy8oumAVTgpy yZ887N9i5WODcKDxeEsmRO/OCN+Cygh/MkGdjfnxjkc7HK7Is+bIq20aJA9GPet3hagd jO9r5yUSVekOXToSMnsMoLvWSGGRJwa0B+md4rtTpWyOzp3UOYc03tKWC2YjqGp4iz4x hjejR3Q3Cu3NGdrVOdL7ughCUXmitMEnOPTa5A8G88XVGiIhmcIoMiw5OSmfnXxfFRsw V796m4/RKapKjGAP9Fecv7Get9yeuER4zmGlYfLHTCX+FIT+sR2RS1MESPny9M/5xPyj L6Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V8Bz0h4o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h62-20020a638341000000b00563de199314si7424937pge.896.2023.07.31.09.57.07; Mon, 31 Jul 2023 09:57:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V8Bz0h4o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231857AbjGaQdR (ORCPT + 99 others); Mon, 31 Jul 2023 12:33:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232782AbjGaQcx (ORCPT ); Mon, 31 Jul 2023 12:32:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6880DF; Mon, 31 Jul 2023 09:32:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 54D3B61212; Mon, 31 Jul 2023 16:32:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB5FAC433C7; Mon, 31 Jul 2023 16:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690821171; bh=9APW6kjAiEHu5U4FuEto4YMwT8x/YGo6oRwvtvD7SiQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V8Bz0h4obauNPZ7sMNXGHjPqUq/cyyXApUk90A/MSRkLEAmzjHzJYuvH/Ww2o4u4s jPkB5FD7qQ9kUYIJv19SDXnWvN8XXvlxZzXFgBuf4A2pjUVF8gQNhD2lY3D/2Sp1xE CpRoc7SFLc1GZiG4+kF7PMoLtqI5ncSd1EfLUHIKvtOy2eQIVFDj5hNmSuMTHhIv5a CdTOSVFsWVQOh3Wnq60SwYSRFOifTdQmQvnAYlyepH3xmgJws7MFdOAgDNXuBa/y0B YQI3tW87kRUnddAPm1kLe+TfxHbJc4J1UJZQEhRlXRyKe/tVXnv+GeS/EngU4hqVRO hODkDanX4jmTw== Date: Mon, 31 Jul 2023 09:35:57 -0700 From: Bjorn Andersson To: Mukesh Ojha Cc: Komal Bajaj , agross@kernel.org, konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, srinivas.kandagatla@linaro.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 2/2] nvmem: sec-qfprom: Add Qualcomm secure QFPROM support Message-ID: References: <20230724083849.8277-1-quic_kbajaj@quicinc.com> <20230724083849.8277-3-quic_kbajaj@quicinc.com> <9f417fea-38cf-942b-514e-99b47f27c544@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9f417fea-38cf-942b-514e-99b47f27c544@quicinc.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 27, 2023 at 12:09:07PM +0530, Mukesh Ojha wrote: > On 7/24/2023 2:08 PM, Komal Bajaj wrote: [..] > > diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile > > index f82431ec8aef..e248d3daadf3 100644 > > --- a/drivers/nvmem/Makefile > > +++ b/drivers/nvmem/Makefile > > @@ -44,6 +44,8 @@ obj-$(CONFIG_NVMEM_NINTENDO_OTP) += nvmem-nintendo-otp.o > > nvmem-nintendo-otp-y := nintendo-otp.o > > obj-$(CONFIG_NVMEM_QCOM_QFPROM) += nvmem_qfprom.o > > nvmem_qfprom-y := qfprom.o > > +obj-$(CONFIG_NVMEM_QCOM_SEC_QFPROM) += nvmem_sec_qfprom.o > > +nvmem_sec_qfprom-y := sec-qfprom.o > > Are we just doing this for just renaming the object ? > Correct. > > obj-$(CONFIG_NVMEM_RAVE_SP_EEPROM) += nvmem-rave-sp-eeprom.o > > nvmem-rave-sp-eeprom-y := rave-sp-eeprom.o > > obj-$(CONFIG_NVMEM_RMEM) += nvmem-rmem.o > > diff --git a/drivers/nvmem/sec-qfprom.c b/drivers/nvmem/sec-qfprom.c [..] > > +static int sec_qfprom_reg_read(void *context, unsigned int reg, void *_val, size_t bytes) > > +{ > > + struct sec_qfprom *priv = context; > > + unsigned int i; > > + u8 *val = _val; > > + u32 read_val; > > + u8 *tmp; > > + > > + for (i = 0; i < bytes; i++, reg++) { > > + if (i == 0 || reg % 4 == 0) { > > + if (qcom_scm_io_readl(priv->base + (reg & ~3), &read_val)) { > > + dev_err(priv->dev, "Couldn't access fuse register\n"); > > + return -EINVAL; > > + } > > + tmp = (u8 *)&read_val; > > + } > > + > > + val[i] = tmp[reg & 3]; > > + } > > Getting secure read from fuse region is fine here, since we have to read > 4 byte from trustzone, but this restriction of reading is also there > for sm8{4|5}50 soc's where byte by byte reading is protected and granularity > set to 4 byte (qfprom_reg_read() in drivers/nvmem/qfprom.c) > is will result in abort, in that case this function need to export this > logic. > If qfprom needs similar treatment, then let's land this first and then consider generalizing (i.e. move to some library code) this - or if infeasible, just fix qfprom_reg_read(). Regards, Bjorn