Compare commits

...

18 Commits

Author SHA1 Message Date
Ivan Velickovic
08871fea6f boot: use word_t instead of paddr_t in init_kernel
Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
2025-10-21 13:11:46 +11:00
Kent McLeod
eb8f78ae06 boot: Make init_kernel arguments word sized
The kernel head.S files for RISCV and Arm assume all arguments are word
sized. Previously, the patch to boot with an additional device reserved
region (c8ef493d03) only supported aarch64
booting.

Make the 64-bit size arguments word_t width so that they continue to be
64-bit on 64bit architectures, but only 32-bit on 32-bit architectures
to stay within the word-sized argument calling convention.

None of the 32-bit platforms support memory sizes larger than 32-bit so
these dtb and reserved device regions cannot be larger than 32-bit
sized.

Signed-off-by: Kent McLeod <kent@kry10.com>
2025-10-20 12:54:32 +11:00
Kent McLeod
8a2f5022c2 aarch32,boot: Fix patched entry code for aarch32
Earlier patches add an additional dynamic reserved region defined by an
earlier stage boot loader. But the asm for aarch32 was never updated.

Now the aarch32 head.S correctly passes through the bootloader
arguments.

Signed-off-by: Kent McLeod <kent@kry10.com>
2025-10-20 10:36:17 +11:00
Ivan-Velickovic
3aafe9e0b9 Merge branch 'master' into microkit 2025-05-23 11:05:26 +10:00
Ivan-Velickovic
2aa12e5d8a Merge branch 'master' into microkit 2025-04-09 12:12:13 +10:00
Ivan-Velickovic
4b97df4c7e Merge branch 'master' into microkit 2025-03-18 11:55:04 +11:00
Ivan-Velickovic
968d8f6f97 Merge branch 'master' into microkit 2025-03-05 16:29:43 +11:00
Ivan-Velickovic
49273c155b Merge branch 'master' into microkit 2025-03-05 14:59:06 +11:00
Ivan-Velickovic
53100c623e Merge branch 'master' into microkit 2025-03-03 16:39:56 +11:00
Ivan-Velickovic
9919e7db30 Merge branch 'master' into microkit 2025-02-10 12:49:39 +11:00
Ivan-Velickovic
0383d0f468 Merge branch 'master' into microkit 2025-02-03 16:20:41 +11:00
Ivan-Velickovic
29ee490ec4 Merge remote-tracking branch 'origin/master' into microkit 2024-10-24 13:17:50 +11:00
Ivan-Velickovic
4cae30a6ef Add extra reserved region to RISC-V boot protocol
Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
2024-08-05 10:25:08 +10:00
Ivan Velickovic
0cdbffec9c Merge branch 'master' into microkit 2024-07-01 16:00:59 +10:00
Ivan Velickovic
57975d4853 Merge branch 'master' into microkit 2024-05-01 16:22:46 +10:00
Ivan Velickovic
7008430d44 Merge branch 'master' into microkit 2024-01-27 11:59:35 +11:00
Ben Leslie
92f0f3ab28 Remove python2 support for core build tools
Depedencies on Python2/3 cross support (such as six, past and future)
are removed as only Python3 is supported at this point. Fewer
external deps is a good thing.

Signed-off-by: Ben Leslie <benno@brkawy.com>
2021-11-16 01:49:36 +00:00
Ben Leslie
c8ef493d03 Update boot protocol to support extra memory 2021-09-06 04:14:08 +00:00
12 changed files with 101 additions and 35 deletions

View File

