Skip to contentSkip to conversation

Inline Encryption support for UFS

PATCH Superseded Satya Tangirala 6 participants 16 messages Jun 18, 2020 – Jun 23, 2020 SCSI

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover 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/[email protected]).
There aren't any significant changes here from that version. This patch series is based on v5.8-rc1.

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/[email protected]/
and on some Mediatek chipsets using the additional patch in
https://lkml.kernel.org/linux-scsi/[email protected]/.
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 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 | 226 +++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshcd-crypto.h |  60 ++++++++
 drivers/scsi/ufs/ufshcd.c        |  47 ++++++-
 drivers/scsi/ufs/ufshcd.h        |  24 ++++
 drivers/scsi/ufs/ufshci.h        |  67 ++++++++-
 7 files changed, 427 insertions(+), 7 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-crypto.c
 create mode 100644 drivers/scsi/ufs/ufshcd-crypto.h
Signature · 1 line
2.27.0.290.gba653c62da-goog
#1 lore raw

PATCH v2 1/3 scsi: ufs: UFS driver v2.1 spec crypto additions

Add the crypto registers and structs defined in v2.1 of the JEDEC UFSHCI specification in preparation to add support for inline encryption to UFS.

---
 drivers/scsi/ufs/ufshcd.c |  3 ++
 drivers/scsi/ufs/ufshcd.h |  6 ++++
 drivers/scsi/ufs/ufshci.h | 67 +++++++++++++++++++++++++++++++++++++--
 3 files changed, 74 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +3 -0
index ad4fc829cbb2..4fdb200de46c 100644
@@ -4792,6 +4792,9 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 	case OCS_MISMATCH_RESP_UPIU_SIZE:
 	case OCS_PEER_COMM_FAILURE:
 	case OCS_FATAL_ERROR:
