# HG changeset patch # User Paul Boddie # Date 1652050851 -7200 # Node ID 73ba6235bd59e119acfa8e153938b0062c8c582a # Parent eb7866448709852ca254c33fdbafc9e0c1a70159 Improved L4 auxiliary information initialisation. diff -r eb7866448709 -r 73ba6235bd59 tests/dstest_exec.cc --- a/tests/dstest_exec.cc Sun May 08 23:51:50 2022 +0200 +++ b/tests/dstest_exec.cc Mon May 09 01:00:51 2022 +0200 @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -472,11 +473,13 @@ l4_addr_t _caps; char *_arg_top, *_env_top; + char **_argv; char *_auxv_end; int _env_entries; - /* L4Re environment region. */ + /* L4Re auxiliary and environment regions. */ + l4re_aux_t *_aux; l4re_env_t *_env; public: @@ -551,11 +554,11 @@ /* Loader flags, debugging flags, and the KIP capability index. See: generate_l4aux in Remote_app_model */ - void push_l4re_flags() + void push_l4re_aux() { - *(--_element) = 0; - *(--_element) = 0; - *(--_element) = 0x14 << L4_CAP_SHIFT; + _aux = (l4re_aux_t *) _element; + _aux--; + _element = (l4_umword_t *) _aux; } void push_l4re_env() @@ -565,6 +568,17 @@ _element = (l4_umword_t *) _env; } + /* Set the common auxiliary information. */ + + void set_l4re_aux(l4re_aux_t *aux) + { + memcpy(_aux, aux, sizeof(l4re_aux_t)); + + /* Take the binary name from the first program argument. */ + + _aux->binary = (char *) _argv[0]; + } + /* Set the common environment, introducing the reference to additional capabilities. */ @@ -590,6 +604,10 @@ *(--auxv_base) = {0xf1, _segment.region_address((char *) _env)}; + /* L4Re auxiliary structure pointer. */ + + *(--auxv_base) = {0xf0, _segment.region_address((char *) _aux)}; + /* Apparently required entries. NOTE: The user/group identifiers should be obtained from the broader environment. */ @@ -645,11 +663,11 @@ /* Reserve space and fill the stack from the top inwards. */ - char **ap = (char **) (_element - argc); + _argv = (char **) (_element - argc); char *arg = _arg_top; for (int i = 0; i < argc; i++) - arg -= write_address(arg, &ap[i], argv[i]); + arg -= write_address(arg, &_argv[i], argv[i]); /* Write the count. */ @@ -684,7 +702,7 @@ /* Push L4Re flags, environment and auxiliary vector. */ - push_l4re_flags(); + push_l4re_aux(); push_l4re_env(); push_auxv(); @@ -711,6 +729,7 @@ l4_cap_idx_t _pager_cap = 0x10 << L4_CAP_SHIFT; l4_cap_idx_t _rm_cap = 0x11 << L4_CAP_SHIFT; l4_cap_idx_t _ma_cap = 0x12 << L4_CAP_SHIFT; + l4_cap_idx_t _kip_cap = 0x14 << L4_CAP_SHIFT; unsigned int _first_cap = 0x15; /* UTCB details. */ @@ -719,6 +738,7 @@ /* Common environment details. */ + l4re_aux_t _aux; l4re_env_t _env; /* Task and thread initialisation. */ @@ -763,6 +783,12 @@ _env.first_free_cap = _first_cap; _env.utcb_area = utcb_fpage; _env.first_free_utcb = l4_fpage_memaddr(utcb_fpage) + L4_UTCB_OFFSET; + + /* Populate auxiliary information. */ + + _aux.kip_ds = _kip_cap; + _aux.dbg_lvl = 0; + _aux.ldr_flags = 0; } /* Configure the task environment. */ @@ -834,6 +860,7 @@ /* Populate the initial environment in the thread. */ + st.set_l4re_aux(&_aux); st.set_l4re_env(&_env); /* Set the start details. */