@@ -15,16 +15,18 @@
* +1 for each MODE_RESERVED region, there might be none
* +1 to allow the kernel to release its own boot data region
* +1 for a possible gap between ELF images and rootserver objects
* +1 loader specified extra memory
*/
#define MAX_NUM_FREEMEM_REG (ARRAY_SIZE(avail_p_regs) + MODE_RESERVED + 1 + 1)
#define MAX_NUM_FREEMEM_REG (ARRAY_SIZE(avail_p_regs) + MODE_RESERVED + 1 + 1 + 1)
/* The regions reserved by the boot code are:
* +1 for kernel
* +1 for device tree binary
* +1 for user image.
* +1 loader specified extra memory
* +1 for each the MODE_RESERVED region, there might be none
*/
#define NUM_RESERVED_REGIONS (3 + MODE_RESERVED)
#define NUM_RESERVED_REGIONS (4 + MODE_RESERVED)
/* The maximum number of reserved regions is:

View File

@@ -18,6 +18,8 @@ void init_kernel(
sword_t pv_offset,
vptr_t v_entry,
paddr_t dtb_addr_p,
uint32_t dtb_size
word_t dtb_size,
paddr_t extra_device_addr_p,
word_t extra_device_size
);

View File

@@ -19,8 +19,9 @@
* +1 for kernel
* +1 for device tree binary
* +1 for user image.
* +1 loader specified extra memory
*/
#define NUM_RESERVED_REGIONS 3
#define NUM_RESERVED_REGIONS 4
/* The maximum number of reserved regions is:
* +1 for each free memory region (MAX_NUM_FREEMEM_REG)

View File

@@ -20,7 +20,9 @@ void init_kernel(
sword_t pv_offset,
vptr_t v_entry,
paddr_t dtb_addr_p,
uint32_t dtb_size
word_t dtb_size,
paddr_t extra_device_addr_p,
word_t extra_device_size
#ifdef ENABLE_SMP_SUPPORT
,
word_t hart_id,

View File

@@ -51,7 +51,8 @@ bool_t provide_cap(cap_t root_cnode_cap, cap_t cap);
cap_t create_it_asid_pool(cap_t root_cnode_cap);
void write_it_pd_pts(cap_t root_cnode_cap, cap_t it_pd_cap);
void create_idle_thread(void);
bool_t create_untypeds(cap_t root_cnode_cap);
bool_t create_untypeds_for_region(cap_t root_cnode_cap, bool_t device_memory, region_t reg, seL4_SlotPos first_untyped_slot);
bool_t create_untypeds(cap_t root_cnode_cap, seL4_SlotPos first_untyped_slot);
void bi_finalise(void);
void create_domain_cap(cap_t root_cnode_cap);

View File

@@ -78,10 +78,11 @@
.section .boot.text, "ax"
BEGIN_FUNC(_start)
/*
* Get the dtb and dtb size from the elfloader stack. Do this first because
* sp might change when we switch to supervisor mode.
* Get the dtb, dtb size, extra device base and extra device size
* from the elfloader stack. Do this first because sp might change
* when we switch to supervisor mode.
*/
pop {r7, r8}
pop {r7, r8, r9, r10}
/* Supervisor/hypervisor mode, interrupts disabled */
ldr r5, =CPSR_KERNEL
@@ -164,12 +165,12 @@ BEGIN_FUNC(_start)
#endif
/* Attempt to workaround any known ARM errata. */
push {r0-r3,r7-r8}
push {r0-r3,r7-r10}
blx arm_errata
pop {r0-r3,r7-r8}
pop {r0-r3,r7-r10}
/* Put the DTB address back on the new stack for init_kernel. */
push {r7, r8}
/* Put the DTB and dev region address back on the new stack for init_kernel. */
push {r7, r8, r9, r10}
/* Call bootstrapping implemented in C with parameters:
* r0: user image physical start address
@@ -178,6 +179,8 @@ BEGIN_FUNC(_start)
* r3: user image virtual entry address
* sp[0]: DTB physical address (0 if there is none)
* sp[1]: DTB size (0 if there is none)
* sp[2]: extra device addr (0 if there is none)
* sp[3]: extra device size (0 if there is none)
*/
blx init_kernel

View File

