Skip to content

Commit ceac389

Browse files
authored
Merge pull request #245 from smartobjectoriented/243-avz-issues-when-booting-on-rpi4
243 avz issues when booting on rpi4
2 parents a325df7 + da72097 commit ceac389

17 files changed

Lines changed: 171 additions & 78 deletions

File tree

doc/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@
123123
try:
124124
import sphinx_rtd_theme
125125
html_theme = 'sphinx_rtd_theme'
126-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
127126
def setup(app):
128127
# app.add_stylesheet('style.css')
129128
app.add_css_file('style.css')

doc/source/user_guide.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ prevent annoying warnings:
3838
3939
sudo apt-get install bison flex
4040
41-
Files and directroy organisation
41+
Files and directory organization
4242
********************************
4343

4444
SO3 root directory (main subdirs)::
@@ -67,7 +67,7 @@ SO3 root directory (main subdirs)::
6767
Build of the environment
6868
************************
6969

70-
kernel toolchain
70+
Kernel toolchain
7171
================
7272

7373
We use the ``arm-none-eabi`` toolchain which has no dependencies on a libc.
@@ -78,22 +78,22 @@ The following package can be installed:
7878
7979
apt install gcc-arm-none-eabi
8080
81-
usr-space toolchain
82-
===================
81+
User space toolchain
82+
====================
8383

84-
The usr-space uses MUSL as libc. The Musl toolchains can be generated with
84+
The user space uses MUSL as libc. The Musl toolchains can be generated with
8585
``toolchains/build-toolchain.sh`` script.
8686

8787
.. code-block:: bash
8888
89-
$ ./build-toolchain.sh
89+
$ sudo ./build-toolchain.sh
9090
9191
By default, it generates ``aarch64-linux-musl`` and ``arm-linux-musleabihf``
9292
folder in the ``toolchains`` directory
9393

9494
.. note::
9595

96-
The output directory (by default ``toolchains`` floder) can be changed by setting
96+
The output directory (by default ``toolchains`` folder) can be changed by setting
9797
the ``OUTPUT_PATH`` variable in the ``build-toolchain.sh`` script
9898

9999
Quick setup & early test
@@ -309,4 +309,4 @@ The, starting the execution of the container:
309309
310310
311311
312-
312+

