3 #include <sys/ptrace.h>
8 #include "lock_guard.h"
10 #include "mem_layout.h"
16 mem_space()->set_pid (Hostproc::create());
21 Task::invoke_arch(L4_msg_tag &tag, Utcb *utcb)
24 switch (utcb->values[0])
30 Utcb_values_per_ldt_entry
31 = Cpu::Ldt_entry_size / sizeof(utcb->values[0]),
33 if (EXPECT_FALSE(tag.words() < 3
34 || tag.words() % Utcb_values_per_ldt_entry))
36 tag = commit_result(-L4_err::EInval);
40 unsigned entry_number = utcb->values[1];
42 Mword *trampoline_page = (Mword *)Kmem::kernel_trampoline_page;
44 for (; idx < tag.words()
45 ; idx += Utcb_values_per_ldt_entry,
48 Gdt_entry *d = (Gdt_entry *)&utcb->values[idx];
53 info.entry_number = entry_number;
54 info.base_addr = d->base();
55 info.limit = d->limit();
56 info.seg_32bit = d->seg32();
57 info.contents = d->contents();
58 info.read_exec_only = !d->writable();
59 info.limit_in_pages = d->granularity();
60 info.seg_not_present = !d->present();
61 info.useable = d->avl();
64 // Set up data on trampoline
65 for (unsigned i = 0; i < sizeof(info) / sizeof(Mword); i++)
66 *(trampoline_page + i + 1) = *(((Mword *)&info) + i);
68 // Call modify_ldt for given user process
69 Trampoline::syscall(pid(), __NR_modify_ldt,
71 Mem_layout::Trampoline_page + sizeof(Mword),
74 // Also set this for the fiasco kernel so that
75 // segment registers can be set, this is necessary for signal
76 // handling, esp. for sigreturn to work in the Fiasco kernel
77 // with the context of the client (gs/fs values).
78 if (*(trampoline_page + 1))
79 Emulation::modify_ldt(*(trampoline_page + 1), // entry
90 /** Map tracebuffer into each userland task for easy access. */
97 if (id() != Config::sigma0_taskno)
100 L4_fpage(0, 1, Config::PAGE_SHIFT,
101 Kmem::virt_to_phys ((const void*)(Mem_layout::Tbuf_status_page))),
102 nonull_static_cast<Space*>(this), // to: space
103 L4_fpage(0, 0, Config::PAGE_SHIFT,
104 Mem_layout::Tbuf_ustatus_page, L4_fpage::Cached), 0);
106 for (Address size=0; size<Jdb_tbuf::size(); size+=Config::PAGE_SIZE)
108 mem_map (sigma0_task, // from: space
109 L4_fpage(0, 1, Config::PAGE_SHIFT,
110 Kmem::virt_to_phys ((const void*)
111 (Mem_layout::Tbuf_buffer_area+size))),
112 nonull_static_cast<Space*>(this), // to: space
113 L4_fpage(0, 0, Config::PAGE_SHIFT,
114 Mem_layout::Tbuf_ubuffer_area+size, L4_fpage::Cached), 0);
125 //unregister_space();
127 //dequeue_at_parent();
130 if (id() == Config::kernel_taskno)
132 reset_dirty(); // Must not deallocate kernel pagetable.
133 return; // No need to kill kernel process.
137 Lock_guard<Cpu_lock> guard (&cpu_lock);
139 pid_t hostpid = pid();
140 ptrace (PTRACE_KILL, hostpid, NULL, NULL);
142 while (waitpid (hostpid, NULL, 0) != hostpid)
149 Task::map_utcb_ptr_page()
151 //Mem_space::Status res =
152 mem_space()->v_insert(
153 Mem_space::Phys_addr::create(Mem_layout::Utcb_ptr_frame),
154 Mem_space::Addr::create(Mem_layout::Utcb_ptr_page_user),
155 Mem_space::Size::create(Config::PAGE_SIZE),
156 Mem_space::Page_writable
157 | Mem_space::Page_user_accessible
158 | Mem_space::Page_cacheable);