Loading drivers/soc/qcom/crypto-qti-tz.c +33 −5 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ /* * Crypto TZ library for storage encryption. * * Copyright (c) 2020, Linux Foundation. All rights reserved. * Copyright (c) 2020-2021, Linux Foundation. All rights reserved. */ #include <asm/cacheflush.h> Loading @@ -10,6 +10,7 @@ #include <linux/qtee_shmbridge.h> #include <linux/crypto-qti-common.h> #include <linux/module.h> #include <linux/of.h> #include "crypto-qti-platform.h" #define ICE_CIPHER_MODE_XTS_256 3 Loading @@ -17,6 +18,24 @@ #define SDCC_CE 20 #define UFS_CARD_CE 30 static bool is_boot_dev_type_emmc(void) { struct device_node *np; const char *bootparams; np = of_find_node_by_path("/chosen"); of_property_read_string(np, "bootargs", &bootparams); if (!bootparams) pr_err("%s: failed to get bootargs property\n", __func__); else if (strnstr(bootparams, "androidboot.bootdevice", strlen(bootparams)) && strnstr(bootparams, "sdhci", strlen(bootparams))) return true; return false; } int crypto_qti_program_key(struct crypto_vops_qti_entry *ice_entry, const struct blk_crypto_key *key, unsigned int slot, unsigned int data_unit_mask, int capid) Loading @@ -31,6 +50,11 @@ int crypto_qti_program_key(struct crypto_vops_qti_entry *ice_entry, memcpy(shm.vaddr, key->raw, key->size); qtee_shmbridge_flush_shm_buf(&shm); if (is_boot_dev_type_emmc()) err = qcom_scm_config_set_ice_key(slot, shm.paddr, key->size, ICE_CIPHER_MODE_XTS_256, data_unit_mask, SDCC_CE); else err = qcom_scm_config_set_ice_key(slot, shm.paddr, key->size, ICE_CIPHER_MODE_XTS_256, data_unit_mask, UFS_CE); Loading @@ -50,7 +74,11 @@ int crypto_qti_invalidate_key(struct crypto_vops_qti_entry *ice_entry, { int err = 0; if (is_boot_dev_type_emmc()) err = qcom_scm_clear_ice_key(slot, SDCC_CE); else err = qcom_scm_clear_ice_key(slot, UFS_CE); if (err) pr_err("%s:SCM call Error: 0x%x\n", __func__, err); Loading Loading
drivers/soc/qcom/crypto-qti-tz.c +33 −5 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ /* * Crypto TZ library for storage encryption. * * Copyright (c) 2020, Linux Foundation. All rights reserved. * Copyright (c) 2020-2021, Linux Foundation. All rights reserved. */ #include <asm/cacheflush.h> Loading @@ -10,6 +10,7 @@ #include <linux/qtee_shmbridge.h> #include <linux/crypto-qti-common.h> #include <linux/module.h> #include <linux/of.h> #include "crypto-qti-platform.h" #define ICE_CIPHER_MODE_XTS_256 3 Loading @@ -17,6 +18,24 @@ #define SDCC_CE 20 #define UFS_CARD_CE 30 static bool is_boot_dev_type_emmc(void) { struct device_node *np; const char *bootparams; np = of_find_node_by_path("/chosen"); of_property_read_string(np, "bootargs", &bootparams); if (!bootparams) pr_err("%s: failed to get bootargs property\n", __func__); else if (strnstr(bootparams, "androidboot.bootdevice", strlen(bootparams)) && strnstr(bootparams, "sdhci", strlen(bootparams))) return true; return false; } int crypto_qti_program_key(struct crypto_vops_qti_entry *ice_entry, const struct blk_crypto_key *key, unsigned int slot, unsigned int data_unit_mask, int capid) Loading @@ -31,6 +50,11 @@ int crypto_qti_program_key(struct crypto_vops_qti_entry *ice_entry, memcpy(shm.vaddr, key->raw, key->size); qtee_shmbridge_flush_shm_buf(&shm); if (is_boot_dev_type_emmc()) err = qcom_scm_config_set_ice_key(slot, shm.paddr, key->size, ICE_CIPHER_MODE_XTS_256, data_unit_mask, SDCC_CE); else err = qcom_scm_config_set_ice_key(slot, shm.paddr, key->size, ICE_CIPHER_MODE_XTS_256, data_unit_mask, UFS_CE); Loading @@ -50,7 +74,11 @@ int crypto_qti_invalidate_key(struct crypto_vops_qti_entry *ice_entry, { int err = 0; if (is_boot_dev_type_emmc()) err = qcom_scm_clear_ice_key(slot, SDCC_CE); else err = qcom_scm_clear_ice_key(slot, UFS_CE); if (err) pr_err("%s:SCM call Error: 0x%x\n", __func__, err); Loading