mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:47:43 +00:00
Kernel: Rename Process::is_ring0/3 to Process::is_kernel/user_process
Since "rings" typically refer to code execution and user processes can also execute in ring 0, rename these functions to more accurately describe what they mean: kernel processes and user processes.
This commit is contained in:
parent
19ffd9d677
commit
0fab0ee96a
8 changed files with 18 additions and 23 deletions
|
@ -1393,7 +1393,7 @@ extern "C" void post_init_finished(void)
|
|||
|
||||
void Processor::initialize_context_switching(Thread& initial_thread)
|
||||
{
|
||||
ASSERT(initial_thread.process().is_ring0());
|
||||
ASSERT(initial_thread.process().is_kernel_process());
|
||||
|
||||
auto& tss = initial_thread.tss();
|
||||
m_tss = tss;
|
||||
|
|
|
@ -830,7 +830,7 @@ static Optional<KBuffer> procfs$all(InodeIdentifier)
|
|||
auto build_process = [&](const Process& process) {
|
||||
auto process_object = array.add_object();
|
||||
|
||||
if (process.is_ring3()) {
|
||||
if (process.is_user_process()) {
|
||||
StringBuilder pledge_builder;
|
||||
|
||||
#define __ENUMERATE_PLEDGE_PROMISE(promise) \
|
||||
|
|
|
@ -312,7 +312,7 @@ RefPtr<Process> Process::create_user_process(Thread*& first_thread, const String
|
|||
if (!root)
|
||||
root = VFS::the().root_custody();
|
||||
|
||||
auto process = adopt(*new Process(first_thread, parts.take_last(), uid, gid, parent_pid, Ring3, move(cwd), nullptr, tty));
|
||||
auto process = adopt(*new Process(first_thread, parts.take_last(), uid, gid, parent_pid, false, move(cwd), nullptr, tty));
|
||||
process->m_fds.resize(m_max_open_file_descriptors);
|
||||
auto& device_to_use_as_tty = tty ? (CharacterDevice&)*tty : NullDevice::the();
|
||||
auto description = device_to_use_as_tty.open(O_RDWR).value();
|
||||
|
@ -338,7 +338,7 @@ RefPtr<Process> Process::create_user_process(Thread*& first_thread, const String
|
|||
|
||||
NonnullRefPtr<Process> Process::create_kernel_process(Thread*& first_thread, String&& name, void (*e)(), u32 affinity)
|
||||
{
|
||||
auto process = adopt(*new Process(first_thread, move(name), (uid_t)0, (gid_t)0, ProcessID(0), Ring0));
|
||||
auto process = adopt(*new Process(first_thread, move(name), (uid_t)0, (gid_t)0, ProcessID(0), true));
|
||||
first_thread->tss().eip = (FlatPtr)e;
|
||||
|
||||
if (process->pid() != 0) {
|
||||
|
@ -352,7 +352,7 @@ NonnullRefPtr<Process> Process::create_kernel_process(Thread*& first_thread, Str
|
|||
return process;
|
||||
}
|
||||
|
||||
Process::Process(Thread*& first_thread, const String& name, uid_t uid, gid_t gid, ProcessID ppid, RingLevel ring, RefPtr<Custody> cwd, RefPtr<Custody> executable, TTY* tty, Process* fork_parent)
|
||||
Process::Process(Thread*& first_thread, const String& name, uid_t uid, gid_t gid, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd, RefPtr<Custody> executable, TTY* tty, Process* fork_parent)
|
||||
: m_name(move(name))
|
||||
, m_pid(allocate_pid())
|
||||
, m_euid(uid)
|
||||
|
@ -361,7 +361,7 @@ Process::Process(Thread*& first_thread, const String& name, uid_t uid, gid_t gid
|
|||
, m_gid(gid)
|
||||
, m_suid(uid)
|
||||
, m_sgid(gid)
|
||||
, m_ring(ring)
|
||||
, m_is_kernel_process(is_kernel_process)
|
||||
, m_executable(move(executable))
|
||||
, m_cwd(move(cwd))
|
||||
, m_tty(tty)
|
||||
|
@ -483,7 +483,7 @@ void Process::crash(int signal, u32 eip, bool out_of_memory)
|
|||
}
|
||||
m_termination_signal = signal;
|
||||
dump_regions();
|
||||
ASSERT(is_ring3());
|
||||
ASSERT(is_user_process());
|
||||
die();
|
||||
// We can not return from here, as there is nowhere
|
||||
// to unwind to, so die right away.
|
||||
|
|
|
@ -137,17 +137,12 @@ public:
|
|||
bool is_profiling() const { return m_profiling; }
|
||||
void set_profiling(bool profiling) { m_profiling = profiling; }
|
||||
|
||||
enum RingLevel : u8 {
|
||||
Ring0 = 0,
|
||||
Ring3 = 3,
|
||||
};
|
||||
|
||||
KBuffer backtrace() const;
|
||||
|
||||
bool is_dead() const { return m_dead; }
|
||||
|
||||
bool is_ring0() const { return m_ring == Ring0; }
|
||||
bool is_ring3() const { return m_ring == Ring3; }
|
||||
bool is_kernel_process() const { return m_is_kernel_process; }
|
||||
bool is_user_process() const { return !m_is_kernel_process; }
|
||||
|
||||
PageDirectory& page_directory() { return *m_page_directory; }
|
||||
const PageDirectory& page_directory() const { return *m_page_directory; }
|
||||
|
@ -576,7 +571,7 @@ private:
|
|||
friend class Scheduler;
|
||||
friend class Region;
|
||||
|
||||
Process(Thread*& first_thread, const String& name, uid_t, gid_t, ProcessID ppid, RingLevel, RefPtr<Custody> cwd = nullptr, RefPtr<Custody> executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
|
||||
Process(Thread*& first_thread, const String& name, uid_t, gid_t, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd = nullptr, RefPtr<Custody> executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
|
||||
static ProcessID allocate_pid();
|
||||
|
||||
Range allocate_range(VirtualAddress, size_t, size_t alignment = PAGE_SIZE);
|
||||
|
@ -654,11 +649,11 @@ private:
|
|||
};
|
||||
Vector<FileDescriptionAndFlags> m_fds;
|
||||
|
||||
RingLevel m_ring { Ring0 };
|
||||
u8 m_termination_status { 0 };
|
||||
u8 m_termination_signal { 0 };
|
||||
Atomic<u32> m_thread_count { 0 };
|
||||
|
||||
const bool m_is_kernel_process;
|
||||
bool m_dead { false };
|
||||
bool m_profiling { false };
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Kernel {
|
|||
|
||||
int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Vector<String> arguments, Vector<String> environment, RefPtr<FileDescription> interpreter_description, Thread*& new_main_thread, u32& prev_flags)
|
||||
{
|
||||
ASSERT(is_ring3());
|
||||
ASSERT(is_user_process());
|
||||
ASSERT(!Processor::current().in_critical());
|
||||
auto path = main_program_description->absolute_path();
|
||||
#ifdef EXEC_DEBUG
|
||||
|
|
|
@ -37,7 +37,7 @@ pid_t Process::sys$fork(RegisterState& regs)
|
|||
{
|
||||
REQUIRE_PROMISE(proc);
|
||||
Thread* child_first_thread = nullptr;
|
||||
auto* child = new Process(child_first_thread, m_name, m_uid, m_gid, m_pid, m_ring, m_cwd, m_executable, m_tty, this);
|
||||
auto* child = new Process(child_first_thread, m_name, m_uid, m_gid, m_pid, m_is_kernel_process, m_cwd, m_executable, m_tty, this);
|
||||
child->m_root_directory = m_root_directory;
|
||||
child->m_root_directory_relative_to_global_root = m_root_directory_relative_to_global_root;
|
||||
child->m_promises = m_promises;
|
||||
|
|
|
@ -34,8 +34,8 @@ KResult Process::do_kill(Process& process, int signal)
|
|||
// FIXME: Should setuid processes have some special treatment here?
|
||||
if (!is_superuser() && m_euid != process.m_uid && m_uid != process.m_uid)
|
||||
return KResult(-EPERM);
|
||||
if (process.is_ring0() && signal == SIGKILL) {
|
||||
klog() << "attempted to send SIGKILL to ring 0 process " << process.name().characters() << "(" << process.pid().value() << ")";
|
||||
if (process.is_kernel_process() && signal == SIGKILL) {
|
||||
klog() << "attempted to send SIGKILL to kernel process " << process.name().characters() << "(" << process.pid().value() << ")";
|
||||
return KResult(-EPERM);
|
||||
}
|
||||
if (signal != 0)
|
||||
|
|
|
@ -68,7 +68,7 @@ Thread::Thread(NonnullRefPtr<Process> process)
|
|||
// Only IF is set when a process boots.
|
||||
m_tss.eflags = 0x0202;
|
||||
|
||||
if (m_process->is_ring0()) {
|
||||
if (m_process->is_kernel_process()) {
|
||||
m_tss.cs = GDT_SELECTOR_CODE0;
|
||||
m_tss.ds = GDT_SELECTOR_DATA0;
|
||||
m_tss.es = GDT_SELECTOR_DATA0;
|
||||
|
@ -91,7 +91,7 @@ Thread::Thread(NonnullRefPtr<Process> process)
|
|||
m_kernel_stack_base = m_kernel_stack_region->vaddr().get();
|
||||
m_kernel_stack_top = m_kernel_stack_region->vaddr().offset(default_kernel_stack_size).get() & 0xfffffff8u;
|
||||
|
||||
if (m_process->is_ring0()) {
|
||||
if (m_process->is_kernel_process()) {
|
||||
m_tss.esp = m_tss.esp0 = m_kernel_stack_top;
|
||||
} else {
|
||||
// Ring 3 processes get a separate stack for ring 0.
|
||||
|
@ -504,7 +504,7 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
|
|||
ASSERT_INTERRUPTS_DISABLED();
|
||||
ASSERT(g_scheduler_lock.own_lock());
|
||||
ASSERT(signal > 0 && signal <= 32);
|
||||
ASSERT(!process().is_ring0());
|
||||
ASSERT(process().is_user_process());
|
||||
|
||||
#ifdef SIGNAL_DEBUG
|
||||
klog() << "signal: dispatch signal " << signal << " to " << *this;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue