linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gaurav Kashyap (QUIC)" <quic_gaurkash@quicinc.com>
To: "dmitry.baryshkov@linaro.org" <dmitry.baryshkov@linaro.org>,
	"Gaurav Kashyap (QUIC)" <quic_gaurkash@quicinc.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>, Jens Axboe <axboe@kernel.dk>,
	Jonathan Corbet <corbet@lwn.net>,
	Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Asutosh Das <quic_asutoshd@quicinc.com>,
	"Ritesh Harjani" <ritesh.list@gmail.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	"Bart Van Assche" <bvanassche@acm.org>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Eric Biggers <ebiggers@kernel.org>,
	"Theodore Y. Ts'o" <tytso@mit.edu>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	"manivannan.sadhasivam@linaro.org"
	<manivannan.sadhasivam@linaro.org>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dm-devel@lists.linux.dev" <dm-devel@lists.linux.dev>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"linux-fscrypt@vger.kernel.org" <linux-fscrypt@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	bartosz.golaszewski <bartosz.golaszewski@linaro.org>
Subject: RE: [PATCH v6 09/17] soc: qcom: ice: add HWKM support to the ICE driver
Date: Thu, 12 Sep 2024 22:17:03 +0000	[thread overview]
Message-ID: <9bd0c9356e2b471385bcb2780ff2425b@quicinc.com> (raw)
In-Reply-To: <CAA8EJpp_HY+YmMCRwdteeAHnSHtjuHb=nFar60O_PwLwjk0mNA@mail.gmail.com>