+	case OCS_DEVICE_FATAL_ERROR:
+	case OCS_INVALID_CRYPTO_CONFIG:
+	case OCS_GENERAL_CRYPTO_ERROR:
 	default:
 		result |= DID_ERROR << 16;
 		dev_err(hba->dev,
drivers/scsi/ufs/ufshcd.h +6 -0
index bf97d616e597..b4981f1c37a2 100644
@@ -564,6 +564,12 @@ enum ufshcd_caps {
 	 * provisioned to be used. This would increase the write performance.
 	 */
 	UFSHCD_CAP_WB_EN				= 1 << 7,
+
+	/*
+	 * This capability allows the host controller driver to use the
+	 * inline crypto engine, if it is present
+	 */
+	UFSHCD_CAP_CRYPTO				= 1 << 8,
 };
 
 struct ufs_hba_variant_params {
drivers/scsi/ufs/ufshci.h +65 -2

106 lines not on this page · raw message

Signature · 1 line
2.27.0.290.gba653c62da-goog
#2 lore raw

PATCH v2 2/3 scsi: ufs: UFS crypto API

In reply to Satya Tangirala

Introduce functions to manipulate UFS inline encryption hardware in line with the JEDEC UFSHCI v2.1 specification and to work with the block keyslot manager.

The UFS crypto API will assume by default that a vendor driver doesn't support UFS crypto, even if the hardware advertises the capability, because a lot of hardware requires some special handling that's not specified in the aforementioned JEDEC spec. Each vendor driver must explicitly set hba->caps |= UFSHCD_CAP_CRYPTO before ufshcd_hba_init_crypto is called to opt-in to UFS crypto support.

---
 drivers/scsi/ufs/Kconfig         |   9 ++
 drivers/scsi/ufs/Makefile        |   1 +
 drivers/scsi/ufs/ufshcd-crypto.c | 226 +++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshcd-crypto.h |  42 ++++++
 drivers/scsi/ufs/ufshcd.h        |  12 ++
 5 files changed, 290 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-crypto.c
 create mode 100644 drivers/scsi/ufs/ufshcd-crypto.h
drivers/scsi/ufs/Kconfig +9 -0
index d35378be89e8..4c0a9661049a 100644
@@ -160,3 +160,12 @@ config SCSI_UFS_BSG
 
 	  Select this if you need a bsg device node for your UFS controller.
 	  If unsure, say N.
+
+config SCSI_UFS_CRYPTO
+	bool "UFS Crypto Engine Support"
+	depends on SCSI_UFSHCD && BLK_INLINE_ENCRYPTION
+	help
+	  Enable Crypto Engine Support in UFS.
+	  Enabling this makes it possible for the kernel to use the crypto
+	  capabilities of the UFS device (if present) to perform crypto
+	  operations on data being transferred to/from the device.
drivers/scsi/ufs/Makefile +1 -0
index 94c6c5d7334b..197e178f44bc 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o
 ufshcd-core-y				+= ufshcd.o ufs-sysfs.o
 ufshcd-core-$(CONFIG_SCSI_UFS_BSG)	+= ufs_bsg.o
+ufshcd-core-$(CONFIG_SCSI_UFS_CRYPTO) += ufshcd-crypto.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
 obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o
drivers/scsi/ufs/ufshcd-crypto.c new file +226 -0

226 lines not on this page · raw message

drivers/scsi/ufs/ufshcd-crypto.h new file +42 -0

42 lines not on this page · raw message

drivers/scsi/ufs/ufshcd.h +12 -0
index b4981f1c37a2..271fc19f8002 100644
@@ -57,6 +57,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/bitfield.h>
 #include <linux/devfreq.h>
+#include <linux/keyslot-manager.h>
 #include "unipro.h"
 
 #include <asm/irq.h>
@@ -630,6 +631,10 @@ struct ufs_hba_variant_params {
  * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for
  *  device is known or not.
  * @scsi_block_reqs_cnt: reference counting for scsi block requests
+ * @crypto_capabilities: Content of crypto capabilities register (0x100)
+ * @crypto_cap_array: Array of crypto capabilities
+ * @crypto_cfg_register: Start of the crypto cfg array
+ * @ksm: the keyslot manager tied to this hba
  */
 struct ufs_hba {
 	void __iomem *mmio_base;
@@ -752,6 +757,13 @@ struct ufs_hba {
 	bool wb_buf_flush_enabled;
 	bool wb_enabled;
 	struct delayed_work rpm_dev_flush_recheck_work;
+
+#ifdef CONFIG_SCSI_UFS_CRYPTO
+	union ufs_crypto_capabilities crypto_capabilities;
+	union ufs_crypto_cap_entry *crypto_cap_array;
+	u32 crypto_cfg_register;
+	struct blk_keyslot_manager ksm;
+#endif
 };
 
 /* Returns true if clocks can be gated. Otherwise false */
Signature · 1 line
2.27.0.290.gba653c62da-goog
#3 lore raw

PATCH v2 3/3 scsi: ufs: Add inline encryption support to UFS

In reply to Satya Tangirala

Wire up ufshcd.c with the UFS Crypto API, the block layer inline encryption additions and the keyslot manager.

Many existing inline crypto devices require some additional behaviour not specified in the UFSHCI v2.1 specification - as such the vendor specific drivers will need to be updated where necessary to make it possible to use those devices. Some of these changes have already been proposed upstream, such as for the Qualcomm 845 SoC at
https://lkml.kernel.org/linux-scsi/[email protected]/
and for ufs-mediatek at
https://lkml.kernel.org/linux-scsi/[email protected]/

This patch has been tested on the db845c, sm8150-mtp and sm8250-mtp (which have Qualcomm chipsets) and on some mediatek chipsets using these aforementioned vendor specific driver updates.

---
 drivers/scsi/ufs/ufshcd-crypto.h | 18 +++++++++++++
 drivers/scsi/ufs/ufshcd.c        | 44 ++++++++++++++++++++++++++++----
 drivers/scsi/ufs/ufshcd.h        |  6 +++++
 3 files changed, 63 insertions(+), 5 deletions(-)
drivers/scsi/ufs/ufshcd-crypto.h +18 -0
index 22677619de59..9578edb63e7b 100644
@@ -10,6 +10,20 @@
 #include "ufshcd.h"
 #include "ufshci.h"
 
+static inline void ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba,
+					      struct scsi_cmnd *cmd,
+					      struct ufshcd_lrb *lrbp)
+{
+	struct request *rq = cmd->request;
+
+	if (rq->crypt_keyslot) {
+		lrbp->crypto_key_slot = blk_ksm_get_slot_idx(rq->crypt_keyslot);
+		lrbp->data_unit_num = rq->crypt_ctx->bc_dun[0];
+	} else {
+		lrbp->crypto_key_slot = -1;
+	}
+}
+
 bool ufshcd_crypto_enable(struct ufs_hba *hba);
 
 int ufshcd_hba_init_crypto(struct ufs_hba *hba);
@@ -21,6 +35,10 @@ void ufshcd_crypto_destroy_keyslot_manager(struct ufs_hba *hba);
 
 #else /* CONFIG_SCSI_UFS_CRYPTO */
 
+static inline void ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba,
+					      struct scsi_cmnd *cmd,
+					      struct ufshcd_lrb *lrbp) { }
+
 static inline bool ufshcd_crypto_enable(struct ufs_hba *hba)
 {
 	return false;
drivers/scsi/ufs/ufshcd.c +39 -5

111 lines not on this page · raw message

drivers/scsi/ufs/ufshcd.h +6 -0
index 271fc19f8002..1cb0fde5772c 100644
@@ -184,6 +184,8 @@ struct ufs_pm_lvl_states {
  * @intr_cmd: Interrupt command (doesn't participate in interrupt aggregation)
  * @issue_time_stamp: time stamp for debug purposes
  * @compl_time_stamp: time stamp for statistics
+ * @crypto_key_slot: the key slot to use for inline crypto (-1 if none)
+ * @data_unit_num: the data unit number for the first block for inline crypto
  * @req_abort_skip: skip request abort task flag
  */
 struct ufshcd_lrb {
@@ -208,6 +210,10 @@ struct ufshcd_lrb {
 	bool intr_cmd;
 	ktime_t issue_time_stamp;
 	ktime_t compl_time_stamp;
+#ifdef CONFIG_SCSI_UFS_CRYPTO
+	int crypto_key_slot;
+	u64 data_unit_num;
+#endif
 
 	bool req_abort_skip;
 };
Signature · 1 line
2.27.0.290.gba653c62da-goog
#4 lore raw

Re: [PATCH v2 3/3] scsi: ufs: Add inline encryption support to UFS

Hi Satya

Quoted 3 lines · Satya Tangirala

Wire up ufshcd.c with the UFS Crypto API, the block layer inline encryption additions and the keyslot manager.

PORT_SYMBOL_GPL(ufshcd_dealloc_host);

drivers/scsi/ufs/ufshcd.c int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) · line 8903

Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +2 -0
@@ -8872,6 +8899,13 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
        /* Reset the attached device */
        ufshcd_vops_device_reset(hba);
 
+       /* Init crypto */
+       err = ufshcd_hba_init_crypto(hba);

How about checking the capabilities of host controller in ufshcd_hba_capabilities() itself and then proceed?

Quoted 35 lines
drivers/scsi/ufs/ufshcd.c +5 -0
+       if (err) {
+               dev_err(hba->dev, "crypto setup failed\n");
+               goto free_tmf_queue;
+       }
+
        /* Host controller enable */
        err = ufshcd_hba_enable(hba);
        if (err) {
drivers/scsi/ufs/ufshcd.h +6 -1
index 271fc19f8002..1cb0fde5772c 100644
@@ -184,6 +184,8 @@ struct ufs_pm_lvl_states {
  * @intr_cmd: Interrupt command (doesn't participate in interrupt aggregation)
  * @issue_time_stamp: time stamp for debug purposes
  * @compl_time_stamp: time stamp for statistics
+ * @crypto_key_slot: the key slot to use for inline crypto (-1 if none)
+ * @data_unit_num: the data unit number for the first block for inline crypto
  * @req_abort_skip: skip request abort task flag
  */
 struct ufshcd_lrb {
@@ -208,6 +210,10 @@ struct ufshcd_lrb {
        bool intr_cmd;
        ktime_t issue_time_stamp;
        ktime_t compl_time_stamp;
+#ifdef CONFIG_SCSI_UFS_CRYPTO
+       int crypto_key_slot;
+       u64 data_unit_num;
+#endif
 
        bool req_abort_skip;
 };
--

2.27.0.290.gba653c62da-goog

Signature · 2 lines
Regards,
Alim
#5 lore raw
In reply to Satya Tangirala

Avri,

Quoted 3 lines

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.

I'd appreciate it if you could review this series.

Thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#6 lore raw
Quoted 7 lines

Avri,

Quoted 3 lines

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.

I'd appreciate it if you could review this series.

I need help doing it. I will ask around.
Thanks,
Avri

#7 lore raw
In reply to Martin K. Petersen

+Alim & Asutosh

Hi Satya,

Quoted 7 lines

Avri,

Quoted 3 lines

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.

Quoted 6 lines

I'd appreciate it if you could review this series.

Thanks!

--
Martin K. Petersen Oracle Linux Engineering

A quick question and a comment:

Does the IE infrastructure that you've added to the block layer invented for ufs? Do you see other devices using it in the future?

Today, chipset vendors are using a different scheme for their IE. Need their ack before reviewing your patches.

Thanks,
Avri

#8 lore raw
Quoted 14 lines

+Alim & Asutosh

Hi Satya,

Quoted 9 lines

Avri,

Quoted 3 lines

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.

I'd appreciate it if you could review this series.

Quoted 8 lines
Quoted 4 lines

Thanks!

--
Martin K. Petersen Oracle Linux Engineering

A quick question and a comment:

Does the IE infrastructure that you've added to the block layer invented for ufs?

And how this infrastructure relates to Eric's RFC: Inline crypto support on DragonBoard 845c
https://www.spinics.net/lists/linux-scsi/msg141472.html

Quoted 7 lines

Do you see other devices using it in the future?

Today, chipset vendors are using a different scheme for their IE. Need their ack before reviewing your patches.

Thanks,
Avri

#9 lore raw
Quoted 16 lines · Avri Altman
Quoted 16 lines

+Alim & Asutosh

Hi Satya,

Quoted 11 lines

Avri,

Quoted 3 lines

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.

I'd appreciate it if you could review this series.

Thanks!

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

--
Martin K. Petersen Oracle Linux Engineering

A quick question and a comment:

Does the IE infrastructure that you've added to the block layer invented for ufs?

And how this infrastructure relates to Eric's RFC: Inline crypto support on DragonBoard 845c
https://www.spinics.net/lists/linux-scsi/msg141472.html

My patches are based on top of Satya's patches. My patches just introduce the quirks needed for Qualcomm ICE to work, since it doesn't follow the UFS standard exactly.

- Eric

#10 lore raw
In reply to Avri Altman

Thanks Avri for CCing me.

Quoted 10 lines

-----Original Message-----
From: Avri Altman <[email protected]>
Sent: 21 June 2020 18:05
To: Martin K. Petersen <[email protected]>; Satya Tangirala <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Barani Muthukumaran <[email protected]>; Kuohong Wang <[email protected]>; Kim Boojin <[email protected]>
Subject: RE: [PATCH v2 0/3] Inline Encryption support for UFS

Quoted 10 lines

+Alim & Asutosh

Hi Satya,

Quoted 6 lines

Avri,

Quoted 3 lines

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.

Quoted 10 lines
Quoted 7 lines

I'd appreciate it if you could review this series.

Thanks!

--
Martin K. Petersen Oracle Linux Engineering

A quick question and a comment:

Does the IE infrastructure that you've added to the block layer invented

for ufs?

Quoted 5 lines

Do you see other devices using it in the future?

Today, chipset vendors are using a different scheme for their IE. Need their ack before reviewing your patches.

Yes, as of today at least in Samsung HCI, we use additional HW blocks to handle all the crypto part.
(Though I need to check the status on the recent SoCs). However given the fact that UFSHCI 2.1 spec does includes Crypto support, and going by threads that you shared, looks like other Vendors does uses IE. I am inclined toward getting this reviewed.

Quoted 2 lines

Thanks,
Avri

#11 lore raw
Quoted 39 lines · Alim Akhtar

Thanks Avri for CCing me.

Quoted 10 lines

-----Original Message-----
From: Avri Altman <[email protected]>
Sent: 21 June 2020 18:05
To: Martin K. Petersen <[email protected]>; Satya Tangirala <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Barani Muthukumaran <[email protected]>; Kuohong Wang <[email protected]>; Kim Boojin <[email protected]>
Subject: RE: [PATCH v2 0/3] Inline Encryption support for UFS

Quoted 10 lines

+Alim & Asutosh

Hi Satya,

Quoted 6 lines

Avri,

Quoted 3 lines

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.

Quoted 10 lines
Quoted 7 lines

I'd appreciate it if you could review this series.

Thanks!

--
Martin K. Petersen Oracle Linux Engineering

A quick question and a comment:

Does the IE infrastructure that you've added to the block layer invented

for ufs?

Quoted 5 lines

Do you see other devices using it in the future?

Today, chipset vendors are using a different scheme for their IE. Need their ack before reviewing your patches.

Quoted 6 lines

Yes, as of today at least in Samsung HCI, we use additional HW blocks to handle all the crypto part.
(Though I need to check the status on the recent SoCs). However given the fact that UFSHCI 2.1 spec does includes Crypto support, and going by threads that you shared, looks like other Vendors does uses IE. I am inclined toward getting this reviewed.

Note that Boojin Kim, who has been Cc'ed on all these patches, has already been working on replacing Samsung's legacy inline encryption implementation with one using the new framework.

Unfortunately, Samsung's UFS inline encryption hardware doesn't follow the UFS specification, so it needs custom driver code and doesn't take much advantage of ufshcd-crypto (this patchset). However, it can still use the blk-crypto framework. So only the driver needs to differ, not the rest of the storage stack. This differs from the "old world" where every vendor had to customize the entire storage stack to support their inline encryption hardware.

Anyway, ufshcd-crypto (this patchset) is still needed for all vendors who did mostly/fully follow the UFS specification, e.g. Mediatek
(https://lkml.kernel.org/linux-scsi/[email protected])
and Qualcomm
(https://lkml.kernel.org/linux-scsi/[email protected]).

More reviews are always appreciated, though note that this patchset has already been out for review for over a year. (This is really v15; Satya started the numbering over after blk-crypto was merged in v5.8-rc1.) So I'm not sure we should count on many more formal reviews.

- Eric

#12 lore raw
Quoted 39 lines
Quoted 9 lines
Quoted 3 lines

A quick question and a comment:

Does the IE infrastructure that you've added to the block layer invented

for ufs?

Quoted 5 lines

Do you see other devices using it in the future?

Today, chipset vendors are using a different scheme for their IE. Need their ack before reviewing your patches.

Quoted 6 lines

Yes, as of today at least in Samsung HCI, we use additional HW blocks to handle all the crypto part.
(Though I need to check the status on the recent SoCs). However given the fact that UFSHCI 2.1 spec does includes Crypto support, and going by threads that you shared, looks like other Vendors does uses IE. I am inclined toward getting this reviewed.

Note that Boojin Kim, who has been Cc'ed on all these patches, has already been
working on replacing Samsung's legacy inline encryption implementation with one
using the new framework.

Unfortunately, Samsung's UFS inline encryption hardware doesn't follow the UFS
specification, so it needs custom driver code and doesn't take much advantage of
ufshcd-crypto (this patchset). However, it can still use the blk-crypto framework. So only the driver needs to differ, not the rest of the storage stack. This differs from the "old world" where every vendor had to customize the entire storage stack to support their inline encryption hardware.

Anyway, ufshcd-crypto (this patchset) is still needed for all vendors who did mostly/fully follow the UFS specification, e.g. Mediatek
(https://lkml.kernel.org/linux-scsi/20200304022101.14165-1-
[email protected])
and Qualcomm
(https://lkml.kernel.org/linux-scsi/20200621173713.132879-1-
[email protected]).

Quoted 5 lines

More reviews are always appreciated, though note that this patchset has already
been out for review for over a year. (This is really v15; Satya started the numbering over after blk-crypto was merged in v5.8-rc1.) So I'm not sure we should count on many more formal reviews.

Ok then.
This works as a practical ack by most of the large chipset vendors.

Thanks,
Avri

#13 lore raw
In reply to Avri Altman
Quoted 13 lines · Avri Altman

+Alim & Asutosh

Hi Satya,

Quoted 9 lines

Avri,

Quoted 3 lines

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.

I'd appreciate it if you could review this series.

Quoted 7 lines
Quoted 4 lines

Thanks!

--
Martin K. Petersen Oracle Linux Engineering

A quick question and a comment:

Does the IE infrastructure that you've added to the block layer invented for ufs?

It wasn't invented "just" for UFS, but it was guided by how UFS inline crypto works. It is meant to be generic, and should be how we support any arbitrary IE hardware in the kernel.

Quoted 2 lines

Do you see other devices using it in the future?

Certainly - at the very least, I think it's likely we'll add support for eMMC inline crypto (although inline encryption support for eMMC was only added in an unreleased/yet to be released spec). It's certainly my hope that we add IE support for other classes of devices too.

Quoted 3 lines

Today, chipset vendors are using a different scheme for their IE. Need their ack before reviewing your patches.

Sure :). The Inline Encryption patches (the block layer, fscrypt, f2fs, ext4 and these UFS patches) have been part of the Android common kernel
https://android.googlesource.com/kernel/common/
for quite a while now, and chipset vendors have been working with us on ensuring that their UFS cards are supported by these patches (by adding code similar to Eric's RFC: Inline crypto support on DragonBoard 845c at
https://www.spinics.net/lists/linux-scsi/msg141472.html
or Mediatek's "scsi: ufs-mediatek: add inline encryption support" at
https://lkml.kernel.org/linux-scsi/[email protected]/
for their individual chipsets).

Quoted 2 lines

Thanks,
Avri

#14 lore raw
Quoted 4 lines · Satya Tangirala
Quoted 4 lines

Today, chipset vendors are using a different scheme for their IE. Need their ack before reviewing your patches.

Quoted 10 lines

Sure :). The Inline Encryption patches (the block layer, fscrypt, f2fs, ext4 and these UFS patches) have been part of the Android common kernel
https://android.googlesource.com/kernel/common/
for quite a while now, and chipset vendors have been working with us on ensuring that their UFS cards are supported by these patches (by adding code similar to Eric's RFC: Inline crypto support on DragonBoard 845c at
https://www.spinics.net/lists/linux-scsi/msg141472.html
or Mediatek's "scsi: ufs-mediatek: add inline encryption support" at
https://lkml.kernel.org/linux-scsi/[email protected]/
for their individual chipsets).

Just as a practical matter, I don't think this patchset should be blocked waiting for a formal Acked-by from every vendor, as some of them don't to be participating in LKML at all despite being Cc'ed on these patches for a year and working with us outside LKML to support their hardware using the new framework. So I think a formal Acked-by on LKML is not always guaranteed. (It would certainly be preferable if everyone would participate though!)

- Eric

#15 lore raw

Re: [PATCH v2 3/3] scsi: ufs: Add inline encryption support to UFS

In reply to Satya Tangirala
Quoted 1 line

ufshcd_prepare_req_desc_hdr

maybe pack all your additions to ufshcd_prepare_req_desc_hdr into a ufshcd_prepare_req_desc_hdr_crypto helper, so the ifdefs can be avoided?

Quoted 1 line

ufshcd_compose_dev_cmd

same goes to ufshcd_compose_dev_cmd and ufshcd_issue_devman_upiu_cmd - maybe just call ufshcd_prepare_lrbp_crypto (with some minor changes) instead of those ifdefs?