@@ -77,9 +77,11 @@
.section .boot.text, "ax"
BEGIN_FUNC(_start)
/* Save x4 and x5 so we don't clobber it */
mov x7, x4
mov x8, x5
/* Save x4, x5, x6, x7 so we don't clobber it */
mov x14, x4
mov x15, x5
mov x16, x6
mov x17, x7
/* Make sure interrupts are disabled */
msr daifset, #DAIFSET_MASK
@@ -118,8 +120,10 @@ BEGIN_FUNC(_start)
/* Attempt to workaround any known ARM errata. */
stp x0, x1, [sp, #-16]!
stp x2, x3, [sp, #-16]!
stp x7, x8, [sp, #-16]!
stp x14, x15, [sp, #-16]!
stp x16, x17, [sp, #-16]!
bl arm_errata
ldp x6, x7, [sp], #16
ldp x4, x5, [sp], #16
ldp x2, x3, [sp], #16
ldp x0, x1, [sp], #16
@@ -131,6 +135,8 @@ BEGIN_FUNC(_start)
* x3: user image virtual entry address
* x4: DTB physical address (0 if there is none)
* x5: DTB size (0 if there is none)
* x6: extra device memory region (0 if there is none)
* x7: extra device size (0 if there is none)
*/
bl init_kernel

View File

@@ -41,6 +41,7 @@ BOOT_BSS static region_t reserved[NUM_RESERVED_REGIONS];
BOOT_CODE static bool_t arch_init_freemem(p_region_t ui_p_reg,
p_region_t dtb_p_reg,
p_region_t extra_device_p_reg,
v_region_t it_v_reg,
word_t extra_bi_size_bits)
{
@@ -60,6 +61,13 @@ BOOT_CODE static bool_t arch_init_freemem(p_region_t ui_p_reg,
index++;
}
if (extra_device_p_reg.start) {
/* the dtb region could be empty */
reserved[index].start = (pptr_t) paddr_to_pptr(extra_device_p_reg.start);
reserved[index].end = (pptr_t) paddr_to_pptr(extra_device_p_reg.end);
index++;
}
/* Reserve the user image region and the mode-reserved regions. For now,
* only one mode-reserved region is supported, because this is all that is
* needed.
@@ -337,7 +345,9 @@ static BOOT_CODE bool_t try_init_kernel(
sword_t pv_offset,
vptr_t v_entry,
paddr_t dtb_phys_addr,
word_t dtb_size
word_t dtb_size,
paddr_t extra_device_addr_start,
word_t extra_device_size
)
{
cap_t root_cnode_cap;
@@ -347,6 +357,9 @@ static BOOT_CODE bool_t try_init_kernel(
p_region_t ui_p_reg = (p_region_t) {
ui_p_reg_start, ui_p_reg_end
};
p_region_t extra_device_p_reg = (p_region_t) {
extra_device_addr_start, extra_device_addr_start + extra_device_size
};
region_t ui_reg = paddr_to_pptr_reg(ui_p_reg);
word_t extra_bi_size = 0;
pptr_t extra_bi_offset = 0;
@@ -355,6 +368,7 @@ static BOOT_CODE bool_t try_init_kernel(
vptr_t ipcbuf_vptr;
create_frames_of_region_ret_t create_frames_ret;
create_frames_of_region_ret_t extra_bi_ret;
seL4_SlotPos first_untyped_slot;
/* convert from physical addresses to userland vptrs */
v_region_t ui_v_reg = {
@@ -429,7 +443,7 @@ static BOOT_CODE bool_t try_init_kernel(
return false;
}
if (!arch_init_freemem(ui_p_reg, dtb_p_reg, it_v_reg, extra_bi_size_bits)) {
if (!arch_init_freemem(ui_p_reg, dtb_p_reg, extra_device_p_reg, it_v_reg, extra_bi_size_bits)) {
printf("ERROR: free memory management initialization failed\n");
return false;
}
@@ -588,8 +602,13 @@ static BOOT_CODE bool_t try_init_kernel(
init_core_state(initial);
first_untyped_slot = ndks_boot.slot_pos_cur;
if (extra_device_addr_start) {
create_untypeds_for_region(root_cnode_cap, true, paddr_to_pptr_reg(extra_device_p_reg), first_untyped_slot);
}
/* create all of the untypeds. Both devices and kernel window memory */
if (!create_untypeds(root_cnode_cap)) {
if (!create_untypeds(root_cnode_cap, first_untyped_slot)) {
printf("ERROR: could not create untypteds for kernel image boot memory\n");
return false;
}
@@ -637,7 +656,9 @@ BOOT_CODE VISIBLE void init_kernel(
sword_t pv_offset,
vptr_t v_entry,
paddr_t dtb_addr_p,
uint32_t dtb_size
word_t dtb_size,
paddr_t extra_device_addr_p,
word_t extra_device_size
)
{
bool_t result;
@@ -649,7 +670,9 @@ BOOT_CODE VISIBLE void init_kernel(
ui_p_reg_end,
pv_offset,
v_entry,
dtb_addr_p, dtb_size);
dtb_addr_p, dtb_size,
extra_device_addr_p, extra_device_size
);
} else {
result = try_init_kernel_secondary_core();
}
@@ -659,7 +682,9 @@ BOOT_CODE VISIBLE void init_kernel(
ui_p_reg_end,
pv_offset,
v_entry,
dtb_addr_p, dtb_size);
dtb_addr_p, dtb_size,
extra_device_addr_p, extra_device_size
);
#endif /* ENABLE_SMP_SUPPORT */

View File

@@ -59,6 +59,7 @@ BOOT_CODE cap_t create_mapped_it_frame_cap(cap_t pd_cap, pptr_t pptr, vptr_t vpt
BOOT_CODE static bool_t arch_init_freemem(region_t ui_reg,
p_region_t dtb_p_reg,
p_region_t extra_device_p_reg,
v_region_t it_v_reg,
word_t extra_bi_size_bits)
{
@@ -79,6 +80,11 @@ BOOT_CODE static bool_t arch_init_freemem(region_t ui_reg,
index += 1;
}
if (extra_device_p_reg.start) {
res_reg[index] = paddr_to_pptr_reg(extra_device_p_reg);
index++;
}
/* reserve the user image region */
if (index >= ARRAY_SIZE(res_reg)) {
printf("ERROR: no slot to add user image to reserved regions\n");
@@ -196,7 +202,9 @@ static BOOT_CODE bool_t try_init_kernel(
sword_t pv_offset,
vptr_t v_entry,
paddr_t dtb_phys_addr,
word_t dtb_size
word_t dtb_size,
paddr_t extra_device_addr_start,
word_t extra_device_size
)
{
cap_t root_cnode_cap;
@@ -206,6 +214,9 @@ static BOOT_CODE bool_t try_init_kernel(
region_t ui_reg = paddr_to_pptr_reg((p_region_t) {
ui_p_reg_start, ui_p_reg_end
});
p_region_t extra_device_p_reg = (p_region_t) {
extra_device_addr_start, extra_device_addr_start + extra_device_size
};
word_t extra_bi_size = 0;
pptr_t extra_bi_offset = 0;
vptr_t extra_bi_frame_vptr;
@@ -213,6 +224,7 @@ static BOOT_CODE bool_t try_init_kernel(
vptr_t ipcbuf_vptr;
create_frames_of_region_ret_t create_frames_ret;
create_frames_of_region_ret_t extra_bi_ret;
seL4_SlotPos first_untyped_slot;
/* convert from physical addresses to userland vptrs */
v_region_t ui_v_reg = {
@@ -290,7 +302,7 @@ static BOOT_CODE bool_t try_init_kernel(
}
/* make the free memory available to alloc_region() */
if (!arch_init_freemem(ui_reg, dtb_p_reg, it_v_reg, extra_bi_size_bits)) {
if (!arch_init_freemem(ui_reg, dtb_p_reg, extra_device_p_reg, it_v_reg, extra_bi_size_bits)) {
printf("ERROR: free memory management initialization failed\n");
return false;
}
@@ -425,8 +437,15 @@ static BOOT_CODE bool_t try_init_kernel(
init_core_state(initial);
first_untyped_slot = ndks_boot.slot_pos_cur;
if (extra_device_addr_start) {
create_untypeds_for_region(root_cnode_cap, true, paddr_to_pptr_reg(extra_device_p_reg), first_untyped_slot);
}
/* convert the remaining free memory into UT objects and provide the caps */
if (!create_untypeds(root_cnode_cap)) {
if (!create_untypeds(
root_cnode_cap,
first_untyped_slot)) {
printf("ERROR: could not create untypteds for kernel image boot memory\n");
return false;
}
@@ -459,7 +478,9 @@ BOOT_CODE VISIBLE void init_kernel(
sword_t pv_offset,
vptr_t v_entry,
paddr_t dtb_addr_p,
uint32_t dtb_size
word_t dtb_size,
paddr_t extra_device_addr_p,
word_t extra_device_size
#ifdef ENABLE_SMP_SUPPORT
,
word_t hart_id,
@@ -477,7 +498,9 @@ BOOT_CODE VISIBLE void init_kernel(
pv_offset,
v_entry,
dtb_addr_p,
dtb_size);
dtb_size,
extra_device_addr_p,
extra_device_size);
} else {
result = try_init_kernel_secondary_core(hart_id, core_id);
}
@@ -487,7 +510,9 @@ BOOT_CODE VISIBLE void init_kernel(
pv_offset,
v_entry,
dtb_addr_p,
dtb_size);
dtb_size,
extra_device_addr_p,
extra_device_size);
#endif
if (!result) {
fail("ERROR: kernel init failed");

View File

@@ -327,7 +327,7 @@ BOOT_CODE bool_t init_sys_state(
#endif
/* create all of the untypeds. Both devices and kernel window memory */
if (!create_untypeds(root_cnode_cap)) {
if (!create_untypeds(root_cnode_cap, ndks_boot.slot_pos_cur)) {
return false;
}

View File

@@ -718,7 +718,7 @@ BOOT_CODE static bool_t provide_untyped_cap(
* @param first_untyped_slot First available untyped boot info slot.
* @return true on success, false on failure.
*/
BOOT_CODE static bool_t create_untypeds_for_region(
BOOT_CODE bool_t create_untypeds_for_region(
cap_t root_cnode_cap,
bool_t device_memory,
region_t reg,
@@ -764,10 +764,10 @@ BOOT_CODE static bool_t create_untypeds_for_region(
return true;
}
BOOT_CODE bool_t create_untypeds(cap_t root_cnode_cap)
BOOT_CODE bool_t create_untypeds(cap_t root_cnode_cap,
seL4_SlotPos first_untyped_slot
)
{
seL4_SlotPos first_untyped_slot = ndks_boot.slot_pos_cur;
paddr_t start = 0;
for (word_t i = 0; i < ndks_boot.resv_count; i++) {
if (start < ndks_boot.reserved[i].start) {

View File

@@ -44,7 +44,6 @@ import os
StringTypes = (str, bytes)
def func_code(f):
return f.__code__