On Monday, September 9, 2024 11:29 PM PDT, Dmitry Baryshkov wrote:
> On Tue, 10 Sept 2024 at 03:51, Gaurav Kashyap (QUIC)
> <quic_gaurkash@quicinc.com> wrote:
> >
> > Hello Dmitry and Neil
> >
> > On Monday, September 9, 2024 2:44 AM PDT, Dmitry Baryshkov wrote:
> > > On Mon, Sep 09, 2024 at 10:58:30AM GMT, Neil Armstrong wrote:
> > > > On 07/09/2024 00:07, Dmitry Baryshkov wrote:
> > > > > On Fri, Sep 06, 2024 at 08:07:12PM GMT, Bartosz Golaszewski wrote:
> > > > > > From: Gaurav Kashyap <quic_gaurkash@quicinc.com>
> > > > > >
> > > > > > Qualcomm's ICE (Inline Crypto Engine) contains a proprietary
> > > > > > key management hardware called Hardware Key Manager (HWKM).
> > > > > > Add
> > > HWKM
> > > > > > support to the ICE driver if it is available on the platform.
> > > > > > HWKM primarily provides hardware wrapped key support where
> the
> > > > > > ICE
> > > > > > (storage) keys are not available in software and instead
> > > > > > protected in
> > > hardware.
> > > > > >
> > > > > > When HWKM software support is not fully available (from
> > > > > > Trustzone), there can be a scenario where the ICE hardware
> > > > > > supports HWKM, but it cannot be used for wrapped keys. In this
> > > > > > case, raw keys have to be used without using the HWKM. We
> > > > > > query the TZ at run-time to find out whether wrapped keys
> > > > > > support is
> > > available.
> > > > > >
> > > > > > Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
> > > > > > Signed-off-by: Gaurav Kashyap <quic_gaurkash@quicinc.com>
> > > > > > Signed-off-by: Bartosz Golaszewski
> > > > > > <bartosz.golaszewski@linaro.org>
> > > > > > ---
> > > > > >   drivers/soc/qcom/ice.c | 152
> > > +++++++++++++++++++++++++++++++++++++++++++++++--
> > > > > >   include/soc/qcom/ice.h |   1 +
> > > > > >   2 files changed, 149 insertions(+), 4 deletions(-)
> > > > > >
> > > > > >   int qcom_ice_enable(struct qcom_ice *ice)
> > > > > >   {
> > > > > > + int err;
> > > > > > +
> > > > > >           qcom_ice_low_power_mode_enable(ice);
> > > > > >           qcom_ice_optimization_enable(ice);
> > > > > > - return qcom_ice_wait_bist_status(ice);
> > > > > > + if (ice->use_hwkm)
> > > > > > +         qcom_ice_enable_standard_mode(ice);
> > > > > > +
> > > > > > + err = qcom_ice_wait_bist_status(ice); if (err)
> > > > > > +         return err;
> > > > > > +
> > > > > > + if (ice->use_hwkm)
> > > > > > +         qcom_ice_hwkm_init(ice);
> > > > > > +
> > > > > > + return err;
> > > > > >   }
> > > > > >   EXPORT_SYMBOL_GPL(qcom_ice_enable);
> > > > > > @@ -150,6 +282,10 @@ int qcom_ice_resume(struct qcom_ice
> *ice)
> > > > > >                   return err;
> > > > > >           }
> > > > > > + if (ice->use_hwkm) {
> > > > > > +         qcom_ice_enable_standard_mode(ice);
> > > > > > +         qcom_ice_hwkm_init(ice); }
> > > > > >           return qcom_ice_wait_bist_status(ice);
> > > > > >   }
> > > > > >   EXPORT_SYMBOL_GPL(qcom_ice_resume);
> > > > > > @@ -157,6 +293,7 @@ EXPORT_SYMBOL_GPL(qcom_ice_resume);
> > > > > >   int qcom_ice_suspend(struct qcom_ice *ice)
> > > > > >   {
> > > > > >           clk_disable_unprepare(ice->core_clk);
> > > > > > + ice->hwkm_init_complete = false;
> > > > > >           return 0;
> > > > > >   }
> > > > > > @@ -206,6 +343,12 @@ int qcom_ice_evict_key(struct qcom_ice
> > > > > > *ice,
> > > int slot)
> > > > > >   }
> > > > > >   EXPORT_SYMBOL_GPL(qcom_ice_evict_key);
> > > > > > +bool qcom_ice_hwkm_supported(struct qcom_ice *ice) {  return
> > > > > > +ice->use_hwkm; }
> > > EXPORT_SYMBOL_GPL(qcom_ice_hwkm_supported);
> > > > > > +
> > > > > >   static struct qcom_ice *qcom_ice_create(struct device *dev,
> > > > > >                                           void __iomem *base)
> > > > > >   {
> > > > > > @@ -240,6 +383,7 @@ static struct qcom_ice
> > > > > > *qcom_ice_create(struct
> > > device *dev,
> > > > > >                   engine->core_clk = devm_clk_get_enabled(dev, NULL);
> > > > > >           if (IS_ERR(engine->core_clk))
> > > > > >                   return ERR_CAST(engine->core_clk);
> > > > > > + engine->use_hwkm = qcom_scm_has_wrapped_key_support();
> > > > >
> > > > > This still makes the decision on whether to use HW-wrapped keys
> > > > > on behalf of a user. I suppose this is incorrect. The user must
> > > > > be able to use raw keys even if HW-wrapped keys are available on
> > > > > the platform. One of the examples for such use-cases is if a
> > > > > user prefers to be able to recover stored information in case of
> > > > > a device failure (such recovery will be impossible if SoC is
> > > > > damaged and HW-
> > > wrapped keys are used).
> > > >
> > > > Isn't that already the case ? the
> BLK_CRYPTO_KEY_TYPE_HW_WRAPPED
> > > size
> > > > is here to select HW-wrapped key, otherwise the ol' raw key is passed.
> > > > Just look the next patch.
> > > >
> > > > Or did I miss something ?
> > >
> > > That's a good question. If use_hwkm is set, ICE gets programmed to
> > > use hwkm (see qcom_ice_hwkm_init() call above). I'm not sure if it
> > > is expected to work properly if after such a call we pass raw key.
> > >
> >
> > Once ICE has moved to a HWKM mode, the firmware key programming
> currently does not support raw keys.
> > This support is being added for the next Qualcomm chipset in Trustzone to
> support both at he same time, but that will take another year or two to hit
> the market.
> > Until that time, due to TZ (firmware) limitations , the driver can only
> support one or the other.
> >
> > We also cannot keep moving ICE modes, due to the HWKM enablement
> being a one-time configurable value at boot.
> 
> So the init of HWKM should be delayed until the point where the user tells if
> HWKM or raw keys should be used.

Ack.
I'll work with Bartosz to look into moving to HWKM mode only during the first key program request

> 
> >
> > > >
> > > > Neil
> > > >
> > > > >
> > > > > >           if (!qcom_ice_check_supported(engine))
> > > > > >                   return ERR_PTR(-EOPNOTSUPP); diff --git
> > > > > > a/include/soc/qcom/ice.h b/include/soc/qcom/ice.h index
> > > > > > 9dd835dba2a7..1f52e82e3e1c 100644
> > > > > > --- a/include/soc/qcom/ice.h
> > > > > > +++ b/include/soc/qcom/ice.h
> > > > > > @@ -34,5 +34,6 @@ int qcom_ice_program_key(struct qcom_ice
> *ice,
> > > > > >                            const struct blk_crypto_key *bkey,
> > > > > >                            u8 data_unit_size, int slot);
> > > > > >   int qcom_ice_evict_key(struct qcom_ice *ice, int slot);
> > > > > > +bool qcom_ice_hwkm_supported(struct qcom_ice *ice);
> > > > > >   struct qcom_ice *of_qcom_ice_get(struct device *dev);
> > > > > >   #endif /* __QCOM_ICE_H__ */
> > > > > >
> > > > > > --
> > > > > > 2.43.0
> > > > > >
> > > > >
> > > >
> > >
> > > --
> > > With best wishes
> > > Dmitry
> >
> > Regards,
> > Gaurav
> 
> 
> 
> --
> With best wishes
> Dmitry

Regards,
Gaurav

  reply	other threads:[~2024-09-12 22:17 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06 18:07 [PATCH v6 00/17] Hardware wrapped key support for QCom ICE and UFS core Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 01/17] blk-crypto: add basic hardware-wrapped key support Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 02/17] blk-crypto: show supported key types in sysfs Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 03/17] blk-crypto: add ioctls to create and prepare hardware-wrapped keys Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 04/17] fscrypt: add support for " Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 05/17] ice, ufs, mmc: use the blk_crypto_key struct when programming the key Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 06/17] firmware: qcom: scm: add a call for deriving the software secret Bartosz Golaszewski
