-
Notifications
You must be signed in to change notification settings - Fork 30
ta/pta: qcom: pas: authenticate PIL firmware signatures and device bindings #20
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
Closed
Selvam Sathappan (zelvam95)
wants to merge
8
commits into
qualcomm-linux:qcom-next
from
zelvam95:feature/qcom-pas-sig-auth
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
eda2e12
pta: qcom: pas: validate carveout range and cache state before verify
zelvam95 b0a6107
drivers: qcom: qfprom: add Lemans platform configuration
zelvam95 c327d28
drivers: qcom: qfprom: add secure-boot fuse accessors
zelvam95 ee8f911
pta: qcom: fuse: expose secure-boot fuses to user TAs
zelvam95 5bf049c
ta: qcom_pas: add MBN metadata decoder
zelvam95 058ea13
ta: qcom_pas: add fuse-PTA session helper
zelvam95 e21e66c
ta: qcom_pas: verify image signature and device bindings
zelvam95 b6a5c63
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,202 @@ | ||
| // SPDX-License-Identifier: BSD-2-Clause | ||
| /* | ||
| * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| */ | ||
|
|
||
| #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); | ||
|
|
||
| TEE_Result qcom_secboot_is_enabled(bool *enabled) | ||
| { | ||
| struct qfprom_context *drv = qfprom_get_context(); | ||
| uint32_t val = 0; | ||
|
|
||
| if (!enabled) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| if (!drv->raw_base_va) | ||
| return TEE_ERROR_BAD_STATE; | ||
|
|
||
| val = io_read32(drv->raw_base_va + | ||
| (SECURE_BOOT_APPS_ADDR - SECURITY_CONTROL_BASE)); | ||
| *enabled = (val & SECURE_BOOT_AUTH_EN_BMSK) != 0; | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| TEE_Result qcom_secboot_get_use_serial_num(bool *enabled) | ||
| { | ||
| struct qfprom_context *drv = qfprom_get_context(); | ||
| uint32_t val = 0; | ||
|
|
||
| if (!enabled) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| if (!drv->raw_base_va) | ||
| return TEE_ERROR_BAD_STATE; | ||
|
|
||
| val = io_read32(drv->raw_base_va + | ||
| (SECURE_BOOT_APPS_ADDR - SECURITY_CONTROL_BASE)); | ||
| *enabled = (val & SECURE_BOOT_USE_SERIAL_NUM_BMSK) != 0; | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| static TEE_Result read_sense_reg(paddr_t pa, 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 + (pa - SECURITY_CONTROL_BASE)); | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| TEE_Result qcom_secboot_get_root_of_trust(uint8_t *hash, size_t len) | ||
| { | ||
|
zelvam95 marked this conversation as resolved.
|
||
| 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_SENSE_ADDR + off, &word); | ||
| if (res) | ||
| return res; | ||
|
|
||
| memcpy(hash + off, &word, MIN(sizeof(word), len - off)); | ||
| } | ||
|
|
||
| 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_SENSE_ADDR, &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_SENSE_ADDR, &val); | ||
| if (res) | ||
| return res; | ||
| ids->jtag_id = val & JTAG_ID_AUTH_BMSK; | ||
|
|
||
| res = read_sense_reg(SERIAL_NUM_SENSE_ADDR, &ids->serial_num); | ||
| if (res) | ||
| return res; | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| #define SEGMENT_HASH_ROOT_CERT_SEL_MAX 3U | ||
|
|
||
| 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 SEGMENT_HASH_SELECT_SUPPORTED | ||
| { | ||
| TEE_Result res = TEE_ERROR_GENERIC; | ||
| uint32_t val = 0; | ||
|
|
||
| res = read_sense_reg(OEM_CONFIG2_ADDR, &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; | ||
| #endif | ||
|
|
||
| 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_ADDR, &val); | ||
| if (res) | ||
| return res; | ||
|
|
||
| *enabled = val & BIT32(EKU_ENFORCEMENT_EN_SHFT); | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| TEE_Result qcom_secboot_get_image_encryption_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_CONFIG0_ADDR, &val); | ||
| if (res) | ||
| return res; | ||
|
|
||
| *enabled = val & BIT32(IMAGE_ENCRYPTION_ENABLE_SHFT); | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| TEE_Result qcom_secboot_get_soc_hw_version(uint32_t *fam_dev) | ||
| { | ||
| vaddr_t va = 0; | ||
|
|
||
| if (!fam_dev) | ||
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| va = (vaddr_t)phys_to_virt(TCSR_SOC_HW_VERSION_ADDR, MEM_AREA_IO_SEC, | ||
| sizeof(uint32_t)); | ||
| if (!va) | ||
| return TEE_ERROR_GENERIC; | ||
|
|
||
| *fam_dev = (io_read32(va) & 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.
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.