From a7b08a9c27b9877c3e88dcdca5eb1c24fe6746f0 Mon Sep 17 00:00:00 2001 From: Surajit Karmakar Date: Wed, 23 Apr 2025 23:34:06 +0530 Subject: [PATCH] Add support for passing keyslot usage to SE-Server This patch adds support for passing keyslot usage to SE-Server Bug 5236776 Change-Id: Iafa6ec15daff6f2acefad207e8b1939f656d7d3f Signed-off-by: Surajit Karmakar Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3348146 (cherry picked from commit f438b482a173bc745af46fe5b08f10a806b43a2f) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3361963 Reviewed-by: mobile promotions Tested-by: Sriharsha Allenki Reviewed-by: Vipin Kumar GVS: buildbot_gerritrpt Tested-by: mobile promotions Tested-by: Khushi . Reviewed-by: Leo Chiu --- drivers/crypto/tegra-hv-vse-safety.c | 2 ++ drivers/crypto/tegra-hv-vse.h | 1 + drivers/crypto/tegra-nvvse-cryptodev.c | 1 + include/uapi/misc/tegra-nvvse-cryptodev.h | 2 ++ 4 files changed, 6 insertions(+) diff --git a/drivers/crypto/tegra-hv-vse-safety.c b/drivers/crypto/tegra-hv-vse-safety.c index 202845ed..780185ba 100644 --- a/drivers/crypto/tegra-hv-vse-safety.c +++ b/drivers/crypto/tegra-hv-vse-safety.c @@ -396,6 +396,7 @@ struct tegra_virtual_se_addr64_buf_size { struct key_args { uint8_t keyslot[KEYSLOT_SIZE_BYTES]; + uint32_t key_usage; uint32_t key_instance; uint32_t key_grp_id; uint32_t token_id; @@ -1110,6 +1111,7 @@ int tegra_hv_vse_allocate_keyslot(struct tegra_vse_key_slot_ctx *key_slot, ivc_tx->cmd = TEGRA_VIRTUAL_SE_CMD_ALLOC_KEY; memcpy(ivc_tx->keys.keyslot, key_slot->key_id, KEYSLOT_SIZE_BYTES); + ivc_tx->keys.key_usage = key_slot->key_usage; ivc_tx->keys.key_grp_id = key_slot->key_grp_id; ivc_tx->keys.token_id = key_slot->token_id; g_crypto_to_ivc_map[node_id].vse_thread_start = true; diff --git a/drivers/crypto/tegra-hv-vse.h b/drivers/crypto/tegra-hv-vse.h index c34f7fb0..1e3b4a0f 100644 --- a/drivers/crypto/tegra-hv-vse.h +++ b/drivers/crypto/tegra-hv-vse.h @@ -48,6 +48,7 @@ struct tegra_vse_membuf_ctx { struct tegra_vse_key_slot_ctx { uint8_t key_id[KEYSLOT_SIZE_BYTES]; + uint8_t key_usage; uint8_t token_id; uint8_t key_instance_idx; uint32_t key_grp_id; diff --git a/drivers/crypto/tegra-nvvse-cryptodev.c b/drivers/crypto/tegra-nvvse-cryptodev.c index a97c4d25..e2b00b9b 100644 --- a/drivers/crypto/tegra-nvvse-cryptodev.c +++ b/drivers/crypto/tegra-nvvse-cryptodev.c @@ -215,6 +215,7 @@ static int tnvvse_crypto_allocate_key_slot(struct tnvvse_crypto_ctx *ctx, memset(&key_slot_params, 0, sizeof(key_slot_params)); memcpy(key_slot_params.key_id, key_slot_allocate_ctl->key_id, KEYSLOT_SIZE_BYTES); + key_slot_params.key_usage = key_slot_allocate_ctl->key_usage; key_slot_params.token_id = key_slot_allocate_ctl->token_id; key_slot_params.key_grp_id = ctx->key_grp_id; err = tegra_hv_vse_allocate_keyslot(&key_slot_params, ctx->node_id); diff --git a/include/uapi/misc/tegra-nvvse-cryptodev.h b/include/uapi/misc/tegra-nvvse-cryptodev.h index b78609ec..a71a12d7 100644 --- a/include/uapi/misc/tegra-nvvse-cryptodev.h +++ b/include/uapi/misc/tegra-nvvse-cryptodev.h @@ -127,6 +127,8 @@ enum tegra_nvvse_cmac_type { struct tegra_nvvse_allocate_key_slot_ctl { /** [in] Holds the key id */ uint8_t key_id[KEYSLOT_SIZE_BYTES]; + /** [in] Holds the key usage */ + uint8_t key_usage; /** [in] Holds the token id */ uint8_t token_id; /** [out] Holds the Key instance index */