Skip to content

Commit e716131

Browse files
DavidMCerdeiradanielRep
authored andcommitted
feat(clang): add support for armv8 clang
This commit fixes some issues when using clang: - remove .directive .func which is not recognized by clang assembler; - make gtlb_page_tables as no data to avoid section type mismatch; - remove general-regs-only in aarch32 this is not recognized by the clang assembler - remove mov instructions with flexible second operand since they are not recognized by the clang assembler; Signed-off-by: Bruno Sa <[email protected]> Signed-off-by: David Cerdeira <[email protected]>
1 parent aacd19c commit e716131

File tree

10 files changed

+45
-51
lines changed

10 files changed

+45
-51
lines changed

src/arch/armv8/aarch32/arch_sub.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
CROSS_COMPILE ?= arm-none-eabi-
55

66
arch-cppflags+=-DAARCH32
7-
arch-cflags+=
7+
arch-cflags+= -mfloat-abi=soft
88
arch-asflags+=
99
arch-ldflags+=
10+
11+
clang_arch_target:=arm

src/arch/armv8/aarch32/boot.S

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ _set_master_cpu:
184184
/***** Helper functions for boot code. ******/
185185

186186
.global boot_clear
187-
.func boot_clear
188187
boot_clear:
189188
2:
190189
mov r8, #0
@@ -195,15 +194,13 @@ boot_clear:
195194
b 2b
196195
1:
197196
bx lr
198-
.endfunc
199197

200198
/*
201199
* Code adapted from "Application Note Bare-metal Boot Code for ARMv8-A Processors - Version 1.0"
202200
*
203201
* r0 - cache level to be invalidated (0 - dl1$, 1 - il1$)
204202
*/
205203
.global boot_cache_invalidate
206-
.func boot_cache_invalidate
207204
boot_cache_invalidate:
208205
mcr p15, 2, r0, c0, c0, 0 // write CSSELR (cache size selection)
209206
mrc p15, 1, r4, c0, c0, 0 // read CCSIDR (cache size id)
@@ -230,5 +227,4 @@ set_loop:
230227
cmp r5, r3 // last way reached yet?
231228
ble way_loop // if not, iterate way_loop
232229
bx lr
233-
.endfunc
234230

src/arch/armv8/aarch32/inc/arch/spinlock.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ static inline void spin_lock(spinlock_t* lock)
3636
__asm__ volatile(
3737
/* Get ticket */
3838
"1:\n\t"
39-
"ldaex %r0, %3\n\t"
40-
"add %r1, %r0, #1\n\t"
41-
"strex %r2, %r1, %3\n\t"
42-
"cmp %r2, #0\n\t"
39+
"ldaex %0, %3\n\t"
40+
"add %1, %0, #1\n\t"
41+
"strex %2, %1, %3\n\t"
42+
"cmp %2, #0\n\t"
4343
"bne 1b \n\t"
4444
/* Wait for your turn */
4545
"2:\n\t"
46-
"ldr %r1, %4\n\t"
47-
"cmp %r0, %r1\n\t"
46+
"ldr %1, %4\n\t"
47+
"cmp %0, %1\n\t"
4848
"beq 3f\n\t"
4949
"wfe \n\t"
5050
"b 2b\n\t"
@@ -58,9 +58,9 @@ static inline void spin_unlock(spinlock_t* lock)
5858

5959
__asm__ volatile(
6060
/* increment to next ticket */
61-
"ldr %r0, %1\n\t"
62-
"add %r0, %r0, #1\n\t"
63-
"stl %r0, %1\n\t"
61+
"ldr %0, %1\n\t"
62+
"add %0, %0, #1\n\t"
63+
"stl %0, %1\n\t"
6464
"dsb ish\n\t"
6565
"sev\n\t" : "=&r"(temp) : "Q"(lock->next) : "memory");
6666
}

src/arch/armv8/aarch64/arch_sub.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ arch-cppflags+=-DAARCH64
77
arch-cflags+= -mcmodel=large -mstrict-align
88
arch-asflags+=
99
arch-ldflags+=
10+
11+
clang_arch_target:=aarch64

src/arch/armv8/aarch64/boot.S

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ _reset_handler:
6262
* this early in the initialization.
6363
*/
6464

65-
mov x3, x0, lsr #8
65+
lsr x3, x0, #8
6666
and x3, x3, 0xff
6767
adr x4, platform
6868
ldr x4, [x4, PLAT_ARCH_OFF+PLAT_ARCH_CLUSTERS_OFF+PLAT_CLUSTERS_CORES_NUM_OFF]
@@ -180,7 +180,6 @@ _set_master_cpu:
180180
/***** Helper functions for boot code. ******/
181181

