@@ -227,13 +227,19 @@ int bootstrap_add_untypeds_from_bootinfo(bootstrap_info_t *bs, seL4_BootInfo *bi
227
227
228
228
static int bootstrap_add_untypeds_from_simple (bootstrap_info_t * bs , simple_t * simple ) {
229
229
int error ;
230
- int i ;
231
230
/* if we do not have a boot cspace, or we have added some uts that aren't in the
232
231
* current space then just bail */
233
232
if (!bs -> have_boot_cspace || (bs -> uts && !bs -> uts_in_current_cspace )) {
234
233
return 1 ;
235
234
}
236
- for (i = 0 ; i < simple_get_untyped_count (simple ); i ++ ) {
235
+
236
+ int cnt = simple_get_untyped_count (simple );
237
+ if (cnt < 0 ) {
238
+ ZF_LOGW ("Could not get untyped count (%d)" , cnt );
239
+ return 1 ;
240
+ }
241
+
242
+ for (int i = 0 ; i < cnt ; i ++ ) {
237
243
size_t size_bits ;
238
244
uintptr_t paddr ;
239
245
bool device ;
@@ -1005,10 +1011,7 @@ static int handle_device_untyped_cap(add_untypeds_state_t *state, uintptr_t padd
1005
1011
bool cap_tainted = false;
1006
1012
int error ;
1007
1013
uintptr_t ut_end = paddr + BIT (size_bits );
1008
- int num_regions = 0 ;
1009
- if (state != NULL ) {
1010
- num_regions = state -> num_regions ;
1011
- }
1014
+ int num_regions = state ? state -> num_regions : 0 ;
1012
1015
for (int i = 0 ; i < num_regions ; i ++ ) {
1013
1016
pmem_region_t * region = & state -> regions [i ];
1014
1017
uint64_t region_end = region -> base_addr + region -> length ;
@@ -1111,23 +1114,25 @@ int allocman_add_simple_untypeds_with_regions(allocman_t *alloc, simple_t *simpl
1111
1114
int error = prepare_handle_device_untyped_cap (alloc , simple , & state , num_regions , region_list );
1112
1115
ZF_LOGF_IF (error , "bootstrap_prepare_handle_device_untyped_cap Failed" );
1113
1116
1114
- size_t i ;
1115
- size_t total_untyped = simple_get_untyped_count (simple );
1117
+ int total_untyped = simple_get_untyped_count (simple );
1118
+ if (total_untyped < 0 ) {
1119
+ ZF_LOGW ("Could not get untyped count (%d)" , total_untyped );
1120
+ return 0 ; /* don't report an error, just do nothing */
1121
+ }
1116
1122
1117
- for (i = 0 ; i < total_untyped ; i ++ ) {
1123
+ for (int i = 0 ; i < total_untyped ; i ++ ) {
1118
1124
size_t size_bits ;
1119
1125
uintptr_t paddr ;
1120
1126
bool device ;
1121
1127
cspacepath_t path = allocman_cspace_make_path (alloc , simple_get_nth_untyped (simple , i , & size_bits , & paddr , & device ));
1122
- int dev_type = device ? ALLOCMAN_UT_DEV : ALLOCMAN_UT_KERNEL ;
1123
- // If it is regular UT memory, then we add cap and move on.
1124
- if (dev_type == ALLOCMAN_UT_KERNEL ) {
1125
- error = allocman_utspace_add_uts (alloc , 1 , & path , & size_bits , & paddr , dev_type );
1126
- ZF_LOGF_IF (error , "Could not add kernel untyped." );
1127
- } else {
1128
- // Otherwise we are Device untyped.
1128
+ if (device ) {
1129
+ // Separates device RAM memory into separate untyped caps
1129
1130
error = handle_device_untyped_cap (state , paddr , size_bits , & path , alloc );
1130
- ZF_LOGF_IF (error , "bootstrap_arch_handle_device_untyped_cap failed." );
1131
+ ZF_LOGF_IF (error , "handle_device_untyped_cap failed (%d)." , error );
1132
+ } else {
1133
+ // for regular UT memory we add cap
1134
+ error = allocman_utspace_add_uts (alloc , 1 , & path , & size_bits , & paddr , ALLOCMAN_UT_KERNEL );
1135
+ ZF_LOGF_IF (error , "Could not add kernel untyped (%d)." , error );
1131
1136
}
1132
1137
}
1133
1138
if (state ) {
0 commit comments