44 */
55
66#include <kernel/transfer_list.h>
7- #include <mm/core_memprot.h>
7+ #include <mm/core_mmu.h>
8+ #include <mm/phys_mem.h>
89#include <pta_invoke_tests.h>
910#include <stdlib.h>
1011#include <string.h>
@@ -28,13 +29,12 @@ static TEE_Result test_add_te(struct transfer_list_header *tl,
2829 const void * data , uint8_t align ,
2930 struct transfer_list_entry * * tle )
3031{
31- uint8_t * te_dat ;
32- bool new_max_align = false ;
32+ uint8_t * te_dat = NULL ;
33+ uint8_t old_tl_align = 0 ;
3334 vaddr_t old_tl_ev = (vaddr_t )tl + tl -> size ;
34- struct transfer_list_entry * tl_e ;
35+ struct transfer_list_entry * tl_e = NULL ;
3536
36- if (align > tl -> alignment )
37- new_max_align = true;
37+ old_tl_align = tl -> alignment ;
3838
3939 if (!align )
4040 tl_e = transfer_list_add (tl , tag_id , data_size , data );
@@ -45,8 +45,7 @@ static TEE_Result test_add_te(struct transfer_list_header *tl,
4545 if (!tl_e )
4646 return TEE_ERROR_GENERIC ;
4747
48- /* tl->alignment keeps the max entry data alignment of the TL */
49- if (new_max_align && tl -> alignment != align )
48+ if (tl -> alignment != MAX (old_tl_align , align ))
5049 return TEE_ERROR_CORRUPT_OBJECT ;
5150
5251 if (tl_e -> tag_id != tag_id || tl_e -> hdr_size != sizeof (* tl_e ) ||
@@ -87,7 +86,7 @@ static TEE_Result test_add_te(struct transfer_list_header *tl,
8786static TEE_Result test_rm_te (struct transfer_list_header * tl ,
8887 uint16_t tag_id )
8988{
90- struct transfer_list_entry * tl_e ;
89+ struct transfer_list_entry * tl_e = NULL ;
9190
9291 tl_e = transfer_list_find (tl , tag_id );
9392 if (!tl_e )
@@ -109,9 +108,9 @@ static TEE_Result test_set_te_data_size(struct transfer_list_header *tl,
109108 struct transfer_list_entry * tl_e ,
110109 uint32_t new_data_size )
111110{
112- struct transfer_list_entry * old_te_next ;
113- struct transfer_list_entry * new_te_next ;
114- size_t mov_dis ;
111+ struct transfer_list_entry * old_te_next = NULL ;
112+ struct transfer_list_entry * new_te_next = NULL ;
113+ size_t mov_dis = 0 ;
115114
116115 old_te_next = transfer_list_next (tl , tl_e );
117116
@@ -144,20 +143,16 @@ static TEE_Result test_set_te_data_size(struct transfer_list_header *tl,
144143
145144static TEE_Result transfer_list_tests (void )
146145{
147- uint8_t * va_tl ;
148- paddr_t pa_tl ;
149- struct transfer_list_header * tl ;
150- struct transfer_list_entry * te1 , * te2 , * te3 ;
151- TEE_Result ret ;
152-
153- va_tl = memalign (TL_ALIGNMENT_FROM_ORDER (TRANSFER_LIST_INIT_MAX_ALIGN ),
154- TEST_TL_MAX_SIZE );
155- if (!va_tl )
156- return TEE_ERROR_OUT_OF_MEMORY ;
146+ struct transfer_list_header * tl = NULL ;
147+ struct transfer_list_entry * te1 = NULL , * te2 = NULL , * te3 = NULL ;
148+ TEE_Result ret = TEE_SUCCESS ;
149+ tee_mm_entry_t * mm = NULL ;
157150
158- pa_tl = virt_to_phys (va_tl );
151+ mm = phys_mem_core_alloc (SMALL_PAGE_SIZE );
152+ if (!mm )
153+ return TEE_ERROR_OUT_OF_MEMORY ;
159154
160- tl = transfer_list_init (pa_tl , TEST_TL_MAX_SIZE );
155+ tl = transfer_list_init (tee_mm_get_smem ( mm ) , TEST_TL_MAX_SIZE );
161156 if (!tl ) {
162157 ret = TEE_ERROR_GENERIC ;
163158 goto free_tl ;
@@ -232,7 +227,7 @@ static TEE_Result transfer_list_tests(void)
232227 transfer_list_unmap_sync (tl );
233228
234229free_tl :
235- free ( va_tl );
230+ tee_mm_free ( mm );
236231 return ret ;
237232}
238233
0 commit comments