182182
.global boot_clear
183-
.func boot_clear
184183
boot_clear:
185184
2:
186185
cmp x16, x17
@@ -189,15 +188,13 @@ boot_clear:
189188
b 2b
190189
1:
191190
ret
192-
.endfunc
193191

194192
/*
195193
* Code taken from "Application Note Bare-metal Boot Code for ARMv8-A Processors - Version 1.0"
196194
*
197195
* x0 - cache level to be invalidated (0 - dl1$, 1 - il1$, 2 - l2$)
198196
*/
199197
.global boot_cache_invalidate
200-
.func boot_cache_invalidate
201198
boot_cache_invalidate:
202199
msr csselr_el1, x0
203200
mrs x4, ccsidr_el1 // read cache size id.
@@ -224,6 +221,4 @@ set_loop:
224221
cmp x5, x3 // last way reached yet?
225222
ble way_loop // if not, iterate way_loop
226223
ret
227-
.endfunc
228-
229224

src/arch/armv8/arch.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ arch_profile_sub_dir:=$(arch_profile_dir)/$(ARCH_SUB)
1515
src_dirs+=$(arch_profile_sub_dir)
1616

1717
arch-cppflags+=-DGIC_VERSION=$(GIC_VERSION)
18+
ifeq ($(CC_IS_GCC),y)
1819
arch-cflags+=-mgeneral-regs-only
20+
endif
1921
arch-asflags+=
2022
arch-ldflags+=

src/arch/armv8/armv8-a/aarch64/boot.S

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@ boot_arch_profile_init:
2424
ldr x18, =extra_allocated_phys_mem
2525

2626
/* Disable caches and MMU */
27-
mrs x3, SCTLR_EL2
28-
bic x3, x3, #0x7
29-
msr SCTLR_EL2, x3
30-
27+
mrs x3, SCTLR_EL2
28+
bic x3, x3, #0x7
29+
msr SCTLR_EL2, x3
30+
3131
/* Skip initialy global page tables setup if not bsp (boot cpu) */
3232
cbnz x9, wait_for_bsp
3333

34-
adr x16, _page_tables_start
35-
adr x17, _page_tables_end
34+
adr x16, _page_tables_start
35+
adr x17, _page_tables_end
3636
add x16, x16, x18
3737
add x17, x17, x18
38-
bl boot_clear
38+
bl boot_clear
3939

4040
/* Set temporary flat mapping to switch to VAS. */
4141

4242
adr x4, root_l1_flat_pt
4343
add x4, x4, x18
44-
PTE_INDEX_ASM x5, x1, 1
44+
PTE_INDEX_ASM x5, x1, 1
4545
add x6, x1, #(PTE_HYP_FLAGS | PTE_SUPERPAGE)
4646
str x6, [x4, x5]
47-
47+
4848
/* Set global root mappings for hypervisor image */
4949

5050
adr x4, root_l1_pt
@@ -96,7 +96,7 @@ boot_arch_profile_init:
9696
sev
9797
b map_cpu
9898

99-
wait_for_bsp:
99+
wait_for_bsp:
100100
/* wait fot the bsp to finish up global mappings */
101101
wfe
102102
ldr x4, _boot_barrier
@@ -110,28 +110,28 @@ map_cpu:
110110
* x5 -> pte index
111111
* x6 -> phys addr
112112
* x7 -> virt addr
113-
* x8 -> aux
113+
* x8 -> aux
114114
*/
115115

116116
/* get cpu root pt */
117117
adrp x3, _dmem_phys_beg
118118
mov x8, #(CPU_SIZE + (PT_SIZE*PT_LVLS))
119119
madd x3, x0, x8, x3
120-
121-
mov x16, x3
120+
121+
mov x16, x3
122122
add x17, x3, x8
123123
bl boot_clear
124124

125125
/* Get pointer to root page table */
126126
add x4, x3, #CPU_SIZE
127127

128128
/* map original bootstrap flat mappings */
129-
PTE_INDEX_ASM x5, x1, 0
129+
PTE_INDEX_ASM x5, x1, 0
130130
adr x6, root_l1_flat_pt
131131
add x6, x6, x18
132132
add x6, x6, #(PTE_HYP_FLAGS | PTE_TABLE)
133133
str x6, [x4, x5]
134-
134+
135135
ldr x5, =(PTE_INDEX(0, BAO_VAS_BASE)*8)
136136
adr x6, root_l1_pt
137137
add x6, x6, x18
@@ -174,7 +174,7 @@ setup_cpu:
174174
/**
175175
* The operation is purposely commented out. We are assuming monitor code already enabled smp
176176
* coherency.
177-
*/
177+
*/
178178

179179
/* setup translation configurations */
180180
ldr x3, =TCR_EL2_DFLT
@@ -194,7 +194,7 @@ setup_cpu:
194194
add x3, x3, #CPU_SIZE
195195
msr TTBR0_EL2, x3
196196

197-
/**
197+
/**
198198
* TODO: set implementation defined registers such as ACTLR or AMAIR. Maybe define a macro for
199199
* this in a implementation oriented directory inside arch.
200200
*/
@@ -208,11 +208,11 @@ setup_cpu:
208208
/* Enable MMU and caches */
209209
ldr x4, =(SCTLR_RES1 | SCTLR_M | SCTLR_C | SCTLR_I)
210210
msr SCTLR_EL2, x4
211-
211+
212212
tlbi alle2
213213
dsb nsh
214214
isb
215-
215+
216216
br x5
217217

218218
_enter_vas:
@@ -224,7 +224,7 @@ _enter_vas:
224224
/* Remove temporary mapping - the L1 page holding it leaks */
225225
ldr x4, =BAO_CPU_BASE
226226
add x4, x4, #CPU_SIZE
227-
PTE_INDEX_ASM x5, x1, 0
227+
PTE_INDEX_ASM x5, x1, 0
228228
str xzr, [x4, x5]
229229

230230
tlbi alle2
@@ -237,7 +237,6 @@ _enter_vas:
237237
ret
238238

239239
.global psci_boot_entry
240-
.func psci_boot_entry
241240
psci_boot_entry:
242241
warm_boot:
243242

@@ -272,7 +271,7 @@ warm_boot:
272271
/* map original bootstrap flat mappings */
273272
mrs x3, TTBR0_EL2
274273
adrp x1, _image_start
275-
PTE_INDEX_ASM x1, x1, 0
274+
PTE_INDEX_ASM x1, x1, 0
276275
add x3, x3, x1
277276
dc civac, x3 //we invalidated l1$, but make sure the pte is not in l2$
278277
add x5, x5, #(PTE_HYP_FLAGS | PTE_TABLE)
@@ -282,7 +281,7 @@ warm_boot:
282281
ldr x3, =_hyp_vector_table
283282
msr VBAR_EL2, x3
284283

285-
tlbi alle2
284+
tlbi alle2
286285
dsb nsh
287286
isb
288287

@@ -292,17 +291,17 @@ warm_boot:
292291

293292
dsb nsh
294293
isb
295-
294+
296295
ldr x5, =_enter_vas_warm
297-
br x5
296+
br x5
298297

299298
_enter_vas_warm:
300299
/* Unmap bootstrat flat mappings */
301300
ldr x4, =BAO_CPU_BASE
302301
add x3, x4, #(CPU_STACK_OFF+CPU_STACK_SIZE)
303302

304303
add x4, x4, #CPU_SIZE
305-
PTE_INDEX_ASM x5, x1, 0
304+
PTE_INDEX_ASM x5, x1, 0
306305
str xzr, [x4, x5]
307306
tlbi alle2
308307
dsb nsh
@@ -314,4 +313,3 @@ _enter_vas_warm:
314313
bl psci_wake
315314
b .
316315

317-
.endfunc

src/arch/armv8/armv8-a/pagetables.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <arch/page_table.h>
77

8-
.section .glb_page_tables, "aw"
8+
.section .glb_page_tables, "aw", %nobits
99

1010
.globl root_l1_pt
1111
.balign PAGE_SIZE, 0

src/arch/armv8/armv8-r/profile.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## Copyright (c) Bao Project and Contributors. All rights reserved.
33

44
arch-cppflags+=
5-
arch-cflags+=-march=armv8-r -mgeneral-regs-only
5+
arch-cflags+=-march=armv8-r
66
arch-asflags+=
77
arch-ldflags+=
88

src/arch/armv8/vgic.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ bool vgic_add_lr(struct vcpu* vcpu, struct vgic_int* interrupt)
331331
if (lr_ind < 0) {
332332
unsigned min_prio_pend = interrupt->prio, min_prio_act = interrupt->prio;
333333
unsigned min_id_act = interrupt->id, min_id_pend = interrupt->id;
334-
size_t pend_found = 0, act_found = 0;
334+
size_t pend_found = 0;
335335
ssize_t pend_ind = -1, act_ind = -1;
336336

337337
for (size_t i = 0; i < NUM_LRS; i++) {
@@ -349,7 +349,6 @@ bool vgic_add_lr(struct vcpu* vcpu, struct vgic_int* interrupt)
349349
min_prio_act = lr_prio;
350350
act_ind = (ssize_t)i;
351351
}
352-
act_found++;
353352
} else if (lr_state & GICH_LR_STATE_PND) {
354353
if (lr_prio > min_prio_pend || (lr_prio == min_prio_pend && lr_id > min_id_pend)) {
355354
min_id_pend = lr_id;

0 commit comments

Comments
 (0)