mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			TF-M patch: Fix fixed-size partitions stack size (TF-M issue #240)
- Link to bug tracking: https://developer.trustedfirmware.org/T240pull/9653/head
							parent
							
								
									0c23e86989
								
							
						
					
					
						commit
						fc78640559
					
				| 
						 | 
				
			
			@ -435,15 +435,19 @@ tfm_spm_partition_get_thread_info_ext(uint32_t partition_idx)
 | 
			
		|||
    return &g_spm_partition_db.partitions[partition_idx].sp_thrd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t tfm_spm_partition_get_stack_base_ext(uint32_t partition_idx)
 | 
			
		||||
static uint32_t tfm_spm_partition_get_stack_size_ext(uint32_t partition_idx)
 | 
			
		||||
{
 | 
			
		||||
    return (uint32_t)&(g_spm_partition_db.partitions[partition_idx].
 | 
			
		||||
                       stack[TFM_STACK_SIZE]);
 | 
			
		||||
    return g_spm_partition_db.partitions[partition_idx].stack_size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t tfm_spm_partition_get_stack_limit_ext(uint32_t partition_idx)
 | 
			
		||||
{
 | 
			
		||||
    return (uint32_t)&g_spm_partition_db.partitions[partition_idx].stack;
 | 
			
		||||
    return g_spm_partition_db.partitions[partition_idx].stack_limit;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t tfm_spm_partition_get_stack_base_ext(uint32_t partition_idx)
 | 
			
		||||
{
 | 
			
		||||
    return tfm_spm_partition_get_stack_limit_ext(partition_idx) + tfm_spm_partition_get_stack_size_ext(partition_idx);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static tfm_thrd_func_t
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,11 +66,10 @@ struct spm_partition_desc_t {
 | 
			
		|||
#ifdef TFM_PSA_API
 | 
			
		||||
    struct tfm_thrd_ctx sp_thrd;
 | 
			
		||||
    /*
 | 
			
		||||
     * FixMe: Hard code stack is not aligned with the definition in the
 | 
			
		||||
     * manifest. It will use the partition stacks in the linker scripts/sct
 | 
			
		||||
     * files include Level 1 to 3.
 | 
			
		||||
     * stack_limit points to starting address of the partitions' stack plus the partitions' stack size.
 | 
			
		||||
     */
 | 
			
		||||
    uint8_t stack[TFM_STACK_SIZE] __attribute__((aligned(8)));
 | 
			
		||||
    uint32_t stack_limit;
 | 
			
		||||
    uint32_t stack_size;
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -71,7 +71,7 @@ struct spm_partition_db_t {
 | 
			
		|||
    } while (0)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define PARTITION_DECLARE(partition, flag, type, id, priority)               \
 | 
			
		||||
#define PARTITION_DECLARE(partition, flag, type, id, priority, part_stack_size)   \
 | 
			
		||||
    do {                                                                     \
 | 
			
		||||
        REGION_DECLARE(Image$$, partition, $$Base);                          \
 | 
			
		||||
        REGION_DECLARE(Image$$, partition, $$Limit);                         \
 | 
			
		||||
| 
						 | 
				
			
			@ -97,8 +97,12 @@ struct spm_partition_db_t {
 | 
			
		|||
        if (g_spm_partition_db.partition_count >= SPM_MAX_PARTITIONS) {      \
 | 
			
		||||
            return SPM_ERR_INVALID_CONFIG;                                   \
 | 
			
		||||
        }                                                                    \
 | 
			
		||||
        __attribute__((section(".data.partitions_stacks")))                  \
 | 
			
		||||
        static uint8_t partition##_stack[part_stack_size] __attribute__((aligned(8))); \
 | 
			
		||||
        part_ptr = &(g_spm_partition_db.partitions[                          \
 | 
			
		||||
            g_spm_partition_db.partition_count]);                            \
 | 
			
		||||
        part_ptr->stack_limit = (uint32_t)partition##_stack;                 \
 | 
			
		||||
        part_ptr->stack_size = part_stack_size;                              \
 | 
			
		||||
        PARTITION_INIT_STATIC_DATA(part_ptr->static_data, partition, flags,  \
 | 
			
		||||
                                   id, priority);                            \
 | 
			
		||||
        PARTITION_INIT_RUNTIME_DATA(part_ptr->runtime_data, partition);      \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue