-
Notifications
You must be signed in to change notification settings - Fork 1.3k
ta/pta: qcom: pas: authenticate PIL firmware signatures and device bindings #7937
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
zelvam95
wants to merge
8
commits into
OP-TEE:master
Choose a base branch
from
zelvam95:feature/optee-pas-sig-auth
base: master
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
8 commits
Select commit
Hold shift + click to select a range
33466d8
pta: qcom: pas: prepare for PAS signature authentication
zelvam95 d5f42ca
drivers: qcom: qfprom: add Lemans platform configuration
zelvam95 56c5c99
drivers: qcom: qfprom: add secure-boot fuse accessors
zelvam95 57395ac
pta: qcom: fuse: expose secure-boot fuses to user TAs
zelvam95 c06891f
ta: qcom_pas: add MBN metadata decoder and retype the hash-segment pa…
zelvam95 f93f250
ta: qcom_pas: add fuse-PTA session helper
zelvam95 d563d16
ta: qcom_pas: verify image signature and device bindings
zelvam95 54be022
plat-qcom: hoya: lemans: wire up fuse PTA and QFPROM for PAS authenti…
zelvam95 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
| // SPDX-License-Identifier: BSD-2-Clause | ||
| /* | ||
| * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| */ | ||
|
|
||
| #include <config.h> | ||
| #include <inttypes.h> | ||
| #include <io.h> | ||
| #include <mm/core_memprot.h> | ||
| #include <mm/core_mmu.h> | ||
| #include <string.h> | ||
| #include <trace.h> | ||
| #include <utee_defines.h> | ||
| #include <util.h> | ||
|
|
||
| #include "qfprom_priv.h" | ||
| #include "qfprom_target.h" | ||
|
|
||
| register_phys_mem_pgdir(MEM_AREA_IO_SEC, TCSR_SOC_HW_VERSION_ADDR, | ||
| CORE_MMU_PGDIR_SIZE); | ||
|
|
||
| static TEE_Result read_sense_reg(uint32_t offset, uint32_t *out) | ||
| { | ||
| struct qfprom_context *drv = qfprom_get_context(); | ||
|
|
||
| if (!drv->raw_base_va) | ||
| return TEE_ERROR_BAD_STATE; | ||
|
|
||
| *out = io_read32(drv->raw_base_va + offset); | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| TEE_Result qcom_secboot_is_enabled(bool *enabled) | ||
| { | ||
| TEE_Result res = TEE_ERROR_GENERIC; | ||
| uint32_t val = 0; | ||
|
|
||
| if (!enabled) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| res = read_sense_reg(SECURE_BOOT_APPS_OFFSET, &val); | ||
| if (res) | ||
| return res; | ||
|
|
||
| *enabled = (val & SECURE_BOOT_AUTH_EN_BMSK) != 0; | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| TEE_Result qcom_secboot_is_use_serial_num_enabled(bool *enabled) | ||
| { | ||
| TEE_Result res = TEE_ERROR_GENERIC; | ||
| uint32_t val = 0; | ||
|
|
||
| if (!enabled) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| res = read_sense_reg(SECURE_BOOT_APPS_OFFSET, &val); | ||
| if (res) | ||
| return res; | ||
|
|
||
| *enabled = (val & SECURE_BOOT_USE_SERIAL_NUM_BMSK) != 0; | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| TEE_Result qcom_secboot_get_root_of_trust(uint8_t *hash, size_t len) | ||
| { | ||
| size_t off = 0; | ||
|
|
||
| if (!hash) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| if (len != QFPROM_ROOT_OF_TRUST_BYTE_SIZE) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| for (off = 0; off < len; off += sizeof(uint32_t)) { | ||
| TEE_Result res = TEE_ERROR_GENERIC; | ||
| uint32_t word = 0; | ||
|
|
||
| res = read_sense_reg(PK_HASH0_OFFSET + off, &word); | ||
| if (res) | ||
| return res; | ||
|
|
||
| memcpy(hash + off, &word, sizeof(word)); | ||
| } | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| TEE_Result qcom_secboot_get_device_ids(struct qcom_secboot_device_ids *ids) | ||
| { | ||
| TEE_Result res = TEE_ERROR_GENERIC; | ||
| uint32_t val = 0; | ||
|
|
||
| if (!ids) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| res = read_sense_reg(OEM_ID_OFFSET, &val); | ||
| if (res) | ||
| return res; | ||
| ids->oem_id = (val & OEM_ID_BMSK) >> OEM_ID_SHFT; | ||
| ids->model_id = (val & MODEL_ID_BMSK) >> MODEL_ID_SHFT; | ||
|
|
||
| res = read_sense_reg(JTAG_ID_OFFSET, &val); | ||
| if (res) | ||
| return res; | ||
| ids->jtag_id = val & JTAG_ID_AUTH_BMSK; | ||
|
|
||
| res = read_sense_reg(SERIAL_NUM_OFFSET, &ids->serial_num); | ||
| if (res) | ||
| return res; | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| #define SEGMENT_HASH_ROOT_CERT_SEL_MAX 3U | ||
|
|
||
| /* | ||
| * Return the hash algorithm's digest size (SHA-256 or SHA-384) selected | ||
| * for the root cert at @root_cert_sel, per the OEM_CONFIG2 fuse row. | ||
| */ | ||
| TEE_Result qcom_secboot_get_segment_hash_len(uint32_t root_cert_sel, | ||
| uint32_t *hash_len) | ||
| { | ||
| if (!hash_len) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| if (root_cert_sel > SEGMENT_HASH_ROOT_CERT_SEL_MAX) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| if (IS_ENABLED(CFG_QCOM_SEGMENT_HASH_SELECT)) { | ||
| TEE_Result res = TEE_ERROR_GENERIC; | ||
| uint32_t val = 0; | ||
|
|
||
| res = read_sense_reg(OEM_CONFIG2_OFFSET, &val); | ||
| if (res) | ||
| return res; | ||
|
|
||
| if (val & BIT32(SEGMENT_HASH_FUNCTION_SELECT0_SHFT + | ||
| root_cert_sel)) | ||
| *hash_len = TEE_SHA256_HASH_SIZE; | ||
| else | ||
| *hash_len = TEE_SHA384_HASH_SIZE; | ||
| } else { | ||
| *hash_len = TEE_SHA384_HASH_SIZE; | ||
| } | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| TEE_Result qcom_secboot_get_eku_enforcement_en(bool *enabled) | ||
| { | ||
| TEE_Result res = TEE_ERROR_GENERIC; | ||
| uint32_t val = 0; | ||
|
|
||
| if (!enabled) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| res = read_sense_reg(OEM_CONFIG2_OFFSET, &val); | ||
| if (res) | ||
| return res; | ||
|
|
||
| *enabled = val & BIT32(EKU_ENFORCEMENT_EN_SHFT); | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| TEE_Result qcom_secboot_get_soc_hw_version(uint32_t *fam_dev) | ||
| { | ||
| static vaddr_t soc_hw_version_addr; | ||
| uint32_t val = 0; | ||
|
|
||
| if (!fam_dev) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| if (!soc_hw_version_addr) { | ||
| soc_hw_version_addr = | ||
| (vaddr_t)phys_to_virt(TCSR_SOC_HW_VERSION_ADDR, | ||
| MEM_AREA_IO_SEC, | ||
| sizeof(uint32_t)); | ||
| if (!soc_hw_version_addr) | ||
| return TEE_ERROR_GENERIC; | ||
| } | ||
|
|
||
| val = io_read32(soc_hw_version_addr); | ||
| *fam_dev = (val & SOC_HW_VERSION_FAM_DEV_BMSK) >> | ||
| SOC_HW_VERSION_FAM_DEV_SHFT; | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
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
Oops, something went wrong.
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.