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::phys_to_virt
43 (Mem_layout::Trampoline_frame);
45 for (; idx < tag.words()
46 ; idx += Utcb_values_per_ldt_entry,
49 Gdt_entry *d = (Gdt_entry *)&utcb->values[idx];
54 info.entry_number = entry_number;
55 info.base_addr = d->base();
56 info.limit = d->limit();
57 info.seg_32bit = d->seg32();
58 info.contents = d->contents();
59 info.read_exec_only = !d->writable();
60 info.limit_in_pages = d->granularity();
61 info.seg_not_present = !d->present();
62 info.useable = d->avl();
65 // Set up data on trampoline
66 for (unsigned i = 0; i < sizeof(info) / sizeof(Mword); i++)
67 *(trampoline_page + i + 1) = *(((Mword *)&info) + i);
69 // Call modify_ldt for given user process
70 Trampoline::syscall(pid(), __NR_modify_ldt,
72 Mem_layout::Trampoline_page + sizeof(Mword),
75 // Also set this for the fiasco kernel so that
76 // segment registers can be set, this is necessary for signal
77 // handling, esp. for sigreturn to work in the Fiasco kernel
78 // with the context of the client (gs/fs values).
79 if (*(trampoline_page + 1))
80 Emulation::modify_ldt(*(trampoline_page + 1), // entry
91 /** Map tracebuffer into each userland task for easy access. */
98 if (id() != Config::sigma0_taskno)
100 mem_map (sigma0_task,
101 L4_fpage(0, 1, Config::PAGE_SHIFT,
102 Kmem::virt_to_phys ((const void*)(Mem_layout::Tbuf_status_page))),
103 nonull_static_cast<Space*>(this), // to: space
104 L4_fpage(0, 0, Config::PAGE_SHIFT,
105 Mem_layout::Tbuf_ustatus_page, L4_fpage::Cached), 0);
107 for (Address size=0; size<Jdb_tbuf::size(); size+=Config::PAGE_SIZE)
109 mem_map (sigma0_task, // from: space
110 L4_fpage(0, 1, Config::PAGE_SHIFT,
111 Kmem::virt_to_phys ((const void*)
112 (Mem_layout::Tbuf_buffer_area+size))),
113 nonull_static_cast<Space*>(this), // to: space
114 L4_fpage(0, 0, Config::PAGE_SHIFT,
115 Mem_layout::Tbuf_ubuffer_area+size, L4_fpage::Cached), 0);
126 //unregister_space();
128 //dequeue_at_parent();
131 if (id() == Config::kernel_taskno)
133 reset_dirty(); // Must not deallocate kernel pagetable.
134 return; // No need to kill kernel process.
138 Lock_guard<Cpu_lock> guard (&cpu_lock);
140 pid_t hostpid = pid();
141 ptrace (PTRACE_KILL, hostpid, NULL, NULL);
143 while (waitpid (hostpid, NULL, 0) != hostpid)
150 Task::map_utcb_ptr_page()
152 //Mem_space::Status res =
153 mem_space()->v_insert(
154 Mem_space::Phys_addr::create(Mem_layout::Utcb_ptr_frame),
155 Mem_space::Addr::create(Mem_layout::Utcb_ptr_page_user),
156 Mem_space::Size::create(Config::PAGE_SIZE),
157 Mem_space::Page_writable
158 | Mem_space::Page_user_accessible
159 | Mem_space::Page_cacheable);