so3/arch/arm64/domain.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ void __setup_dom_pgtable(struct domain *d, addr_t paddr_start, unsigned long map
116116
__create_mapping(new_pt, memslot[slotID].ipa_addr, paddr_start, map_size, false, S2);
117117

118118
if (d->avz_shared->domID == DOMID_AGENCY)
119-
do_ipamap(new_pt, linux_ipamap, ARRAY_SIZE(linux_ipamap));
119+
do_ipamap(new_pt, agency_ipamap, ARRAY_SIZE(agency_ipamap));
120120
else
121-
do_ipamap(new_pt, guest_ipamap, ARRAY_SIZE(guest_ipamap));
121+
do_ipamap(new_pt, capsule_ipamap, ARRAY_SIZE(capsule_ipamap));
122122

123123
/* Map the shared page in the IPA space; the shared page is located right after the domain area
124124
* in the IPA space, and if any, the RT shared page follows the shared page (in IPA space).

so3/arch/arm64/exception.S

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,17 @@ ENTRY(__vectors)
209209

210210
#ifdef CONFIG_CPU_SPIN_TABLE
211211

212-
ENTRY(pre_ret_to_el1_with_spin)
212+
ENTRY(pre_ret_to_el1_spin)
213213

214-
mov x1, x0
214+
mov x1, x0
215215
str xzr, [x1]
216216
1:
217217
wfe
218218
ldr x0, [x1]
219219

220-
cbz x0, 1b
220+
cbz x0, 1b
221221

222-
// Branch to the given address
222+
// Branch to the given address
223223
msr elr_el2, x0
224224

225225
// Set the CPU in EL1 mode to proceed with
@@ -239,7 +239,7 @@ ENTRY(pre_ret_to_el1_with_spin)
239239
mov x2, #0
240240
mov x3, #0
241241

242-
// Ready to jump into the Linux domain...
242+
// Ready to jump into the Agency domain...
243243

244244
eret
245245

@@ -264,7 +264,7 @@ ENTRY(pre_ret_to_el1)
264264

265265
wfi
266266

267-
ldr x0, cpu_entrypoint
267+
ldr x0, cpu_entrypoint
268268
msr elr_el2, x0
269269

270270
// Set the CPU in EL1 mode to proceed with

so3/arch/arm64/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ void __switch_domain_to(struct domain *prev, struct domain *next);
12631263
void ret_to_user(void);
12641264
void pre_ret_to_user(void);
12651265
void pre_ret_to_el1(void);
1266-
void pre_ret_to_el1_with_spin(addr_t release_addr);
1266+
void pre_ret_to_el1_spin(addr_t release_addr);
12671267

12681268
#endif /* CONFIG_AVZ */
12691269

so3/arch/arm64/rpi4_64/include/mach/ipamap.h

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,51 +21,37 @@
2121

2222
#include <asm/mmu.h>
2323

24-
ipamap_t ipamap[] = {
24+
ipamap_t agency_ipamap[] = {
25+
26+
/* I/O Memory space*/
2527
{
2628
.ipa_addr = 0xf0000000,
2729
.phys_addr = 0xf0000000,
2830
.size = 0x10000000,
2931
},
30-
{
31-
.ipa_addr = 0x1faf0000,
32-
.phys_addr = 0x1faf0000,
33-
.size = 0x1000,
34-
},
35-
{
36-
.ipa_addr = 0x1faf1000,
37-
.phys_addr = 0x1faf1000,
38-
.size = 0x9000,
39-
},
40-
{
41-
.ipa_addr = 0x1fafa000,
42-
.phys_addr = 0x1fafa000,
43-
.size = 0x2000,
44-
},
45-
{
46-
.ipa_addr = 0x1fafc000,
47-
.phys_addr = 0x1fafc000,
48-
.size = 0x2000,
49-
},
50-
{
51-
.ipa_addr = 0x1fafe000,
52-
.phys_addr = 0x1fafe000,
53-
.size = 0x2000,
54-
},
32+
33+
/* Null pointer exception */
5534
{
5635
.ipa_addr = 0x0,
5736
.phys_addr = 0x0,
5837
.size = 0x1000,
5938
},
39+
};
40+
41+
/**
42+
* In the guest environment, the access to the GIC distributor must lead to a data abort
43+
* which will be trapped and handled by the hypervisor.
44+
*/
45+
46+
ipamap_t capsule_ipamap[] = {
47+
6048
{
61-
.ipa_addr = 0x50000000,
62-
.phys_addr = 0x50000000,
63-
.size = 0x10000000,
64-
},
65-
{
66-
.ipa_addr = 0x600000000,
67-
.phys_addr = 0x600000000,
68-
.size = 0x1000,
49+
/* Only mapping the CPU interface to the vGIC CPU interface.
50+
* Access to the distributor must lead to a trap and be handled by the hypervisor.
51+
*/
52+
.ipa_addr = 0x08010000,
53+
.phys_addr = 0x08040000,
54+
.size = 0x10000,
6955
},
7056
};
7157

so3/arch/arm64/virt64/include/mach/ipamap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include <asm/mmu.h>
2323

24-
ipamap_t linux_ipamap[] = {
24+
ipamap_t agency_ipamap[] = {
2525
{
2626
.ipa_addr = 0x08000000,
2727
.phys_addr = 0x08000000,
@@ -34,7 +34,7 @@ ipamap_t linux_ipamap[] = {
3434
* which will be trapped and handled by the hypervisor.
3535
*/
3636

37-
ipamap_t guest_ipamap[] = {
37+
ipamap_t capsule_ipamap[] = {
3838

3939
{
4040
/* Only mapping the CPU interface to the vGIC CPU interface.

so3/avz/kernel/smp.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,25 @@ void secondary_start_kernel(void)
114114
#ifdef CONFIG_CPU_SPIN_TABLE
115115
switch (cpu) {
116116
case 1:
117-
pre_ret_to_el1_with_spin(CPU1_RELEASE_ADDR);
117+
pre_ret_to_el1_spin(CPU1_RELEASE_ADDR);
118118
break;
119119
case 2:
120-
pre_ret_to_el1_with_spin(CPU2_RELEASE_ADDR);
120+
pre_ret_to_el1_spin(CPU2_RELEASE_ADDR);
121121
break;
122122
case 3:
123-
pre_ret_to_el1_with_spin(CPU3_RELEASE_ADDR);
123+
pre_ret_to_el1_spin(CPU3_RELEASE_ADDR);
124124
break;
125125
default:
126126
printk("%s: trying to start CPU %d that is not supported.\n", __func__, cpu);
127127
}
128128
#endif
129129

130+
#ifdef CONFIG_CPU_PSCI
130131
#ifdef CONFIG_SOO
131132
if (cpu != ME_CPU)
132-
#endif
133+
#endif /* CONFIG_SOO */
133134
pre_ret_to_el1();
135+
#endif /* CONFIG_CPU_PCSI */
134136

135137
secondary_timer_init();
136138

so3/devices/fdt.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2014-2019 Daniel Rossier <daniel.rossier@heig-vd.ch>
2+
* Copyright (C) 2014-2026 Daniel Rossier <daniel.rossier@heig-vd.ch>
33
*
44
*
55
* This program is free software; you can redistribute it and/or modify
@@ -55,7 +55,13 @@ static void init_dev_info(dev_t *dev)
5555
dev->fdt = 0;
5656
}
5757

58-
/* Get memory informations from a device tree */
58+
/**
59+
* @brief Get memory informations from a device tree
60+
*
61+
* @param fdt Virtual address of the device tree
62+
* @param info Memory info structure which will be filled up by this function
63+
* @return int Offset of the memory node in the device tree
64+
*/
5965
int get_mem_info(const void *fdt, mem_info_t *info)
6066
{
6167
int offset;
@@ -81,14 +87,17 @@ int get_mem_info(const void *fdt, mem_info_t *info)
8187

8288
/* For some platform, address-cells and size-cells are set to 2 (64-bit)
8389
* even for a 32-bit platform, probably to support LPAE.
90+
* Additionally, on Raspberry Pi 4, the device tree has its memory node
91+
* with a 64-bit address cell and a 32-bit size cell. That's why we need
92+
* to consider a 12 bytes <reg> property.
8493
*/
8594

8695
if (prop) {
8796
if (prop_len == 8) {
8897
info->phys_base = fdt32_to_cpu(((const fdt32_t *) prop->data)[0]);
8998
info->size = fdt32_to_cpu(((const fdt32_t *) prop->data)[1]);
9099
} else {
91-
BUG_ON(prop_len != 16);
100+
BUG_ON((prop_len != 16) && (prop_len != 12));
92101

93102
/* Keep a possible conversion from 64-bit to 32-bit if the address & size are
94103
* on 64-bit for aarch32 platforms.
@@ -110,10 +119,15 @@ int get_mem_info(const void *fdt, mem_info_t *info)
110119

111120
info->phys_base = fdt64_to_cpu(val);
112121

113-
for (i = 0; i < 8; i++)
114-
*(((char *) &val) + i) = *ptr++;
115-
116-
info->size = fdt64_to_cpu(val);
122+
if (prop_len == 16) {
123+
for (i = 0; i < 8; i++)
124+
*(((char *) &val) + i) = *ptr++;
125+
info->size = fdt64_to_cpu(val);
126+
} else {
127+
for (i = 0; i < 4; i++)
128+
*(((char *) &val) + i) = *ptr++;
129+
info->size = fdt32_to_cpu(val);
130+
}
117131

118132
#endif /* !CONFIG_ARCH_ARM32 */
119133
}

so3/devices/irq/gic.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,9 @@ void gich_init(void)
431431

432432
void gicc_init(void)
433433
{
434-
unsigned int cpu = smp_processor_id();
435434
u32 bypass = 0;
436435
int i;
437436

438-
spin_lock_init(&per_cpu(intc_lock, cpu));
439-
440437
/*
441438
* Deal with the banked PPI and SGI interrupts - disable all
442439
* PPI interrupts, ensure all SGI interrupts are enabled.
@@ -659,6 +656,11 @@ static int gic_init(dev_t *dev, int fdt_offset)
659656
{
660657
const struct fdt_property *prop;
661658
int prop_len;
659+
int cpu;
660+
661+
for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++) {
662+
spin_lock_init(&per_cpu(intc_lock, cpu));
663+
}
662664

663665
gic = (gic_t *) malloc(sizeof(gic_t));
664666
BUG_ON(!gic);

0 commit comments

Comments
 (0)