[PATCH v4 10/15] ufs: host: wrapped keys support in ufs qcom

Gaurav Kashyap posted 15 patches 2 years ago
There is a newer version of this series
[PATCH v4 10/15] ufs: host: wrapped keys support in ufs qcom
Posted by Gaurav Kashyap 2 years ago
Use the wrapped keys quirk when hwkm is supported/used.
Whether to use HWKM or not would be decided during an ICE
probe, and based on this information, UFS can decide to use
wrapped keys or standard keys.

Also, propagate the appropriate key size to the ICE driver
when wrapped keys are used.

Signed-off-by: Gaurav Kashyap <quic_gaurkash@quicinc.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/ufs/host/ufs-qcom.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index acf352594362..5c9ba06438a9 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -123,6 +123,8 @@ static int ufs_qcom_ice_init(struct ufs_qcom_host *host)
 
 	host->ice = ice;
 	hba->caps |= UFSHCD_CAP_CRYPTO;
+	if (qcom_ice_hwkm_supported(host->ice))
+		hba->quirks |= UFSHCD_QUIRK_USES_WRAPPED_CRYPTO_KEYS;
 
 	return 0;
 }
@@ -160,7 +162,11 @@ static int ufs_qcom_ice_program_key(struct ufs_hba *hba,
 	    cap.key_size != UFS_CRYPTO_KEY_SIZE_256)
 		return -EOPNOTSUPP;
 
-	ice_key_size = QCOM_ICE_CRYPTO_KEY_SIZE_256;
+	if (bkey->crypto_cfg.key_type == BLK_CRYPTO_KEY_TYPE_HW_WRAPPED)
+		ice_key_size = QCOM_ICE_CRYPTO_KEY_SIZE_WRAPPED;
+	else
+		ice_key_size = QCOM_ICE_CRYPTO_KEY_SIZE_256;
+
 	if (config_enable)
 		return qcom_ice_program_key(host->ice,
 					    QCOM_ICE_CRYPTO_ALG_AES_XTS,
-- 
2.43.0
Re: [PATCH v4 10/15] ufs: host: wrapped keys support in ufs qcom
Posted by Om Prakash Singh 2 years ago

On 1/28/2024 4:44 AM, Gaurav Kashyap wrote:
> Use the wrapped keys quirk when hwkm is supported/used.
> Whether to use HWKM or not would be decided during an ICE
> probe, and based on this information, UFS can decide to use
> wrapped keys or standard keys.
> 
> Also, propagate the appropriate key size to the ICE driver
> when wrapped keys are used.
> 
> Signed-off-by: Gaurav Kashyap <quic_gaurkash@quicinc.com>
> Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
Reviewed-by: Om Prakash Singh <quic_omprsing@quicinc.com>
>   drivers/ufs/host/ufs-qcom.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index acf352594362..5c9ba06438a9 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -123,6 +123,8 @@ static int ufs_qcom_ice_init(struct ufs_qcom_host *host)
>   
>   	host->ice = ice;
>   	hba->caps |= UFSHCD_CAP_CRYPTO;
> +	if (qcom_ice_hwkm_supported(host->ice))
> +		hba->quirks |= UFSHCD_QUIRK_USES_WRAPPED_CRYPTO_KEYS;
>   
>   	return 0;
>   }
> @@ -160,7 +162,11 @@ static int ufs_qcom_ice_program_key(struct ufs_hba *hba,
>   	    cap.key_size != UFS_CRYPTO_KEY_SIZE_256)
>   		return -EOPNOTSUPP;
>   
> -	ice_key_size = QCOM_ICE_CRYPTO_KEY_SIZE_256;
> +	if (bkey->crypto_cfg.key_type == BLK_CRYPTO_KEY_TYPE_HW_WRAPPED)
> +		ice_key_size = QCOM_ICE_CRYPTO_KEY_SIZE_WRAPPED;
> +	else
> +		ice_key_size = QCOM_ICE_CRYPTO_KEY_SIZE_256;
> +
>   	if (config_enable)
>   		return qcom_ice_program_key(host->ice,
>   					    QCOM_ICE_CRYPTO_ALG_AES_XTS,