1.1 --- a/libexec/include/exec/external_pager.h Sun Dec 11 01:23:05 2022 +0100
1.2 +++ b/libexec/include/exec/external_pager.h Tue Dec 13 17:05:51 2022 +0100
1.3 @@ -23,11 +23,13 @@
1.4
1.5 #include <exec/pager.h>
1.6
1.7 +#include "parent_pager_object_interface.h"
1.8 +
1.9
1.10
1.11 /* A simple system pager also acting as a region mapper. */
1.12
1.13 -class ExternalPager : public ExecPager
1.14 +class ExternalPager : public ExecPager, public ParentPagerObject
1.15 {
1.16 public:
1.17 explicit ExternalPager(address_t start = 0, address_t end = 0);
1.18 @@ -44,6 +46,10 @@
1.19
1.20 virtual long attach(address_t *start, address_t size, map_flags_t flags,
1.21 l4_cap_idx_t ds, address_t offset, unsigned char align);
1.22 +
1.23 + /* Parent methods. */
1.24 +
1.25 + virtual long signal(unsigned long sig, unsigned long val);
1.26 };
1.27
1.28 /* vim: tabstop=2 expandtab shiftwidth=2
2.1 --- a/libexec/include/exec/internal_pager.h Sun Dec 11 01:23:05 2022 +0100
2.2 +++ b/libexec/include/exec/internal_pager.h Tue Dec 13 17:05:51 2022 +0100
2.3 @@ -23,11 +23,13 @@
2.4
2.5 #include <exec/pager.h>
2.6
2.7 +#include "pager_object_interface.h"
2.8 +
2.9
2.10
2.11 /* A simple system pager also acting as a region mapper. */
2.12
2.13 -class InternalPager : public ExecPager
2.14 +class InternalPager : public ExecPager, public PagerObject
2.15 {
2.16 public:
2.17 explicit InternalPager(address_t start = 0, address_t end = 0);
3.1 --- a/libexec/include/exec/pager.h Sun Dec 11 01:23:05 2022 +0100
3.2 +++ b/libexec/include/exec/pager.h Tue Dec 13 17:05:51 2022 +0100
3.3 @@ -25,8 +25,6 @@
3.4
3.5 #include <exec/mapped_region.h>
3.6
3.7 -#include "pager_object_interface.h"
3.8 -
3.9
3.10
3.11 /* Collection types. */
3.12 @@ -37,7 +35,7 @@
3.13
3.14 /* A simple system pager also acting as a region mapper. */
3.15
3.16 -class ExecPager : public PagerObject
3.17 +class ExecPager
3.18 {
3.19 protected:
3.20 address_t _start, _end;
4.1 --- a/libexec/include/exec/process.h Sun Dec 11 01:23:05 2022 +0100
4.2 +++ b/libexec/include/exec/process.h Tue Dec 13 17:05:51 2022 +0100
4.3 @@ -50,10 +50,11 @@
4.4
4.5 enum exec_task_caps
4.6 {
4.7 - L4_EXEC_PAGER_CAP = 0x10UL << L4_CAP_SHIFT,
4.8 - L4_EXEC_RM_CAP = 0x11UL << L4_CAP_SHIFT,
4.9 - L4_EXEC_MA_CAP = 0x12UL << L4_CAP_SHIFT,
4.10 - L4_EXEC_KIP_CAP = 0x14UL << L4_CAP_SHIFT,
4.11 + L4_EXEC_PAGER_CAP = 0x10UL << L4_CAP_SHIFT,
4.12 + L4_EXEC_RM_CAP = 0x11UL << L4_CAP_SHIFT,
4.13 + L4_EXEC_MA_CAP = 0x12UL << L4_CAP_SHIFT,
4.14 + L4_EXEC_PARENT_CAP = 0x13UL << L4_CAP_SHIFT,
4.15 + L4_EXEC_KIP_CAP = 0x14UL << L4_CAP_SHIFT,
4.16 };
4.17
4.18 /* The default first free capability index must follow those above. Any
4.19 @@ -94,6 +95,8 @@
4.20
4.21 long configure_thread(l4_cap_idx_t server, l4_cap_idx_t mapped_cap = L4_INVALID_CAP);
4.22
4.23 + long set_parent(l4_cap_idx_t server);
4.24 +
4.25 long map_capabilities(struct ipc_mapped_cap mapped_caps[],
4.26 bool to_count = true);
4.27
5.1 --- a/libexec/lib/src/Makefile Sun Dec 11 01:23:05 2022 +0100
5.2 +++ b/libexec/lib/src/Makefile Tue Dec 13 17:05:51 2022 +0100
5.3 @@ -17,7 +17,7 @@
5.4
5.5 CLIENT_INTERFACES_CC = dataspace mapped_file
5.6
5.7 -SERVER_INTERFACES_CC = pager_object
5.8 +SERVER_INTERFACES_CC = pager_object parent_pager_object
5.9
5.10 # Generated and plain source files.
5.11
6.1 --- a/libexec/lib/src/external_pager.cc Sun Dec 11 01:23:05 2022 +0100
6.2 +++ b/libexec/lib/src/external_pager.cc Tue Dec 13 17:05:51 2022 +0100
6.3 @@ -131,7 +131,7 @@
6.4 l4_cap_idx_t ds, address_t offset,
6.5 unsigned char align)
6.6 {
6.7 - long err = find(start, &size, flags, offset, align);
6.8 + long err = ExecPager::find(start, &size, flags, offset, align);
6.9
6.10 if (!err)
6.11 {
6.12 @@ -155,5 +155,13 @@
6.13 return err;
6.14 }
6.15
6.16 +/* Receive signals from a task. */
6.17 +
6.18 +long ExternalPager::signal(unsigned long sig, unsigned long val)
6.19 +{
6.20 + printf("Signal %ld with value %ld received.\n", sig, val);
6.21 + return L4_EOK;
6.22 +}
6.23 +
6.24 /* vim: tabstop=2 expandtab shiftwidth=2
6.25 */
7.1 --- a/libexec/lib/src/internal_pager.cc Sun Dec 11 01:23:05 2022 +0100
7.2 +++ b/libexec/lib/src/internal_pager.cc Tue Dec 13 17:05:51 2022 +0100
7.3 @@ -21,6 +21,7 @@
7.4
7.5 #include <l4/re/env.h>
7.6 #include <l4/re/c/dataspace.h>
7.7 +#include <l4/util/util.h>
7.8
7.9 #include <mem/memory_utils.h>
7.10
7.11 @@ -131,7 +132,7 @@
7.12 l4_cap_idx_t ds, address_t offset,
7.13 unsigned char align)
7.14 {
7.15 - long err = find(start, &size, flags, offset, align);
7.16 + long err = ExecPager::find(start, &size, flags, offset, align);
7.17
7.18 if (!err)
7.19 {
8.1 --- a/libexec/lib/src/process.cc Sun Dec 11 01:23:05 2022 +0100
8.2 +++ b/libexec/lib/src/process.cc Tue Dec 13 17:05:51 2022 +0100
8.3 @@ -62,8 +62,10 @@
8.4 _env.log = L4_BASE_LOG_CAP;
8.5 _env.scheduler = L4_BASE_SCHEDULER_CAP;
8.6 _env.mem_alloc = L4_EXEC_MA_CAP;
8.7 + _env.parent = L4_EXEC_PARENT_CAP;
8.8
8.9 - /* Capability details that are updated for each thread. */
8.10 + /* Capability details that are updated for each thread. Note that the region
8.11 + mapper is redefined, but it would traditionally employ the given index. */
8.12
8.13 _env.main_thread = L4_BASE_THREAD_CAP;
8.14 _env.rm = L4_EXEC_RM_CAP;
8.15 @@ -139,7 +141,8 @@
8.16 return map_capabilities(mapped_caps, false);
8.17 }
8.18
8.19 -/* Configure the thread environment. */
8.20 +/* Configure the thread environment, employing the given server as the region
8.21 + mapper. */
8.22
8.23 long Process::configure_thread(l4_cap_idx_t server, l4_cap_idx_t mapped_cap)
8.24 {
8.25 @@ -158,6 +161,13 @@
8.26 }
8.27 }
8.28
8.29 +/* Set the parent of the new thread. */
8.30 +
8.31 +long Process::set_parent(l4_cap_idx_t server)
8.32 +{
8.33 + return ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.parent, server, L4_CAP_FPAGE_RWS, 0});
8.34 +}
8.35 +
8.36 /* Map capabilities into the task, counting them if indicated. */
8.37
8.38 long Process::map_capabilities(struct ipc_mapped_cap mapped_caps[],
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/libsystypes/idl/parent.idl Tue Dec 13 17:05:51 2022 +0100
9.3 @@ -0,0 +1,9 @@
9.4 +#include <l4/re/protocols.h> /* L4RE_PROTO_PARENT */
9.5 +
9.6 +[protocol(L4RE_PROTO_PARENT)]
9.7 +interface Parent
9.8 +{
9.9 + /* Receive a signal from a task. */
9.10 +
9.11 + [opcode(0)] void signal(in unsigned long sig, in unsigned long val);
9.12 +};
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/libsystypes/idl/parent_pager_object.idl Tue Dec 13 17:05:51 2022 +0100
10.3 @@ -0,0 +1,4 @@
10.4 +import "pager_object.idl";
10.5 +import "parent.idl";
10.6 +
10.7 +interface ParentPagerObject composes Parent, PagerObject;
11.1 --- a/tests/Makefile Sun Dec 11 01:23:05 2022 +0100
11.2 +++ b/tests/Makefile Tue Dec 13 17:05:51 2022 +0100
11.3 @@ -34,7 +34,7 @@
11.4
11.5 CLIENT_INTERFACES_CC = dataspace
11.6
11.7 -SERVER_INTERFACES_CC = pager_object
11.8 +SERVER_INTERFACES_CC = pager_object parent_pager_object
11.9
11.10 # Generated and plain source files.
11.11
12.1 --- a/tests/dstest_exec.cc Sun Dec 11 01:23:05 2022 +0100
12.2 +++ b/tests/dstest_exec.cc Tue Dec 13 17:05:51 2022 +0100
12.3 @@ -36,7 +36,7 @@
12.4 #include <pthread-l4.h>
12.5 #include <pthread.h>
12.6
12.7 -#include "pager_object_server.h"
12.8 +#include "parent_pager_object_server.h"
12.9
12.10
12.11
12.12 @@ -61,7 +61,7 @@
12.13 pthread_attr_init(&attr);
12.14 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
12.15
12.16 - ipc_server_init_for(&config, PagerObject, &exec_pager);
12.17 + ipc_server_init_for(&config, ParentPagerObject, &exec_pager);
12.18
12.19 long err = pthread_create(&pager_thread, &attr, ipc_server_start_mainloop, &config);
12.20
12.21 @@ -172,6 +172,14 @@
12.22 return 1;
12.23 }
12.24
12.25 + err = process.set_parent(config.server);
12.26 +
12.27 + if (err)
12.28 + {
12.29 + printf("Could not map parent to task for internal pager.\n");
12.30 + return 1;
12.31 + }
12.32 +
12.33 /* Create an unbound IPC gate for the region mapper. */
12.34
12.35 l4_cap_idx_t ipc_gate = ipc_cap_alloc();
12.36 @@ -297,6 +305,14 @@
12.37 return 1;
12.38 }
12.39
12.40 + err = process.set_parent(config.server);
12.41 +
12.42 + if (err)
12.43 + {
12.44 + printf("Could not map parent to task for payload.\n");
12.45 + return 1;
12.46 + }
12.47 +
12.48 /* Populate a thread stack with argument and environment details for the
12.49 actual program. The server capability should be assigned to the region
12.50 mapper capability slot already. */