Lines Matching refs:sp
96 struct sp_exec_ctx *spmc_get_sp_ec(struct secure_partition_desc *sp) in spmc_get_sp_ec() argument
98 return &(sp->ec[get_ec_index(sp)]); in spmc_get_sp_ec()
286 struct secure_partition_desc *sp; in direct_msg_validate_dst_id() local
299 sp = spmc_get_sp_ctx(dst_id); in direct_msg_validate_dst_id()
300 if (sp != NULL) { in direct_msg_validate_dst_id()
386 struct secure_partition_desc *sp; in direct_req_smc_handler() local
450 sp = spmc_get_sp_ctx(dst_id); in direct_req_smc_handler()
451 if (sp == NULL) { in direct_req_smc_handler()
458 if (!direct_msg_receivable(sp->properties, dir_req_funcid)) { in direct_req_smc_handler()
463 if (sp->runtime_el == S_EL0) { in direct_req_smc_handler()
464 spin_lock(&sp->rt_state_lock); in direct_req_smc_handler()
471 idx = get_ec_index(sp); in direct_req_smc_handler()
472 if (sp->ec[idx].rt_state != RT_STATE_WAITING) { in direct_req_smc_handler()
474 idx, sp->ec[idx].rt_model); in direct_req_smc_handler()
476 if (sp->runtime_el == S_EL0) { in direct_req_smc_handler()
477 spin_unlock(&sp->rt_state_lock); in direct_req_smc_handler()
487 sp->ec[idx].rt_state = RT_STATE_RUNNING; in direct_req_smc_handler()
488 sp->ec[idx].rt_model = RT_MODEL_DIR_REQ; in direct_req_smc_handler()
489 sp->ec[idx].dir_req_origin_id = src_id; in direct_req_smc_handler()
490 sp->ec[idx].dir_req_funcid = dir_req_funcid; in direct_req_smc_handler()
492 if (sp->runtime_el == S_EL0) { in direct_req_smc_handler()
493 spin_unlock(&sp->rt_state_lock); in direct_req_smc_handler()
497 handle, cookie, flags, dst_id, sp->ffa_version); in direct_req_smc_handler()
515 struct secure_partition_desc *sp; in direct_resp_smc_handler() local
546 sp = spmc_get_sp_ctx(ffa_endpoint_source(x1)); in direct_resp_smc_handler()
547 if (sp == NULL) { in direct_resp_smc_handler()
554 if (sp->runtime_el == S_EL0) { in direct_resp_smc_handler()
555 spin_lock(&sp->rt_state_lock); in direct_resp_smc_handler()
559 idx = get_ec_index(sp); in direct_resp_smc_handler()
560 assert(sp->ec[idx].rt_state == RT_STATE_RUNNING); in direct_resp_smc_handler()
563 if (sp->ec[idx].rt_model != RT_MODEL_DIR_REQ) { in direct_resp_smc_handler()
565 idx, sp->ec[idx].rt_model); in direct_resp_smc_handler()
566 if (sp->runtime_el == S_EL0) { in direct_resp_smc_handler()
567 spin_unlock(&sp->rt_state_lock); in direct_resp_smc_handler()
572 if (dir_req_funcid != sp->ec[idx].dir_req_funcid) { in direct_resp_smc_handler()
574 sp->ec[idx].dir_req_funcid, (smc_fid & FUNCID_NUM_MASK), idx); in direct_resp_smc_handler()
575 if (sp->runtime_el == S_EL0) { in direct_resp_smc_handler()
576 spin_unlock(&sp->rt_state_lock); in direct_resp_smc_handler()
581 if (sp->ec[idx].dir_req_origin_id != dst_id) { in direct_resp_smc_handler()
583 dst_id, sp->ec[idx].dir_req_origin_id, idx); in direct_resp_smc_handler()
584 if (sp->runtime_el == S_EL0) { in direct_resp_smc_handler()
585 spin_unlock(&sp->rt_state_lock); in direct_resp_smc_handler()
591 sp->ec[idx].rt_state = RT_STATE_WAITING; in direct_resp_smc_handler()
594 sp->ec[idx].dir_req_origin_id = INV_SP_ID; in direct_resp_smc_handler()
597 sp->ec[idx].dir_req_funcid = 0U; in direct_resp_smc_handler()
599 if (sp->runtime_el == S_EL0) { in direct_resp_smc_handler()
600 spin_unlock(&sp->rt_state_lock); in direct_resp_smc_handler()
608 spmc_sp_synchronous_exit(&sp->ec[idx], x4); in direct_resp_smc_handler()
614 handle, cookie, flags, dst_id, sp->ffa_version); in direct_resp_smc_handler()
631 struct secure_partition_desc *sp; in msg_wait_handler() local
644 sp = spmc_get_current_sp_ctx(); in msg_wait_handler()
645 if (sp == NULL) { in msg_wait_handler()
653 idx = get_ec_index(sp); in msg_wait_handler()
654 if (sp->runtime_el == S_EL0) { in msg_wait_handler()
655 spin_lock(&sp->rt_state_lock); in msg_wait_handler()
659 if (sp->ec[idx].rt_model == RT_MODEL_DIR_REQ) { in msg_wait_handler()
660 if (sp->runtime_el == S_EL0) { in msg_wait_handler()
661 spin_unlock(&sp->rt_state_lock); in msg_wait_handler()
667 assert(sp->ec[idx].rt_state == RT_STATE_RUNNING); in msg_wait_handler()
673 if (sp->ec[idx].rt_model == RT_MODEL_INIT) { in msg_wait_handler()
674 if (sp->runtime_el == S_EL0) { in msg_wait_handler()
675 spin_unlock(&sp->rt_state_lock); in msg_wait_handler()
677 spmc_sp_synchronous_exit(&sp->ec[idx], x4); in msg_wait_handler()
683 sp->ec[idx].rt_state = RT_STATE_WAITING; in msg_wait_handler()
686 if (sp->ec[idx].rt_model == RT_MODEL_INTR) { in msg_wait_handler()
687 if (sp->runtime_el == S_EL0) { in msg_wait_handler()
688 spin_unlock(&sp->rt_state_lock); in msg_wait_handler()
694 handle, flags, sp->ffa_version); in msg_wait_handler()
698 if (sp->runtime_el == S_EL0) { in msg_wait_handler()
699 spin_unlock(&sp->rt_state_lock); in msg_wait_handler()
704 handle, cookie, flags, FFA_NWD_ID, sp->ffa_version); in msg_wait_handler()
717 struct secure_partition_desc *sp; in ffa_error_handler() local
728 sp = spmc_get_current_sp_ctx(); in ffa_error_handler()
729 if (sp == NULL) { in ffa_error_handler()
735 idx = get_ec_index(sp); in ffa_error_handler()
741 if (sp->ec[idx].rt_model == RT_MODEL_INIT) { in ffa_error_handler()
742 ERROR("SP 0x%x failed to initialize.\n", sp->sp_id); in ffa_error_handler()
743 spmc_sp_synchronous_exit(&sp->ec[idx], x2); in ffa_error_handler()
748 if (sp->runtime_el == S_EL0) { in ffa_error_handler()
749 spin_lock(&sp->rt_state_lock); in ffa_error_handler()
752 if (sp->ec[idx].rt_state == RT_STATE_RUNNING && in ffa_error_handler()
753 sp->ec[idx].rt_model == RT_MODEL_DIR_REQ) { in ffa_error_handler()
754 sp->ec[idx].rt_state = RT_STATE_WAITING; in ffa_error_handler()
755 sp->ec[idx].dir_req_origin_id = INV_SP_ID; in ffa_error_handler()
756 sp->ec[idx].dir_req_funcid = 0x00; in ffa_error_handler()
760 if (sp->runtime_el == S_EL0) { in ffa_error_handler()
761 spin_unlock(&sp->rt_state_lock); in ffa_error_handler()
766 spmc_sp_synchronous_exit(&sp->ec[idx], x4); in ffa_error_handler()
771 handle, cookie, flags, dst_id, sp->ffa_version); in ffa_error_handler()
1302 struct secure_partition_desc *sp = spmc_get_current_sp_ctx(); in ffa_features_retrieve_request() local
1308 if (spmc_compatible_version(sp->ffa_version, 1, 1)) { in ffa_features_retrieve_request()
1317 sp->ns_bit_requested = (input_properties & in ffa_features_retrieve_request()
1321 if (sp->ns_bit_requested) { in ffa_features_retrieve_request()
1501 struct secure_partition_desc *sp; in ffa_run_handler() local
1523 sp = spmc_get_sp_ctx(target_id); in ffa_run_handler()
1524 if (sp == NULL) { in ffa_run_handler()
1530 idx = get_ec_index(sp); in ffa_run_handler()
1537 if (sp->runtime_el == S_EL0) { in ffa_run_handler()
1538 spin_lock(&sp->rt_state_lock); in ffa_run_handler()
1540 rt_state = &((sp->ec[idx]).rt_state); in ffa_run_handler()
1541 rt_model = &((sp->ec[idx]).rt_model); in ffa_run_handler()
1543 if (sp->runtime_el == S_EL0) { in ffa_run_handler()
1544 spin_unlock(&sp->rt_state_lock); in ffa_run_handler()
1572 if (sp->runtime_el == S_EL0) { in ffa_run_handler()
1573 spin_unlock(&sp->rt_state_lock); in ffa_run_handler()
1577 handle, cookie, flags, target_id, sp->ffa_version); in ffa_run_handler()
1663 static int validate_secondary_ep(uintptr_t ep, struct secure_partition_desc *sp) in validate_secondary_ep() argument
1672 mb = &sp->mailbox; in validate_secondary_ep()
1705 struct secure_partition_desc *sp; in ffa_sec_ep_register_handler() local
1715 sp = spmc_get_current_sp_ctx(); in ffa_sec_ep_register_handler()
1716 if (sp == NULL) { in ffa_sec_ep_register_handler()
1723 if (sp->runtime_el != S_EL1) { in ffa_sec_ep_register_handler()
1729 sp_ctx = spmc_get_sp_ec(sp); in ffa_sec_ep_register_handler()
1737 if (validate_secondary_ep(x1, sp)) { in ffa_sec_ep_register_handler()
1749 sp->secondary_ep = x1; in ffa_sec_ep_register_handler()
1750 VERBOSE("%s: 0x%lx\n", __func__, sp->secondary_ep); in ffa_sec_ep_register_handler()
1810 struct secure_partition_desc *sp; in ffa_mem_perm_set_handler() local
1828 sp = spmc_get_current_sp_ctx(); in ffa_mem_perm_set_handler()
1829 if (sp == NULL) { in ffa_mem_perm_set_handler()
1835 if (sp->runtime_el == S_EL1) { in ffa_mem_perm_set_handler()
1845 idx = get_ec_index(sp); in ffa_mem_perm_set_handler()
1852 if (sp->ec[idx].rt_model != RT_MODEL_INIT) { in ffa_mem_perm_set_handler()
1869 ret = xlat_change_mem_attributes_ctx(sp->xlat_ctx_handle, in ffa_mem_perm_set_handler()
1924 struct secure_partition_desc *sp; in ffa_mem_perm_get_handler() local
1940 sp = spmc_get_current_sp_ctx(); in ffa_mem_perm_get_handler()
1941 if (sp == NULL) { in ffa_mem_perm_get_handler()
1947 if (sp->runtime_el == S_EL1) { in ffa_mem_perm_get_handler()
1952 idx = get_ec_index(sp); in ffa_mem_perm_get_handler()
1959 if (sp->ec[idx].rt_model != RT_MODEL_INIT) { in ffa_mem_perm_get_handler()
1966 ret = xlat_get_mem_attributes_ctx(sp->xlat_ctx_handle, base_va, in ffa_mem_perm_get_handler()
1982 ret = xlat_get_mem_attributes_ctx(sp->xlat_ctx_handle, base_va, in ffa_mem_perm_get_handler()
2014 struct secure_partition_desc *sp, in sp_manifest_parse() argument
2039 sp->num_uuids = (uint32_t)uuid_size / sizeof(struct ffa_uuid); in sp_manifest_parse()
2040 if (sp->num_uuids > ARRAY_SIZE(sp->uuid_array)) { in sp_manifest_parse()
2042 sp->num_uuids, ARRAY_SIZE(sp->uuid_array)); in sp_manifest_parse()
2048 sp->uuid_array[0].uuid); in sp_manifest_parse()
2054 for (uint32_t i = 0; i < sp->num_uuids; i++) { in sp_manifest_parse()
2056 if (memcmp(&sp->uuid_array[i], &sp->uuid_array[j], in sp_manifest_parse()
2059 sp->uuid_array[i].uuid[0], in sp_manifest_parse()
2060 sp->uuid_array[i].uuid[1], in sp_manifest_parse()
2061 sp->uuid_array[i].uuid[2], in sp_manifest_parse()
2062 sp->uuid_array[i].uuid[3]); in sp_manifest_parse()
2074 sp->runtime_el = config_32; in sp_manifest_parse()
2082 sp->ffa_version = config_32; in sp_manifest_parse()
2090 sp->execution_state = config_32; in sp_manifest_parse()
2109 sp->properties = config_32; in sp_manifest_parse()
2124 if ((sp->runtime_el == S_EL1) && (config_32 != PLATFORM_CORE_COUNT)) { in sp_manifest_parse()
2143 sp->sp_id = config_32; in sp_manifest_parse()
2151 if ((sp->runtime_el == S_EL0) && (config_32 != 0)) { in sp_manifest_parse()
2167 sp->pwr_mgmt_msgs = config_32; in sp_manifest_parse()
2188 } else if ((sp->properties & FFA_PARTITION_DIRECT_REQ_RECV) == 0) { in sp_manifest_parse()
2202 sp->properties |= FFA_PARTITION_VM_CREATED; in sp_manifest_parse()
2205 sp->properties |= FFA_PARTITION_VM_DESTROYED; in sp_manifest_parse()
2225 struct secure_partition_desc *sp; in find_and_prepare_sp_context() local
2292 sp = spmc_get_current_sp_ctx(); in find_and_prepare_sp_context()
2304 ret = sp_manifest_parse(sp_manifest, ret, sp, next_image_ep_info, in find_and_prepare_sp_context()
2312 spmc_sp_common_setup(sp, next_image_ep_info, boot_info_reg); in find_and_prepare_sp_context()
2315 if (sp->runtime_el == S_EL1) { in find_and_prepare_sp_context()
2316 spmc_el1_sp_setup(sp, next_image_ep_info); in find_and_prepare_sp_context()
2317 spmc_sp_common_ep_commit(sp, next_image_ep_info); in find_and_prepare_sp_context()
2321 else if (sp->runtime_el == S_EL0) { in find_and_prepare_sp_context()
2325 spmc_sp_common_ep_commit(sp, next_image_ep_info); in find_and_prepare_sp_context()
2331 spmc_el0_sp_setup(sp, boot_info_reg, sp_manifest); in find_and_prepare_sp_context()
2335 ERROR("Unexpected runtime EL: %u\n", sp->runtime_el); in find_and_prepare_sp_context()
2409 struct secure_partition_desc *sp; in sp_init() local
2412 sp = spmc_get_current_sp_ctx(); in sp_init()
2413 ec = spmc_get_sp_ec(sp); in sp_init()
2417 INFO("Secure Partition (0x%x) init start.\n", sp->sp_id); in sp_init()
2423 sp->sp_id, rc); in sp_init()
2435 struct secure_partition_desc *sp; in initalize_sp_descs() local
2438 sp = &sp_desc[i]; in initalize_sp_descs()
2439 sp->sp_id = INV_SP_ID; in initalize_sp_descs()
2440 sp->mailbox.rx_buffer = NULL; in initalize_sp_descs()
2441 sp->mailbox.tx_buffer = NULL; in initalize_sp_descs()
2442 sp->mailbox.state = MAILBOX_STATE_EMPTY; in initalize_sp_descs()
2443 sp->secondary_ep = 0; in initalize_sp_descs()
2684 struct secure_partition_desc *sp = spmc_get_current_sp_ctx(); in spmc_sp_interrupt_handler() local
2689 assert(sp != NULL); in spmc_sp_interrupt_handler()
2695 if (sp->runtime_el != S_EL1) { in spmc_sp_interrupt_handler()
2702 ec = spmc_get_sp_ec(sp); in spmc_sp_interrupt_handler()
2715 VERBOSE("SP (0x%x) interrupt start on core%u.\n", sp->sp_id, linear_id); in spmc_sp_interrupt_handler()
2726 handle, 0ULL, sp->ffa_version); in spmc_sp_interrupt_handler()