diff options
author | Tom Hochstein <tom.hochstein@nxp.com> | 2025-03-26 07:23:35 -0700 |
---|---|---|
committer | Tom Hochstein <tom.hochstein@nxp.com> | 2025-03-26 14:23:46 -0700 |
commit | 3eb657e2491615eed1e1398be5c27cf47e53abcf (patch) | |
tree | e5ae781d50d95ee3f6a62cd40d3226c6bb341a48 | |
parent | 04abb8bec14f8ecbeb91f53aaf0e9ccc7c70dac4 (diff) | |
download | meta-freescale-3eb657e2491615eed1e1398be5c27cf47e53abcf.tar.gz |
optee-imx: Updates for clang
Clang is on version 20 now, so the disablement of it and the patches for
it are no longer needed.
Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
4 files changed, 0 insertions, 286 deletions
diff --git a/recipes-security/optee-imx/optee-fslc.inc b/recipes-security/optee-imx/optee-fslc.inc index 42e23fc2..6e380e05 100644 --- a/recipes-security/optee-imx/optee-fslc.inc +++ b/recipes-security/optee-imx/optee-fslc.inc | |||
@@ -17,9 +17,6 @@ OPTEE_ARCH:arm = "arm32" | |||
17 | OPTEE_ARCH:aarch64 = "arm64" | 17 | OPTEE_ARCH:aarch64 = "arm64" |
18 | OPTEE_CORE = "${@d.getVar('OPTEE_ARCH').upper()}" | 18 | OPTEE_CORE = "${@d.getVar('OPTEE_ARCH').upper()}" |
19 | 19 | ||
20 | # FIXME - breaks with Clang 18. See https://github.com/OP-TEE/optee_os/issues/6754 | ||
21 | TOOLCHAIN = "gcc" | ||
22 | |||
23 | OPTEE_TOOLCHAIN = "${@d.getVar('TOOLCHAIN') or 'gcc'}" | 20 | OPTEE_TOOLCHAIN = "${@d.getVar('TOOLCHAIN') or 'gcc'}" |
24 | OPTEE_COMPILER = "${@bb.utils.contains("BBFILE_COLLECTIONS", "clang-layer", "${OPTEE_TOOLCHAIN}", "gcc", d)}" | 21 | OPTEE_COMPILER = "${@bb.utils.contains("BBFILE_COLLECTIONS", "clang-layer", "${OPTEE_TOOLCHAIN}", "gcc", d)}" |
25 | 22 | ||
diff --git a/recipes-security/optee-imx/optee-os/0001-core-Define-section-attributes-for-clang.patch b/recipes-security/optee-imx/optee-os/0001-core-Define-section-attributes-for-clang.patch deleted file mode 100644 index 54fbe541..00000000 --- a/recipes-security/optee-imx/optee-os/0001-core-Define-section-attributes-for-clang.patch +++ /dev/null | |||
@@ -1,245 +0,0 @@ | |||
1 | From ef83625c9a5f50610e25aa860c4b9c5e64723a66 Mon Sep 17 00:00:00 2001 | ||
2 | From: Emekcan Aras <emekcan.aras@arm.com> | ||
3 | Date: Wed, 21 Dec 2022 10:55:58 +0000 | ||
4 | Subject: [PATCH 1/4] core: Define section attributes for clang | ||
5 | |||
6 | Clang's attribute section is not same as gcc, here we need to add flags | ||
7 | to sections so they can be eventually collected by linker into final | ||
8 | output segments. Only way to do so with clang is to use | ||
9 | |||
10 | pragma clang section ... | ||
11 | |||
12 | The behavious is described here [1], this allows us to define names bss | ||
13 | sections. This was not an issue until clang-15 where LLD linker starts | ||
14 | to detect the section flags before merging them and throws the following | ||
15 | errors | ||
16 | |||
17 | | ld.lld: error: section type mismatch for .nozi.kdata_page | ||
18 | | >>> /mnt/b/yoe/master/build/tmp/work/qemuarm64-yoe-linux/optee-os-tadevkit/3.17.0-r0/build/core/arch/arm/kernel/thread.o:(.nozi.kdata_page): SHT_PROGBITS | ||
19 | | >>> output section .nozi: SHT_NOBITS | ||
20 | | | ||
21 | | ld.lld: error: section type mismatch for .nozi.mmu.l2 | ||
22 | | >>> /mnt/b/yoe/master/build/tmp/work/qemuarm64-yoe-linux/optee-os-tadevkit/3.17.0-r0/build/core/arch/arm/mm/core_mmu_lpae.o:(.nozi.mmu.l2): SHT_PROGBITS | ||
23 | | >>> output section .nozi: SHT_NOBITS | ||
24 | |||
25 | These sections should be carrying SHT_NOBITS but so far it was not | ||
26 | possible to do so, this patch tries to use clangs pragma to get this | ||
27 | going and match the functionality with gcc. | ||
28 | |||
29 | [1] https://intel.github.io/llvm-docs/clang/LanguageExtensions.html#specifying-section-names-for-global-objects-pragma-clang-section | ||
30 | |||
31 | Upstream-Status: Pending | ||
32 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
33 | Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> | ||
34 | --- | ||
35 | |||
36 | core/arch/arm/kernel/thread.c | 19 +++++++++++++++-- | ||
37 | core/arch/arm/mm/core_mmu_lpae.c | 35 +++++++++++++++++++++++++++---- | ||
38 | core/arch/arm/mm/core_mmu_v7.c | 36 +++++++++++++++++++++++++++++--- | ||
39 | core/kernel/thread.c | 13 +++++++++++- | ||
40 | core/mm/pgt_cache.c | 12 ++++++++++- | ||
41 | 5 files changed, 104 insertions(+), 11 deletions(-) | ||
42 | |||
43 | diff --git a/core/arch/arm/kernel/thread.c b/core/arch/arm/kernel/thread.c | ||
44 | index 66833b3a0..b3eb9cf9a 100644 | ||
45 | --- a/core/arch/arm/kernel/thread.c | ||
46 | +++ b/core/arch/arm/kernel/thread.c | ||
47 | @@ -45,15 +45,30 @@ static size_t thread_user_kcode_size __nex_bss; | ||
48 | #if defined(CFG_CORE_UNMAP_CORE_AT_EL0) && \ | ||
49 | defined(CFG_CORE_WORKAROUND_SPECTRE_BP_SEC) && defined(ARM64) | ||
50 | long thread_user_kdata_sp_offset __nex_bss; | ||
51 | +#ifdef __clang__ | ||
52 | +#ifndef CFG_VIRTUALIZATION | ||
53 | +#pragma clang section bss=".nozi.kdata_page" | ||
54 | +#else | ||
55 | +#pragma clang section bss=".nex_nozi.kdata_page" | ||
56 | +#endif | ||
57 | +#endif | ||
58 | static uint8_t thread_user_kdata_page[ | ||
59 | ROUNDUP(sizeof(struct thread_core_local) * CFG_TEE_CORE_NB_CORE, | ||
60 | SMALL_PAGE_SIZE)] | ||
61 | __aligned(SMALL_PAGE_SIZE) | ||
62 | +#ifndef __clang__ | ||
63 | #ifndef CFG_NS_VIRTUALIZATION | ||
64 | - __section(".nozi.kdata_page"); | ||
65 | + __section(".nozi.kdata_page") | ||
66 | #else | ||
67 | - __section(".nex_nozi.kdata_page"); | ||
68 | + __section(".nex_nozi.kdata_page") | ||
69 | #endif | ||
70 | +#endif | ||
71 | + ; | ||
72 | +#endif | ||
73 | + | ||
74 | +/* reset BSS section to default ( .bss ) */ | ||
75 | +#ifdef __clang__ | ||
76 | +#pragma clang section bss="" | ||
77 | #endif | ||
78 | |||
79 | #ifdef ARM32 | ||
80 | diff --git a/core/arch/arm/mm/core_mmu_lpae.c b/core/arch/arm/mm/core_mmu_lpae.c | ||
81 | index 4c8b85e39..1885e1d3f 100644 | ||
82 | --- a/core/arch/arm/mm/core_mmu_lpae.c | ||
83 | +++ b/core/arch/arm/mm/core_mmu_lpae.c | ||
84 | @@ -234,19 +234,46 @@ typedef uint16_t l1_idx_t; | ||
85 | typedef uint64_t base_xlat_tbls_t[CFG_TEE_CORE_NB_CORE][NUM_BASE_LEVEL_ENTRIES]; | ||
86 | typedef uint64_t xlat_tbl_t[XLAT_TABLE_ENTRIES]; | ||
87 | |||
88 | +#ifdef __clang__ | ||
89 | +#pragma clang section bss=".nozi.mmu.base_table" | ||
90 | +#endif | ||
91 | static base_xlat_tbls_t base_xlation_table[NUM_BASE_TABLES] | ||
92 | __aligned(NUM_BASE_LEVEL_ENTRIES * XLAT_ENTRY_SIZE) | ||
93 | - __section(".nozi.mmu.base_table"); | ||
94 | +#ifndef __clang__ | ||
95 | + __section(".nozi.mmu.base_table") | ||
96 | +#endif | ||
97 | +; | ||
98 | +#ifdef __clang__ | ||
99 | +#pragma clang section bss="" | ||
100 | +#endif | ||
101 | |||
102 | +#ifdef __clang__ | ||
103 | +#pragma clang section bss=".nozi.mmu.l2" | ||
104 | +#endif | ||
105 | static xlat_tbl_t xlat_tables[MAX_XLAT_TABLES] | ||
106 | - __aligned(XLAT_TABLE_SIZE) __section(".nozi.mmu.l2"); | ||
107 | + __aligned(XLAT_TABLE_SIZE) | ||
108 | +#ifndef __clang__ | ||
109 | + __section(".nozi.mmu.l2") | ||
110 | +#endif | ||
111 | +; | ||
112 | +#ifdef __clang__ | ||
113 | +#pragma clang section bss="" | ||
114 | +#endif | ||
115 | |||
116 | #define XLAT_TABLES_SIZE (sizeof(xlat_tbl_t) * MAX_XLAT_TABLES) | ||
117 | |||
118 | +#ifdef __clang__ | ||
119 | +#pragma clang section bss=".nozi.mmu.l2" | ||
120 | +#endif | ||
121 | /* MMU L2 table for TAs, one for each thread */ | ||
122 | static xlat_tbl_t xlat_tables_ul1[CFG_NUM_THREADS] | ||
123 | - __aligned(XLAT_TABLE_SIZE) __section(".nozi.mmu.l2"); | ||
124 | - | ||
125 | +#ifndef __clang__ | ||
126 | + __aligned(XLAT_TABLE_SIZE) __section(".nozi.mmu.l2") | ||
127 | +#endif | ||
128 | +; | ||
129 | +#ifdef __clang__ | ||
130 | +#pragma clang section bss="" | ||
131 | +#endif | ||
132 | /* | ||
133 | * TAs page table entry inside a level 1 page table. | ||
134 | * | ||
135 | diff --git a/core/arch/arm/mm/core_mmu_v7.c b/core/arch/arm/mm/core_mmu_v7.c | ||
136 | index 61e703da8..1960c08ca 100644 | ||
137 | --- a/core/arch/arm/mm/core_mmu_v7.c | ||
138 | +++ b/core/arch/arm/mm/core_mmu_v7.c | ||
139 | @@ -204,16 +204,46 @@ typedef uint32_t l1_xlat_tbl_t[NUM_L1_ENTRIES]; | ||
140 | typedef uint32_t l2_xlat_tbl_t[NUM_L2_ENTRIES]; | ||
141 | typedef uint32_t ul1_xlat_tbl_t[NUM_UL1_ENTRIES]; | ||
142 | |||
143 | +#ifdef __clang__ | ||
144 | +#pragma clang section bss=".nozi.mmu.l1" | ||
145 | +#endif | ||
146 | static l1_xlat_tbl_t main_mmu_l1_ttb | ||
147 | - __aligned(L1_ALIGNMENT) __section(".nozi.mmu.l1"); | ||
148 | + __aligned(L1_ALIGNMENT) | ||
149 | +#ifndef __clang__ | ||
150 | + __section(".nozi.mmu.l1") | ||
151 | +#endif | ||
152 | +; | ||
153 | +#ifdef __clang__ | ||
154 | +#pragma clang section bss="" | ||
155 | +#endif | ||
156 | |||
157 | /* L2 MMU tables */ | ||
158 | +#ifdef __clang__ | ||
159 | +#pragma clang section bss=".nozi.mmu.l2" | ||
160 | +#endif | ||
161 | static l2_xlat_tbl_t main_mmu_l2_ttb[MAX_XLAT_TABLES] | ||
162 | - __aligned(L2_ALIGNMENT) __section(".nozi.mmu.l2"); | ||
163 | + __aligned(L2_ALIGNMENT) | ||
164 | +#ifndef __clang__ | ||
165 | + __section(".nozi.mmu.l2") | ||
166 | +#endif | ||
167 | +; | ||
168 | +#ifdef __clang__ | ||
169 | +#pragma clang section bss="" | ||
170 | +#endif | ||
171 | |||
172 | /* MMU L1 table for TAs, one for each thread */ | ||
173 | +#ifdef __clang__ | ||
174 | +#pragma clang section bss=".nozi.mmu.ul1" | ||
175 | +#endif | ||
176 | static ul1_xlat_tbl_t main_mmu_ul1_ttb[CFG_NUM_THREADS] | ||
177 | - __aligned(UL1_ALIGNMENT) __section(".nozi.mmu.ul1"); | ||
178 | + __aligned(UL1_ALIGNMENT) | ||
179 | +#ifndef __clang__ | ||
180 | + __section(".nozi.mmu.ul1") | ||
181 | +#endif | ||
182 | +; | ||
183 | +#ifdef __clang__ | ||
184 | +#pragma clang section bss="" | ||
185 | +#endif | ||
186 | |||
187 | struct mmu_partition { | ||
188 | l1_xlat_tbl_t *l1_table; | ||
189 | diff --git a/core/kernel/thread.c b/core/kernel/thread.c | ||
190 | index 2a1f22dce..5516b6771 100644 | ||
191 | --- a/core/kernel/thread.c | ||
192 | +++ b/core/kernel/thread.c | ||
193 | @@ -39,13 +39,24 @@ static uint32_t end_canary_value = 0xababab00; | ||
194 | name[stack_num][sizeof(name[stack_num]) / sizeof(uint32_t) - 1] | ||
195 | #endif | ||
196 | |||
197 | +#define DO_PRAGMA(x) _Pragma (#x) | ||
198 | + | ||
199 | +#ifdef __clang__ | ||
200 | +#define DECLARE_STACK(name, num_stacks, stack_size, linkage) \ | ||
201 | +DO_PRAGMA (clang section bss=".nozi_stack." #name) \ | ||
202 | +linkage uint32_t name[num_stacks] \ | ||
203 | + [ROUNDUP(stack_size + STACK_CANARY_SIZE + STACK_CHECK_EXTRA, \ | ||
204 | + STACK_ALIGNMENT) / sizeof(uint32_t)] \ | ||
205 | + __attribute__((aligned(STACK_ALIGNMENT))); \ | ||
206 | +DO_PRAGMA(clang section bss="") | ||
207 | +#else | ||
208 | #define DECLARE_STACK(name, num_stacks, stack_size, linkage) \ | ||
209 | linkage uint32_t name[num_stacks] \ | ||
210 | [ROUNDUP(stack_size + STACK_CANARY_SIZE + STACK_CHECK_EXTRA, \ | ||
211 | STACK_ALIGNMENT) / sizeof(uint32_t)] \ | ||
212 | __attribute__((section(".nozi_stack." # name), \ | ||
213 | aligned(STACK_ALIGNMENT))) | ||
214 | - | ||
215 | +#endif | ||
216 | #define GET_STACK(stack) ((vaddr_t)(stack) + STACK_SIZE(stack)) | ||
217 | |||
218 | DECLARE_STACK(stack_tmp, CFG_TEE_CORE_NB_CORE, STACK_TMP_SIZE, | ||
219 | diff --git a/core/mm/pgt_cache.c b/core/mm/pgt_cache.c | ||
220 | index 79553c6d2..b9efdf427 100644 | ||
221 | --- a/core/mm/pgt_cache.c | ||
222 | +++ b/core/mm/pgt_cache.c | ||
223 | @@ -410,8 +410,18 @@ void pgt_init(void) | ||
224 | * has a large alignment, while .bss has a small alignment. The current | ||
225 | * link script is optimized for small alignment in .bss | ||
226 | */ | ||
227 | +#ifdef __clang__ | ||
228 | +#pragma clang section bss=".nozi.mmu.l2" | ||
229 | +#endif | ||
230 | static uint8_t pgt_tables[PGT_CACHE_SIZE][PGT_SIZE] | ||
231 | - __aligned(PGT_SIZE) __section(".nozi.pgt_cache"); | ||
232 | + __aligned(PGT_SIZE) | ||
233 | +#ifndef __clang__ | ||
234 | + __section(".nozi.pgt_cache") | ||
235 | +#endif | ||
236 | + ; | ||
237 | +#ifdef __clang__ | ||
238 | +#pragma clang section bss="" | ||
239 | +#endif | ||
240 | size_t n; | ||
241 | |||
242 | for (n = 0; n < ARRAY_SIZE(pgt_tables); n++) { | ||
243 | -- | ||
244 | 2.43.2 | ||
245 | |||
diff --git a/recipes-security/optee-imx/optee-os/0002-optee-enable-clang-support.patch b/recipes-security/optee-imx/optee-os/0002-optee-enable-clang-support.patch deleted file mode 100644 index dbc53542..00000000 --- a/recipes-security/optee-imx/optee-os/0002-optee-enable-clang-support.patch +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | From 2ba573c9763329fbfdfacc8393d565ab747cac4d Mon Sep 17 00:00:00 2001 | ||
2 | From: Brett Warren <brett.warren@arm.com> | ||
3 | Date: Wed, 23 Sep 2020 09:27:34 +0100 | ||
4 | Subject: [PATCH 2/4] optee: enable clang support | ||
5 | |||
6 | When compiling with clang, the LIBGCC_LOCATE_CFLAG variable used | ||
7 | to provide a sysroot wasn't included, which results in not locating | ||
8 | compiler-rt. This is mitigated by including the variable as ammended. | ||
9 | |||
10 | Upstream-Status: Pending | ||
11 | ChangeId: 8ba69a4b2eb8ebaa047cb266c9aa6c2c3da45701 | ||
12 | Signed-off-by: Brett Warren <brett.warren@arm.com> | ||
13 | Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> | ||
14 | --- | ||
15 | |||
16 | mk/clang.mk | 2 +- | ||
17 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
18 | |||
19 | diff --git a/mk/clang.mk b/mk/clang.mk | ||
20 | index a045beee8..1ebe2f702 100644 | ||
21 | --- a/mk/clang.mk | ||
22 | +++ b/mk/clang.mk | ||
23 | @@ -30,7 +30,7 @@ comp-cflags-warns-clang := -Wno-language-extension-token \ | ||
24 | |||
25 | # Note, use the compiler runtime library (libclang_rt.builtins.*.a) instead of | ||
26 | # libgcc for clang | ||
27 | -libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \ | ||
28 | +libgcc$(sm) := $(shell $(CC$(sm)) $(LIBGCC_LOCATE_CFLAGS) $(CFLAGS$(arch-bits-$(sm))) \ | ||
29 | -rtlib=compiler-rt -print-libgcc-file-name 2> /dev/null) | ||
30 | |||
31 | # Core ASLR relies on the executable being ready to run from its preferred load | ||
32 | -- | ||
33 | 2.43.2 | ||
34 | |||
diff --git a/recipes-security/optee-imx/optee-os_4.4.0.imx.bb b/recipes-security/optee-imx/optee-os_4.4.0.imx.bb index 5ff12a59..dc6d3901 100644 --- a/recipes-security/optee-imx/optee-os_4.4.0.imx.bb +++ b/recipes-security/optee-imx/optee-os_4.4.0.imx.bb | |||
@@ -2,9 +2,5 @@ | |||
2 | 2 | ||
3 | require optee-os-fslc-imx.inc | 3 | require optee-os-fslc-imx.inc |
4 | 4 | ||
5 | SRC_URI += " \ | ||
6 | file://0001-core-Define-section-attributes-for-clang.patch \ | ||
7 | file://0002-optee-enable-clang-support.patch \ | ||
8 | " | ||
9 | SRCBRANCH = "lf-6.6.52_2.2.0" | 5 | SRCBRANCH = "lf-6.6.52_2.2.0" |
10 | SRCREV = "60beb308810f9561a67fdb435388a64c85eb6dcb" | 6 | SRCREV = "60beb308810f9561a67fdb435388a64c85eb6dcb" |