@@ -11,7 +11,7 @@ use elf::ElfFile;
1111use loader:: Loader ;
1212use microkit_tool:: {
1313 elf, loader, sdf, sel4, util, DisjointMemoryRegion , MemoryRegion , ObjectAllocator , Region ,
14- UntypedObject , MAX_PDS , PD_MAX_NAME_LENGTH ,
14+ UntypedObject , MAX_PDS , MAX_VMS , PD_MAX_NAME_LENGTH , VM_MAX_NAME_LENGTH ,
1515} ;
1616use sdf:: {
1717 parse, ProtectionDomain , SysMap , SysMapPerms , SysMemoryRegion , SystemDescription ,
@@ -31,7 +31,7 @@ use std::mem::size_of;
3131use std:: path:: { Path , PathBuf } ;
3232use util:: {
3333 bytes_to_struct, comma_sep_u64, comma_sep_usize, json_str, json_str_as_bool, json_str_as_u64,
34- monitor_serialise_u64_vec, struct_to_bytes,
34+ monitor_serialise_names , monitor_serialise_u64_vec, struct_to_bytes,
3535} ;
3636
3737// Corresponds to the IPC buffer symbol in libmicrokit and the monitor
@@ -448,7 +448,8 @@ struct BuiltSystem {
448448 fault_ep_cap_address : u64 ,
449449 reply_cap_address : u64 ,
450450 cap_lookup : HashMap < u64 , String > ,
451- tcb_caps : Vec < u64 > ,
451+ pd_tcb_caps : Vec < u64 > ,
452+ vm_tcb_caps : Vec < u64 > ,
452453 sched_caps : Vec < u64 > ,
453454 ntfn_caps : Vec < u64 > ,
454455 pd_elf_regions : Vec < Vec < Region > > ,
@@ -2864,7 +2865,8 @@ fn build_system(
28642865 fault_ep_cap_address : fault_ep_endpoint_object. cap_addr ,
28652866 reply_cap_address : reply_obj. cap_addr ,
28662867 cap_lookup : cap_address_names,
2867- tcb_caps : tcb_caps[ ..system. protection_domains . len ( ) ] . to_vec ( ) ,
2868+ pd_tcb_caps : tcb_caps[ ..system. protection_domains . len ( ) ] . to_vec ( ) ,
2869+ vm_tcb_caps : tcb_caps[ system. protection_domains . len ( ) ..] . to_vec ( ) ,
28682870 sched_caps : sched_context_caps,
28692871 ntfn_caps : notification_caps,
28702872 pd_elf_regions,
@@ -3534,38 +3536,42 @@ fn main() -> Result<(), String> {
35343536 & bootstrap_invocation_data,
35353537 ) ?;
35363538
3537- let tcb_cap_bytes = monitor_serialise_u64_vec ( & built_system. tcb_caps ) ;
3539+ let pd_tcb_cap_bytes = monitor_serialise_u64_vec ( & built_system. pd_tcb_caps ) ;
3540+ let vm_tcb_cap_bytes = monitor_serialise_u64_vec ( & built_system. vm_tcb_caps ) ;
35383541 let sched_cap_bytes = monitor_serialise_u64_vec ( & built_system. sched_caps ) ;
35393542 let ntfn_cap_bytes = monitor_serialise_u64_vec ( & built_system. ntfn_caps ) ;
35403543 let pd_stack_addrs_bytes = monitor_serialise_u64_vec ( & built_system. pd_stack_addrs ) ;
35413544
35423545 monitor_elf. write_symbol ( "fault_ep" , & built_system. fault_ep_cap_address . to_le_bytes ( ) ) ?;
35433546 monitor_elf. write_symbol ( "reply" , & built_system. reply_cap_address . to_le_bytes ( ) ) ?;
3544- monitor_elf. write_symbol ( "tcbs" , & tcb_cap_bytes) ?;
3547+ monitor_elf. write_symbol ( "pd_tcbs" , & pd_tcb_cap_bytes) ?;
3548+ monitor_elf. write_symbol ( "vm_tcbs" , & vm_tcb_cap_bytes) ?;
35453549 monitor_elf. write_symbol ( "scheduling_contexts" , & sched_cap_bytes) ?;
35463550 monitor_elf. write_symbol ( "notification_caps" , & ntfn_cap_bytes) ?;
35473551 monitor_elf. write_symbol ( "pd_stack_addrs" , & pd_stack_addrs_bytes) ?;
3548- // We do MAX_PDS + 1 due to the index that the monitor uses (the badge) starting at 1.
3549- let mut pd_names_bytes = vec ! [ 0 ; ( MAX_PDS + 1 ) * PD_MAX_NAME_LENGTH ] ;
3550- for ( i, pd) in system. protection_domains . iter ( ) . enumerate ( ) {
3551- // The monitor will index into the array of PD names based on the badge, which
3552- // starts at 1 and hence we cannot use the 0th entry in the array.
3553- let name = pd. name . as_bytes ( ) ;
3554- let start = ( i + 1 ) * PD_MAX_NAME_LENGTH ;
3555- // Here instead of giving an error we simply take the minimum of the PD's name
3556- // and how large of a name we can encode
3557- let name_length = min ( name. len ( ) , PD_MAX_NAME_LENGTH ) ;
3558- let end = start + name_length;
3559- pd_names_bytes[ start..end] . copy_from_slice ( & name[ ..name_length] ) ;
3560- // These bytes will be interpreted as a C string, so we must include
3561- // a null-terminator.
3562- pd_names_bytes[ start + PD_MAX_NAME_LENGTH - 1 ] = 0 ;
3563- }
3564- monitor_elf. write_symbol ( "pd_names" , & pd_names_bytes) ?;
3552+ let pd_names = system
3553+ . protection_domains
3554+ . iter ( )
3555+ . map ( |pd| & pd. name )
3556+ . collect ( ) ;
3557+ monitor_elf. write_symbol (
3558+ "pd_names" ,
3559+ & monitor_serialise_names ( pd_names, MAX_PDS , PD_MAX_NAME_LENGTH ) ,
3560+ ) ?;
35653561 monitor_elf. write_symbol (
35663562 "pd_names_len" ,
35673563 & system. protection_domains . len ( ) . to_le_bytes ( ) ,
35683564 ) ?;
3565+ let vm_names: Vec < & String > = system
3566+ . protection_domains
3567+ . iter ( )
3568+ . filter_map ( |pd| pd. virtual_machine . as_ref ( ) . map ( |vm| & vm. name ) )
3569+ . collect ( ) ;
3570+ monitor_elf. write_symbol ( "vm_names_len" , & vm_names. len ( ) . to_le_bytes ( ) ) ?;
3571+ monitor_elf. write_symbol (
3572+ "vm_names" ,
3573+ & monitor_serialise_names ( vm_names, MAX_VMS , VM_MAX_NAME_LENGTH ) ,
3574+ ) ?;
35693575
35703576 // Write out all the symbols for each PD
35713577 pd_write_symbols (
0 commit comments