2024-09-09 11:23   ` Konrad Dybcio
2024-09-26 14:45     ` Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 07/17] firmware: qcom: scm: add calls for creating, preparing and importing keys Bartosz Golaszewski
2024-09-09 11:24   ` Konrad Dybcio
2024-09-06 18:07 ` [PATCH v6 08/17] firmware: qcom: scm: add a call for checking wrapped key support Bartosz Golaszewski
2024-09-09 11:25   ` Konrad Dybcio
2024-09-06 18:07 ` [PATCH v6 09/17] soc: qcom: ice: add HWKM support to the ICE driver Bartosz Golaszewski
2024-09-06 22:07   ` Dmitry Baryshkov
2024-09-09  8:58     ` Neil Armstrong
2024-09-09  9:44       ` Dmitry Baryshkov
2024-09-10  0:51         ` Gaurav Kashyap (QUIC)
2024-09-10  6:28           ` Dmitry Baryshkov
2024-09-12 22:17             ` Gaurav Kashyap (QUIC) [this message]
2024-09-12 23:17               ` Eric Biggers
2024-09-13  4:28                 ` Dmitry Baryshkov
2024-09-13  4:57                   ` Eric Biggers
2024-09-13 12:21                     ` Dmitry Baryshkov
2024-09-21 19:49                       ` Eric Biggers
2024-09-21 22:33                         ` Dmitry Baryshkov
2024-09-13  7:23                 ` Neil Armstrong
2024-09-06 18:07 ` [PATCH v6 10/17] soc: qcom: ice: add support for hardware wrapped keys Bartosz Golaszewski
2024-09-09 11:51   ` Konrad Dybcio
2024-09-06 18:07 ` [PATCH v6 11/17] soc: qcom: ice: add support for generating, importing and preparing keys Bartosz Golaszewski
2024-09-09  2:36   ` kernel test robot
2024-09-06 18:07 ` [PATCH v6 12/17] ufs: core: add support for wrapped keys to UFS core Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 13/17] ufs: core: add support for deriving the software secret Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 14/17] ufs: core: add support for generating, importing and preparing keys Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 15/17] ufs: host: add support for wrapped keys in QCom UFS Bartosz Golaszewski
2024-09-06 18:07 ` [PATCH v6 16/17] ufs: host: add a callback for deriving software secrets and use it Bartosz Golaszewski
2024-09-09 11:56   ` Konrad Dybcio
2024-09-06 18:07 ` [PATCH v6 17/17] ufs: host: add support for generating, importing and preparing wrapped keys Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9bd0c9356e2b471385bcb2780ff2425b@quicinc.com \
    --to=quic_gaurkash@quicinc.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=adrian.hunter@intel.com \
    --cc=agk@redhat.com \
    --cc=alim.akhtar@samsung.com \
    --cc=andersson@kernel.org \
    --cc=avri.altman@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brauner@kernel.org \
    --cc=brgl@bgdev.pl \
    --cc=bvanassche@acm.org \
    --cc=corbet@lwn.net \
    --cc=dm-devel@lists.linux.dev \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=ebiggers@kernel.org \
    --cc=jack@suse.cz \
    --cc=jaegeuk@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=martin.petersen@oracle.com \
    --cc=mpatocka@redhat.com \
    --cc=neil.armstrong@linaro.org \
    --cc=quic_asutoshd@quicinc.com \
    --cc=ritesh.list@gmail.com \
    --cc=snitzer@kernel.org \
    --cc=tytso@mit.edu \
    --cc=ulf.hansson@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).