mbox series

[v4,0/3] Inline Encryption Support for UFS

Message ID 20200706200414.2027450-1-satyat@google.com (mailing list archive)
Headers show
Series Inline Encryption Support for UFS | expand

Message

Satya Tangirala July 6, 2020, 8:04 p.m. UTC
This patch series adds support for inline encryption to UFS using
the inline encryption support in the block layer. It follows the JEDEC
UFSHCI v2.1 specification, which defines inline encryption for UFS.

This patch series previously went through a number of iterations as
part of the "Inline Encryption Support" patchset (last version was v13:
https://lkml.kernel.org/r/20200514003727.69001-1-satyat@google.com).
This patch series is rebased on v5.8-rc4.

Patch 1 introduces the crypto registers and struct definitions defined
in the UFSHCI v2.1 spec.

Patch 2 introduces functions to manipulate the UFS inline encryption
hardware (again in line with the UFSHCI v2.1 spec) via the block
layer keyslot manager. Device specific drivers must set the
UFSHCD_CAP_CRYPTO in hba->caps before ufshcd_hba_init_crypto is called
to opt-in to inline encryption support.

Patch 3 wires up ufshcd.c with the UFS crypto API introduced in Patch 2.

This patch series has been tested on some Qualcomm chipsets (on the
db845c, sm8150-mtp and sm8250-mtp) using some additional patches at
https://lkml.kernel.org/linux-scsi/20200501045111.665881-1-ebiggers@kernel.org/
and on some Mediatek chipsets using the additional patch in
https://lkml.kernel.org/linux-scsi/20200304022101.14165-1-stanley.chu@mediatek.com/.
These additional patches are required because these chipsets need certain
additional behaviour not specified within the UFSHCI v2.1 spec.

Thanks a lot to all the folks who tested this out!

Changes v3 => v4:
 - fix incorrect patch folding
 - some cleanups from Eric

Changes v2 => v3:
 - introduce ufshcd_prepare_req_desc_hdr_crypto to clean up code slightly
 - split up ufshcd_hba_init_crypto into ufshcd_hba_init_crypto_capabilities
   and ufshcd_init_crypto. The first function is called from
   ufshcd_hba_capabilities, and only reads crypto capabilities from device
   registers and sets up appropriate crypto structures. The second function
   is called from ufshcd_init, and actually initializes the inline crypto
   hardware.

Changes v1 => v2
 - handle OCS_DEVICE_FATAL_ERROR explicitly in ufshcd_transfer_rsp_status

Satya Tangirala (3):
  scsi: ufs: UFS driver v2.1 spec crypto additions
  scsi: ufs: UFS crypto API
  scsi: ufs: Add inline encryption support to UFS

 drivers/scsi/ufs/Kconfig         |   9 ++
 drivers/scsi/ufs/Makefile        |   1 +
 drivers/scsi/ufs/ufshcd-crypto.c | 238 +++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshcd-crypto.h |  77 ++++++++++
 drivers/scsi/ufs/ufshcd.c        |  49 ++++++-
 drivers/scsi/ufs/ufshcd.h        |  24 ++++
 drivers/scsi/ufs/ufshci.h        |  67 ++++++++-
 7 files changed, 456 insertions(+), 9 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-crypto.c
 create mode 100644 drivers/scsi/ufs/ufshcd-crypto.h

Comments

Eric Biggers July 7, 2020, 12:13 a.m. UTC | #1
On Mon, Jul 06, 2020 at 08:04:11PM +0000, Satya Tangirala wrote:
> This patch series adds support for inline encryption to UFS using
> the inline encryption support in the block layer. It follows the JEDEC
> UFSHCI v2.1 specification, which defines inline encryption for UFS.
> 
> This patch series previously went through a number of iterations as
> part of the "Inline Encryption Support" patchset (last version was v13:
> https://lkml.kernel.org/r/20200514003727.69001-1-satyat@google.com).
> This patch series is rebased on v5.8-rc4.
> 
> Patch 1 introduces the crypto registers and struct definitions defined
> in the UFSHCI v2.1 spec.
> 
> Patch 2 introduces functions to manipulate the UFS inline encryption
> hardware (again in line with the UFSHCI v2.1 spec) via the block
> layer keyslot manager. Device specific drivers must set the
> UFSHCD_CAP_CRYPTO in hba->caps before ufshcd_hba_init_crypto is called
> to opt-in to inline encryption support.

Note that it's now ufshcd_hba_init_crypto_capabilities(), not
ufshcd_hba_init_crypto().

> 
> Patch 3 wires up ufshcd.c with the UFS crypto API introduced in Patch 2.
> 
> This patch series has been tested on some Qualcomm chipsets (on the
> db845c, sm8150-mtp and sm8250-mtp) using some additional patches at
> https://lkml.kernel.org/linux-scsi/20200501045111.665881-1-ebiggers@kernel.org/
> and on some Mediatek chipsets using the additional patch in
> https://lkml.kernel.org/linux-scsi/20200304022101.14165-1-stanley.chu@mediatek.com/.
> These additional patches are required because these chipsets need certain
> additional behaviour not specified within the UFSHCI v2.1 spec.
> 
> Thanks a lot to all the folks who tested this out!
> 
> Changes v3 => v4:
>  - fix incorrect patch folding
>  - some cleanups from Eric
> 
> Changes v2 => v3:
>  - introduce ufshcd_prepare_req_desc_hdr_crypto to clean up code slightly
>  - split up ufshcd_hba_init_crypto into ufshcd_hba_init_crypto_capabilities
>    and ufshcd_init_crypto. The first function is called from
>    ufshcd_hba_capabilities, and only reads crypto capabilities from device
>    registers and sets up appropriate crypto structures. The second function
>    is called from ufshcd_init, and actually initializes the inline crypto
>    hardware.
> 
> Changes v1 => v2
>  - handle OCS_DEVICE_FATAL_ERROR explicitly in ufshcd_transfer_rsp_status
> 
> Satya Tangirala (3):
>   scsi: ufs: UFS driver v2.1 spec crypto additions
>   scsi: ufs: UFS crypto API
>   scsi: ufs: Add inline encryption support to UFS

These patches look good to me.  Avri and Alim, what do you think?
We'd like these to be applied for 5.9.

- Eric
Alim Akhtar July 7, 2020, 5:36 p.m. UTC | #2
Hi Satya,

> -----Original Message-----
> From: Satya Tangirala <satyat@google.com>
> Sent: 07 July 2020 01:34
> To: linux-scsi@vger.kernel.org; Avri Altman <avri.altman@wdc.com>; Alim
> Akhtar <alim.akhtar@samsung.com>
> Cc: Barani Muthukumaran <bmuthuku@qti.qualcomm.com>; Kuohong Wang
> <kuohong.wang@mediatek.com>; Kim Boojin <boojin.kim@samsung.com>;
> Satya Tangirala <satyat@google.com>
> Subject: [PATCH v4 0/3] Inline Encryption Support for UFS
> 
> This patch series adds support for inline encryption to UFS using the inline
> encryption support in the block layer. It follows the JEDEC UFSHCI v2.1
> specification, which defines inline encryption for UFS.
> 
> This patch series previously went through a number of iterations as part of the
> "Inline Encryption Support" patchset (last version was v13:
> https://lkml.kernel.org/r/20200514003727.69001-1-satyat@google.com).
> This patch series is rebased on v5.8-rc4.
> 
> Patch 1 introduces the crypto registers and struct definitions defined in the
> UFSHCI v2.1 spec.
> 
> Patch 2 introduces functions to manipulate the UFS inline encryption hardware
> (again in line with the UFSHCI v2.1 spec) via the block layer keyslot manager.
> Device specific drivers must set the UFSHCD_CAP_CRYPTO in hba->caps before
> ufshcd_hba_init_crypto is called to opt-in to inline encryption support.
> 
> Patch 3 wires up ufshcd.c with the UFS crypto API introduced in Patch 2.
> 
> This patch series has been tested on some Qualcomm chipsets (on the db845c,
> sm8150-mtp and sm8250-mtp) using some additional patches at
> https://lkml.kernel.org/linux-scsi/20200501045111.665881-1-
> ebiggers@kernel.org/
> and on some Mediatek chipsets using the additional patch in
> https://lkml.kernel.org/linux-scsi/20200304022101.14165-1-
> stanley.chu@mediatek.com/.
> These additional patches are required because these chipsets need certain
> additional behaviour not specified within the UFSHCI v2.1 spec.
> 
> Thanks a lot to all the folks who tested this out!
> 
> Changes v3 => v4:
>  - fix incorrect patch folding
>  - some cleanups from Eric
> 
> Changes v2 => v3:
>  - introduce ufshcd_prepare_req_desc_hdr_crypto to clean up code slightly
>  - split up ufshcd_hba_init_crypto into ufshcd_hba_init_crypto_capabilities
>    and ufshcd_init_crypto. The first function is called from
>    ufshcd_hba_capabilities, and only reads crypto capabilities from device
>    registers and sets up appropriate crypto structures. The second function
>    is called from ufshcd_init, and actually initializes the inline crypto
>    hardware.
> 
> Changes v1 => v2
>  - handle OCS_DEVICE_FATAL_ERROR explicitly in ufshcd_transfer_rsp_status
> 
> Satya Tangirala (3):
>   scsi: ufs: UFS driver v2.1 spec crypto additions
>   scsi: ufs: UFS crypto API
>   scsi: ufs: Add inline encryption support to UFS
> 
>  drivers/scsi/ufs/Kconfig         |   9 ++
>  drivers/scsi/ufs/Makefile        |   1 +
>  drivers/scsi/ufs/ufshcd-crypto.c | 238 +++++++++++++++++++++++++++++++
> drivers/scsi/ufs/ufshcd-crypto.h |  77 ++++++++++
>  drivers/scsi/ufs/ufshcd.c        |  49 ++++++-
>  drivers/scsi/ufs/ufshcd.h        |  24 ++++
>  drivers/scsi/ufs/ufshci.h        |  67 ++++++++-
>  7 files changed, 456 insertions(+), 9 deletions(-)  create mode 100644
> drivers/scsi/ufs/ufshcd-crypto.c  create mode 100644 drivers/scsi/ufs/ufshcd-
> crypto.h
> 
Looks Good to me.
I don’t have a platform to test this series though.
It will be good to get a Tested-by tags for this series.

Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>

> --
> 2.27.0.212.ge8ba1cc988-goog
Eric Biggers July 7, 2020, 5:59 p.m. UTC | #3
On Tue, Jul 07, 2020 at 11:06:14PM +0530, Alim Akhtar wrote:
> Hi Satya,
> 
> > -----Original Message-----
> > From: Satya Tangirala <satyat@google.com>
> > Sent: 07 July 2020 01:34
> > To: linux-scsi@vger.kernel.org; Avri Altman <avri.altman@wdc.com>; Alim
> > Akhtar <alim.akhtar@samsung.com>
> > Cc: Barani Muthukumaran <bmuthuku@qti.qualcomm.com>; Kuohong Wang
> > <kuohong.wang@mediatek.com>; Kim Boojin <boojin.kim@samsung.com>;
> > Satya Tangirala <satyat@google.com>
> > Subject: [PATCH v4 0/3] Inline Encryption Support for UFS
> > 
> > This patch series adds support for inline encryption to UFS using the inline
> > encryption support in the block layer. It follows the JEDEC UFSHCI v2.1
> > specification, which defines inline encryption for UFS.
> > 
> > This patch series previously went through a number of iterations as part of the
> > "Inline Encryption Support" patchset (last version was v13:
> > https://lkml.kernel.org/r/20200514003727.69001-1-satyat@google.com).
> > This patch series is rebased on v5.8-rc4.
> > 
> > Patch 1 introduces the crypto registers and struct definitions defined in the
> > UFSHCI v2.1 spec.
> > 
> > Patch 2 introduces functions to manipulate the UFS inline encryption hardware
> > (again in line with the UFSHCI v2.1 spec) via the block layer keyslot manager.
> > Device specific drivers must set the UFSHCD_CAP_CRYPTO in hba->caps before
> > ufshcd_hba_init_crypto is called to opt-in to inline encryption support.
> > 
> > Patch 3 wires up ufshcd.c with the UFS crypto API introduced in Patch 2.
> > 
> > This patch series has been tested on some Qualcomm chipsets (on the db845c,
> > sm8150-mtp and sm8250-mtp) using some additional patches at
> > https://lkml.kernel.org/linux-scsi/20200501045111.665881-1-
> > ebiggers@kernel.org/
> > and on some Mediatek chipsets using the additional patch in
> > https://lkml.kernel.org/linux-scsi/20200304022101.14165-1-
> > stanley.chu@mediatek.com/.
> > These additional patches are required because these chipsets need certain
> > additional behaviour not specified within the UFSHCI v2.1 spec.
> > 
> > Thanks a lot to all the folks who tested this out!
> > 
> > Changes v3 => v4:
> >  - fix incorrect patch folding
> >  - some cleanups from Eric
> > 
> > Changes v2 => v3:
> >  - introduce ufshcd_prepare_req_desc_hdr_crypto to clean up code slightly
> >  - split up ufshcd_hba_init_crypto into ufshcd_hba_init_crypto_capabilities
> >    and ufshcd_init_crypto. The first function is called from
> >    ufshcd_hba_capabilities, and only reads crypto capabilities from device
> >    registers and sets up appropriate crypto structures. The second function
> >    is called from ufshcd_init, and actually initializes the inline crypto
> >    hardware.
> > 
> > Changes v1 => v2
> >  - handle OCS_DEVICE_FATAL_ERROR explicitly in ufshcd_transfer_rsp_status
> > 
> > Satya Tangirala (3):
> >   scsi: ufs: UFS driver v2.1 spec crypto additions
> >   scsi: ufs: UFS crypto API
> >   scsi: ufs: Add inline encryption support to UFS
> > 
> >  drivers/scsi/ufs/Kconfig         |   9 ++
> >  drivers/scsi/ufs/Makefile        |   1 +
> >  drivers/scsi/ufs/ufshcd-crypto.c | 238 +++++++++++++++++++++++++++++++
> > drivers/scsi/ufs/ufshcd-crypto.h |  77 ++++++++++
> >  drivers/scsi/ufs/ufshcd.c        |  49 ++++++-
> >  drivers/scsi/ufs/ufshcd.h        |  24 ++++
> >  drivers/scsi/ufs/ufshci.h        |  67 ++++++++-
> >  7 files changed, 456 insertions(+), 9 deletions(-)  create mode 100644
> > drivers/scsi/ufs/ufshcd-crypto.c  create mode 100644 drivers/scsi/ufs/ufshcd-
> > crypto.h
> > 
> Looks Good to me.
> I don’t have a platform to test this series though.
> It will be good to get a Tested-by tags for this series.
> 
> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
> 

There's information about testing in the cover letter and commit messages
already.  But feel free to also add my Tested-by to all three patches:

Tested-by: Eric Biggers <ebiggers@google.com> # db845c

- Eric
Martin K. Petersen July 8, 2020, 6:06 a.m. UTC | #4
On Mon, 6 Jul 2020 20:04:11 +0000, Satya Tangirala wrote:

> This patch series adds support for inline encryption to UFS using
> the inline encryption support in the block layer. It follows the JEDEC
> UFSHCI v2.1 specification, which defines inline encryption for UFS.
> 
> This patch series previously went through a number of iterations as
> part of the "Inline Encryption Support" patchset (last version was v13:
> https://lkml.kernel.org/r/20200514003727.69001-1-satyat@google.com).
> This patch series is rebased on v5.8-rc4.
> 
> [...]

Applied to 5.9/scsi-queue, thanks!

[1/3] scsi: ufs: UFS driver v2.1 spec crypto additions
      https://git.kernel.org/mkp/scsi/c/5e7341e1f9ec
[2/3] scsi: ufs: UFS crypto API
      https://git.kernel.org/mkp/scsi/c/70297a8ac7a7
[3/3] scsi: ufs: Add inline encryption support to UFS
      https://git.kernel.org/mkp/scsi/c/df043c745ea1
Avri Altman July 8, 2020, 7:46 a.m. UTC | #5
> 
> On Mon, Jul 06, 2020 at 08:04:11PM +0000, Satya Tangirala wrote:
> > This patch series adds support for inline encryption to UFS using
> > the inline encryption support in the block layer. It follows the JEDEC
> > UFSHCI v2.1 specification, which defines inline encryption for UFS.
> >
> > This patch series previously went through a number of iterations as
> > part of the "Inline Encryption Support" patchset (last version was v13:
> > https://lkml.kernel.org/r/20200514003727.69001-1-satyat@google.com).
> > This patch series is rebased on v5.8-rc4.
> >
> > Patch 1 introduces the crypto registers and struct definitions defined
> > in the UFSHCI v2.1 spec.
> >
> > Patch 2 introduces functions to manipulate the UFS inline encryption
> > hardware (again in line with the UFSHCI v2.1 spec) via the block
> > layer keyslot manager. Device specific drivers must set the
> > UFSHCD_CAP_CRYPTO in hba->caps before ufshcd_hba_init_crypto is called
> > to opt-in to inline encryption support.
> 
> Note that it's now ufshcd_hba_init_crypto_capabilities(), not
> ufshcd_hba_init_crypto().
> 
> >
> > Patch 3 wires up ufshcd.c with the UFS crypto API introduced in Patch 2.
> >
> > This patch series has been tested on some Qualcomm chipsets (on the
> > db845c, sm8150-mtp and sm8250-mtp) using some additional patches at
> > https://lkml.kernel.org/linux-scsi/20200501045111.665881-1-
> ebiggers@kernel.org/
> > and on some Mediatek chipsets using the additional patch in
> > https://lkml.kernel.org/linux-scsi/20200304022101.14165-1-
> stanley.chu@mediatek.com/.
> > These additional patches are required because these chipsets need certain
> > additional behaviour not specified within the UFSHCI v2.1 spec.
> >
> > Thanks a lot to all the folks who tested this out!
> >
> > Changes v3 => v4:
> >  - fix incorrect patch folding
> >  - some cleanups from Eric
> >
> > Changes v2 => v3:
> >  - introduce ufshcd_prepare_req_desc_hdr_crypto to clean up code slightly
> >  - split up ufshcd_hba_init_crypto into ufshcd_hba_init_crypto_capabilities
> >    and ufshcd_init_crypto. The first function is called from
> >    ufshcd_hba_capabilities, and only reads crypto capabilities from device
> >    registers and sets up appropriate crypto structures. The second function
> >    is called from ufshcd_init, and actually initializes the inline crypto
> >    hardware.
> >
> > Changes v1 => v2
> >  - handle OCS_DEVICE_FATAL_ERROR explicitly in ufshcd_transfer_rsp_status
> >
> > Satya Tangirala (3):
> >   scsi: ufs: UFS driver v2.1 spec crypto additions
> >   scsi: ufs: UFS crypto API
> >   scsi: ufs: Add inline encryption support to UFS
> 
> These patches look good to me.  Avri and Alim, what do you think?
> We'd like these to be applied for 5.9.
Yes.  It looks good to me too.
I've added 2 nits to your 2nd patch - please feel free to ignore them.

Thanks,
Avri

> 
> - Eric