-
Notifications
You must be signed in to change notification settings - Fork 30
pta: qcom: ice: add software-key ICE PTA #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Harikrishna (thariaruchamy-bit)
wants to merge
2
commits into
qualcomm-linux:qcom-next
Choose a base branch
from
thariaruchamy-bit:drivers-qcom-ice
base: qcom-next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* SPDX-License-Identifier: BSD-2-Clause */ | ||
| /* | ||
| * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| */ | ||
|
|
||
| #ifndef __ICE_CONFIG_H | ||
| #define __ICE_CONFIG_H | ||
|
|
||
| #include <platform_config.h> | ||
| #include <stdint.h> | ||
|
|
||
| #define ICE_MAX_KEY_IDX 32 | ||
|
thariaruchamy-bit marked this conversation as resolved.
|
||
| #define ICE_CRYPTOCFG_DATA_REGS 16 | ||
|
|
||
| /* Key sizes in bytes */ | ||
| #define ICE_AES128_KEY_SIZE 16 | ||
| #define ICE_AES256_KEY_SIZE 32 | ||
|
|
||
| /* ICE key register layout within a slot: | ||
| * n = 0..7 : DATA key (32 bytes, 8 x 4-byte registers) | ||
| * n = 8..15 : SALT key (32 bytes, 8 x 4-byte registers) | ||
| */ | ||
| #define ICE_KEY_REG_SIZE 32 | ||
| #define ICE_KEY_DATA_REG_START 0 | ||
| #define ICE_KEY_SALT_REG_START 8 | ||
|
|
||
| /* | ||
| * ICE LUT-keys register offsets from the LUT-keys base, common to eMMC/SDCC | ||
| * and UFS. The field masks are used with io_write32_off_field(), which derives | ||
| * the shift from the mask. | ||
| */ | ||
| #define ICE_CRYPTOCFG_r_n_OFF(r, n) \ | ||
| (0x0 + (0x80 * (r)) + (0x4 * (n))) | ||
| #define ICE_CRYPTOCFG_r_16_OFF(r) \ | ||
| (0x40 + (0x80 * (r))) | ||
| #define ICE_CRYPTOCFG_r_16_CFGE_BMSK 0x80000000 | ||
| #define ICE_CRYPTOCFG_r_16_CAPIDX_BMSK 0xff00 | ||
| #define ICE_CRYPTOCFG_r_16_DUSIZE_BMSK 0xff | ||
|
|
||
| enum ice_capability_index_type { | ||
| ICE_CIPHER_MODE_XTS_128 = 0x0, | ||
| ICE_CIPHER_MODE_CBC_128 = 0x1, | ||
| ICE_CIPHER_MODE_ECB_128 = 0x2, | ||
| ICE_CIPHER_MODE_XTS_256 = 0x3, | ||
| ICE_CIPHER_MODE_CBC_256 = 0x4, | ||
| ICE_CIPHER_MODE_ECB_256 = 0x5 | ||
| }; | ||
|
|
||
| enum ice_data_unit_type { | ||
| ICE_DATA_UNIT_SIZE_512 = 0x1, | ||
| ICE_DATA_UNIT_SIZE_1024 = 0x2, | ||
| ICE_DATA_UNIT_SIZE_2048 = 0x4, | ||
| ICE_DATA_UNIT_SIZE_4096 = 0x8, | ||
| ICE_DATA_UNIT_SIZE_8192 = 0x10, | ||
| ICE_DATA_UNIT_SIZE_16384 = 0x20, | ||
| ICE_DATA_UNIT_SIZE_32768 = 0x40, | ||
| ICE_DATA_UNIT_SIZE_65536 = 0x80 | ||
| }; | ||
|
|
||
| #endif /* __ICE_CONFIG_H */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // SPDX-License-Identifier: BSD-2-Clause | ||
| /* | ||
| * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| */ | ||
|
|
||
| #include <kernel/pseudo_ta.h> | ||
| #include <kernel/tee_ta_manager.h> | ||
| #include <pta_qcom_ice.h> | ||
| #include <tee_api_defines_extensions.h> | ||
| #include <trace.h> | ||
|
|
||
| #include "sw_keys/ice_sw_keys.h" | ||
|
|
||
| /* | ||
| * Controller-agnostic entry points. These wrap the per-controller | ||
| * implementation so the dispatcher stays independent of the underlying ICE | ||
| * block. Only software-key programming exists today; a future hardware-key | ||
| * (HWKM) path can be selected here at runtime, based on the key size passed | ||
| * to the PTA, dispatching to hwkm_cmd_ice_*() instead of sw_cmd_ice_*(). | ||
| */ | ||
| static TEE_Result cmd_ice_invalidate_key(uint32_t param_types, | ||
| TEE_Param params[TEE_NUM_PARAMS]) | ||
| { | ||
| return sw_cmd_ice_invalidate_key(param_types, params); | ||
| } | ||
|
|
||
| static TEE_Result cmd_ice_set_config_key(uint32_t param_types, | ||
| TEE_Param params[TEE_NUM_PARAMS]) | ||
| { | ||
| return sw_cmd_ice_set_config_key(param_types, params); | ||
| } | ||
|
|
||
| /* PTA command dispatcher */ | ||
| static TEE_Result invoke_command(void *sess_ctx __unused, uint32_t cmd_id, | ||
| uint32_t param_types, | ||
| TEE_Param params[TEE_NUM_PARAMS]) | ||
| { | ||
| switch (cmd_id) { | ||
| case PTA_CMD_ICE_INVALIDATE_KEY: | ||
| return cmd_ice_invalidate_key(param_types, params); | ||
|
thariaruchamy-bit marked this conversation as resolved.
|
||
| case PTA_CMD_ICE_SET_CONFIG_KEY: | ||
| return cmd_ice_set_config_key(param_types, params); | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
| EMSG("ICE: Command not implemented: %u", cmd_id); | ||
| return TEE_ERROR_NOT_IMPLEMENTED; | ||
| } | ||
|
|
||
| /* Only the REE kernel's storage-encryption path may open a session */ | ||
| static TEE_Result open_session(uint32_t param_types __unused, | ||
| TEE_Param params[TEE_NUM_PARAMS] __unused, | ||
| void **sess_ctx __unused) | ||
| { | ||
| struct tee_ta_session *s = to_ta_session(ts_get_current_session()); | ||
|
|
||
| if (s->clnt_id.login != TEE_LOGIN_REE_KERNEL) | ||
| return TEE_ERROR_ACCESS_DENIED; | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| pseudo_ta_register(.uuid = PTA_QCOM_ICE_UUID, | ||
|
thariaruchamy-bit marked this conversation as resolved.
|
||
| .name = "qcom_ice.pta", | ||
| .flags = PTA_DEFAULT_FLAGS | TA_FLAG_DEVICE_ENUM, | ||
|
thariaruchamy-bit marked this conversation as resolved.
|
||
| .open_session_entry_point = open_session, | ||
| .invoke_command_entry_point = invoke_command); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| srcs-y += ice.c | ||
| incdirs-y += . | ||
| subdirs-y += sw_keys |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.