* [PATCH] mmc: core: crypto: Add MMC_CAP2_CRYPTO_RETAIN_KEY
@ 2023-08-21 6:50 Om Prakash Singh
2023-08-22 4:50 ` Eric Biggers
0 siblings, 1 reply; 3+ messages in thread
From: Om Prakash Singh @ 2023-08-21 6:50 UTC (permalink / raw)
To: ebiggers, andersson
Cc: linux-mmc, satyaprateek2357, ulf.hansson, agross, adrian.hunter,
quic_omprsing, linux-arm-msm
Add new capability MMC_CAP2_CRYPTO_RETAIN_KEY for mmc host that
support inline crypto key retention and doesn't need reinitialization
of all keys after mmc host has reinitialized.
Signed-off-by: Om Prakash Singh <quic_omprsing@quicinc.com>
---
drivers/mmc/core/crypto.c | 3 ++-
drivers/mmc/host/sdhci-msm.c | 1 +
include/linux/mmc/host.h | 2 ++
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/core/crypto.c b/drivers/mmc/core/crypto.c
index fec4fbf16a5b..f8ce7c2295f6 100644
--- a/drivers/mmc/core/crypto.c
+++ b/drivers/mmc/core/crypto.c
@@ -15,7 +15,8 @@
void mmc_crypto_set_initial_state(struct mmc_host *host)
{
/* Reset might clear all keys, so reprogram all the keys. */
- if (host->caps2 & MMC_CAP2_CRYPTO)
+ if ((host->caps2 & MMC_CAP2_CRYPTO) &&
+ !(host->caps2 & MMC_CAP2_CRYPTO_RETAIN_KEY))
blk_crypto_reprogram_all_keys(&host->crypto_profile);
}
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 1c935b5bafe1..cfc2328f90ed 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -1828,6 +1828,7 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host,
msm_host->ice = ice;
mmc->caps2 |= MMC_CAP2_CRYPTO;
+ mmc->caps2 |= MMC_CAP2_CRYPTO_RETAIN_KEY;
return 0;
}
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 461d1543893b..74c69415746d 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -417,8 +417,10 @@ struct mmc_host {
#define MMC_CAP2_MERGE_CAPABLE (1 << 26) /* Host can merge a segment over the segment size */
#ifdef CONFIG_MMC_CRYPTO
#define MMC_CAP2_CRYPTO (1 << 27) /* Host supports inline encryption */
+#define MMC_CAP2_CRYPTO_RETAIN_KEY (1 << 28) /* Host doesn't need inline encryption key reinitialization */
#else
#define MMC_CAP2_CRYPTO 0
+#define MMC_CAP2_CRYPTO_RETAIN_KEY 0
#endif
#define MMC_CAP2_ALT_GPT_TEGRA (1 << 28) /* Host with eMMC that has GPT entry at a non-standard location */
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mmc: core: crypto: Add MMC_CAP2_CRYPTO_RETAIN_KEY
2023-08-21 6:50 [PATCH] mmc: core: crypto: Add MMC_CAP2_CRYPTO_RETAIN_KEY Om Prakash Singh
@ 2023-08-22 4:50 ` Eric Biggers
2023-08-23 3:56 ` Om Prakash Singh
0 siblings, 1 reply; 3+ messages in thread
From: Eric Biggers @ 2023-08-22 4:50 UTC (permalink / raw)
To: Om Prakash Singh
Cc: andersson, linux-mmc, satyaprateek2357, ulf.hansson, agross,
adrian.hunter, linux-arm-msm
On Mon, Aug 21, 2023 at 12:20:37PM +0530, Om Prakash Singh wrote:
> Add new capability MMC_CAP2_CRYPTO_RETAIN_KEY for mmc host that
> support inline crypto key retention and doesn't need reinitialization
> of all keys after mmc host has reinitialized.
MMC_CAP2_RETAINS_CRYPTO_KEYS would be a better name.
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index 1c935b5bafe1..cfc2328f90ed 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -1828,6 +1828,7 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host,
>
> msm_host->ice = ice;
> mmc->caps2 |= MMC_CAP2_CRYPTO;
> + mmc->caps2 |= MMC_CAP2_CRYPTO_RETAIN_KEY;
>
> return 0;
> }
Are you sure that *all* versions of Qualcomm's eMMC inline encryption hardware
have this behavior?
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> index 461d1543893b..74c69415746d 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -417,8 +417,10 @@ struct mmc_host {
> #define MMC_CAP2_MERGE_CAPABLE (1 << 26) /* Host can merge a segment over the segment size */
> #ifdef CONFIG_MMC_CRYPTO
> #define MMC_CAP2_CRYPTO (1 << 27) /* Host supports inline encryption */
> +#define MMC_CAP2_CRYPTO_RETAIN_KEY (1 << 28) /* Host doesn't need inline encryption key reinitialization */
How about:
/* Host retains inline encryption keys on reset */
> #else
> #define MMC_CAP2_CRYPTO 0
> +#define MMC_CAP2_CRYPTO_RETAIN_KEY 0
> #endif
> #define MMC_CAP2_ALT_GPT_TEGRA (1 << 28) /* Host with eMMC that has GPT entry at a non-standard location */
'1 << 28' is already used.
Also, the new flag doesn't need to be in the #ifdef section.
- Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mmc: core: crypto: Add MMC_CAP2_CRYPTO_RETAIN_KEY
2023-08-22 4:50 ` Eric Biggers
@ 2023-08-23 3:56 ` Om Prakash Singh
0 siblings, 0 replies; 3+ messages in thread
From: Om Prakash Singh @ 2023-08-23 3:56 UTC (permalink / raw)
To: Eric Biggers
Cc: andersson, linux-mmc, satyaprateek2357, ulf.hansson, agross,
adrian.hunter, linux-arm-msm
On 8/22/2023 10:20 AM, Eric Biggers wrote:
> On Mon, Aug 21, 2023 at 12:20:37PM +0530, Om Prakash Singh wrote:
>> Add new capability MMC_CAP2_CRYPTO_RETAIN_KEY for mmc host that
>> support inline crypto key retention and doesn't need reinitialization
>> of all keys after mmc host has reinitialized.
>
> MMC_CAP2_RETAINS_CRYPTO_KEYS would be a better name.
I will update in next version
>
>> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
>> index 1c935b5bafe1..cfc2328f90ed 100644
>> --- a/drivers/mmc/host/sdhci-msm.c
>> +++ b/drivers/mmc/host/sdhci-msm.c
>> @@ -1828,6 +1828,7 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host,
>>
>> msm_host->ice = ice;
>> mmc->caps2 |= MMC_CAP2_CRYPTO;
>> + mmc->caps2 |= MMC_CAP2_CRYPTO_RETAIN_KEY;
>>
>> return 0;
>> }
>
> Are you sure that *all* versions of Qualcomm's eMMC inline encryption hardware
> have this behavior?
Thanks for pointing this out. I am not sure and checking internally for
more information.
>
>> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
>> index 461d1543893b..74c69415746d 100644
>> --- a/include/linux/mmc/host.h
>> +++ b/include/linux/mmc/host.h
>> @@ -417,8 +417,10 @@ struct mmc_host {
>> #define MMC_CAP2_MERGE_CAPABLE (1 << 26) /* Host can merge a segment over the segment size */
>> #ifdef CONFIG_MMC_CRYPTO
>> #define MMC_CAP2_CRYPTO (1 << 27) /* Host supports inline encryption */
>> +#define MMC_CAP2_CRYPTO_RETAIN_KEY (1 << 28) /* Host doesn't need inline encryption key reinitialization */
>
> How about:
>
> /* Host retains inline encryption keys on reset */
>
I will update in next version
>> #else
>> #define MMC_CAP2_CRYPTO 0
>> +#define MMC_CAP2_CRYPTO_RETAIN_KEY 0
>> #endif
>> #define MMC_CAP2_ALT_GPT_TEGRA (1 << 28) /* Host with eMMC that has GPT entry at a non-standard location */
>
> '1 << 28' is already used.
ack
> Also, the new flag doesn't need to be in the #ifdef section.
>
> - Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-23 3:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-21 6:50 [PATCH] mmc: core: crypto: Add MMC_CAP2_CRYPTO_RETAIN_KEY Om Prakash Singh
2023-08-22 4:50 ` Eric Biggers
2023-08-23 3:56 ` Om Prakash Singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox