Skip to content

Commit ddcce3b

Browse files
Yann-lmsTrustedFirmware Code Review
authored and
TrustedFirmware Code Review
committed
Merge "fix(intel): update ssbl naming conventions" into integration
2 parents 8ed1e20 + bf2c213 commit ddcce3b

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

plat/intel/soc/common/include/socfpga_ros.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2024, Intel Corporation. All rights reserved.
3+
* Copyright (c) 2025, Altera Corporation. All rights reserved.
34
*
45
* SPDX-License-Identifier: BSD-3-Clause
56
*/
@@ -40,8 +41,8 @@
4041
#define SPT_MIN_PARTITIONS (9U)
4142

4243
#define FACTORY_IMAGE "FACTORY_IMAGE"
43-
#define FACTORY_SSBL "FACTORY_IM.SSBL"
44-
#define SSBL_SUFFIX ".SSBL"
44+
#define FACTORY_SSBL "SSBL.FACTORY_IM"
45+
#define SSBL_PREFIX "SSBL."
4546

4647
typedef struct {
4748
const uint32_t magic_number;
@@ -55,7 +56,7 @@ typedef struct {
5556
const uint32_t length;
5657
const uint32_t flags;
5758
} partition[SPT_MAX_PARTITIONS];
58-
} __packed spt_table_t;
59+
} __packed __aligned(4) spt_table_t;
5960

6061
uint32_t ros_qspi_get_ssbl_offset(unsigned long *offset);
6162

plat/intel/soc/common/socfpga_ros.c

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2024, Intel Corporation. All rights reserved.
3+
* Copyright (c) 2025, Altera Corporation. All rights reserved.
34
*
45
* SPDX-License-Identifier: BSD-3-Clause
56
*/
@@ -20,6 +21,8 @@
2021

2122
#include <socfpga_ros.h>
2223

24+
#define WORD_SIZE (sizeof(uint32_t))
25+
2326
static void swap_bits(char *const data, uint32_t len)
2427
{
2528
uint32_t x, y;
@@ -99,7 +102,8 @@ static uint32_t load_and_check_spt(spt_table_t *spt_ptr, size_t offset)
99102
return ROS_IMAGE_PARTNUM_OVFL;
100103
}
101104

102-
memcpy_s(&spt_data, SPT_SIZE, spt_ptr, SPT_SIZE);
105+
memcpy_s(&spt_data, (sizeof(spt_table_t) / WORD_SIZE),
106+
spt_ptr, (SPT_SIZE / WORD_SIZE));
103107
spt_data.checksum = 0U;
104108
swap_bits((char *)&spt_data, SPT_SIZE);
105109

@@ -153,6 +157,7 @@ uint32_t ros_qspi_get_ssbl_offset(unsigned long *offset)
153157
}
154158

155159
uint32_t ret, img_index;
160+
size_t len;
156161
char ssbl_name[SPT_PARTITION_NAME_LENGTH];
157162
static spt_table_t spt;
158163

@@ -168,11 +173,12 @@ uint32_t ros_qspi_get_ssbl_offset(unsigned long *offset)
168173

169174
if (strncmp(spt.partition[img_index].name, FACTORY_IMAGE,
170175
SPT_PARTITION_NAME_LENGTH) == 0U) {
171-
strlcpy(ssbl_name, FACTORY_SSBL, SPT_PARTITION_NAME_LENGTH);
176+
strcpy_secure(ssbl_name, SPT_PARTITION_NAME_LENGTH, FACTORY_SSBL);
172177
} else {
173-
strlcpy(ssbl_name, spt.partition[img_index].name,
174-
SPT_PARTITION_NAME_LENGTH);
175-
strlcat(ssbl_name, SSBL_SUFFIX, SPT_PARTITION_NAME_LENGTH);
178+
strcpy_secure(ssbl_name, SPT_PARTITION_NAME_LENGTH, SSBL_PREFIX);
179+
len = strnlen_secure(ssbl_name, SPT_PARTITION_NAME_LENGTH);
180+
strcpy_secure(ssbl_name + len, SPT_PARTITION_NAME_LENGTH - len,
181+
spt.partition[img_index].name);
176182
}
177183

178184
for (uint32_t index = 0U; index < spt.partitions; index++) {

0 commit comments

Comments
 (0)