summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
AgeCommit message (Collapse)Author
2019-06-02AK: Add implicit String -> StringView conversionRobin Burchell
And tidy up existing view() users.
2019-06-02Kernel: Make better use of the multiboot info.Andreas Kling
Define the multiboot info struct properly so we don't have to grab at byte offsets in the memory access checker code. Also print kernel command line in init().
2019-06-01Kernel: Add fchown() syscall.Andreas Kling
2019-06-01Kernel: Set the absolute path as name for executable regions.Andreas Kling
2019-05-31Kernel: Discard a process's ELFLoader on finalization.Andreas Kling
We don't need after that point, and throwing it out might free up some cached data used for backtraces.
2019-05-31Kernel: Process finalization should release cwd and executable custodies.Andreas Kling
Since Process destruction happens with interrupts disabled, it's not safe to still hold custodies at that point. Drop them in finalization.
2019-05-31Kernel: Do a bit more of do_exec() before disabling interrupts.Andreas Kling
We definitely need to replace m_executable before clearing interrupts, since otherwise we might call ~Custody() which would make it assert in locking. Also avoid calling FileDescriptor::metadata() repeatedly and just cache the result from the first call. I also added a comment at the point where we've decided to commit to the new executable and follow through with the swap.
2019-05-30Kernel: The stat() syscall should follow symlinks.Andreas Kling
2019-05-30Kernel: Rename Process::cwd_custody() to Process::current_directory().Andreas Kling
...and executable_custody() to just executable().
2019-05-30FileSystem: Port most of the code over to using custodies.Andreas Kling
The current working directory is now stored as a custody. Likewise for a process executable file. This unbreaks /proc/PID/fd which has not been working since we made the filesystem bigger. This still needs a bunch of work, for instance when renaming or removing a file somewhere, we have to update the relevant custody links.
2019-05-30Kernel: Make the Process allocate_region* API's understand "int prot".Andreas Kling
Instead of having to inspect 'prot' at every call site, make the Process API's take care of that so we can just pass it through.
2019-05-30Kernel: Make fcntl(F_SETFL) actually update the append/blocking flags.Andreas Kling
2019-05-30Kernel: Add InodeFile, a File subclass for regular files.Andreas Kling
Finally everything that can be held by a FileDescriptor actually inherits from the File class.
2019-05-30Kernel/LibC: Implement sched_* functionality to set/get process priorityRobin Burchell
Right now, we allow anything inside a user to raise or lower any other process's priority. This feels simple enough to me. Linux disallows raising, but that's annoying in practice.
2019-05-26Kernel: Sending a signal to yourself should block until dispatch.Andreas Kling
By moving the sending (and receiving) thread into the BlockedSignal state, we ensure that the thread doesn't continue executing until the signal has been dispatched.
2019-05-26Kernel: Send more specific signals when crashing due to CPU exceptions.Andreas Kling
- For division by zero, send SIGFPE. - For illegal instruction, send SIGILL. - For the rest, default to SIGSEGV.
2019-05-26Kernel: Support O_APPENDRobin Burchell
As per the manpage, this acts as a transparent lseek() before write.
2019-05-23Kernel/AK: Move ELF loader to AKRobin Burchell
This is in preparation for eventually using it in userspace. LinearAddress.h has not been moved for the time being (as it seems to be only used by a very small part of the code).
2019-05-23Kernel: getpeername() should fail with ENOTCONN for non-connected sockets.Andreas Kling
2019-05-22Kernel: Forked children should inherit their RangeAllocator by copy.Andreas Kling
Otherwise we'll start handing out addresses that are very likely already in use by existing ranges.
2019-05-20Kernel: Add getpeername() syscall, and fix getsockname() behavior.Andreas Kling
We were copying the raw IPv4 addresses into the wrong part of sockaddr_in, and we didn't set sa_family or sa_port.
2019-05-20Kernel: Let PageDirectory own the associated RangeAllocator.Andreas Kling
Since we transition to a new PageDirectory on exec(), we need a matching RangeAllocator to go with the new directory. Instead of juggling this in Process and MemoryManager, simply attach the RangeAllocator to the PageDirectory instead. Fixes #61.
2019-05-20Kernel: Add support for recv() with MSG_DONTWAIT.Andreas Kling
Passing this flag to recv() temporarily puts the file descriptor into non-blocking mode. Also implement LocalSocket::recv() as a simple forwarding to read().
2019-05-19Kernel+LibC: Implement getsockname() syscall.Andreas Kling
2019-05-19LibC: Add mmap_with_name() that names the allocation immediately.Andreas Kling
This allows us to skip the separate call to set_mmap_name() in code that we control, e.g malloc() and GraphicsBitmap.
2019-05-19Kernel: Check can_write for blocking writeRobin Burchell
This way the socket write buffer sizes are respected, and things that exceed them get sent EAGAIN.
2019-05-19Kernel: Add the ability to debug poll/select independently of read/writeRobin Burchell
2019-05-18Kernel: Fix select with a 0 timeoutRobin Burchell
select essentially has 3 modes (which is presumably why we're finding it so hard to get this right in a reliable way :)). 1. NULL timeout -- no timeout on blocking 2. non-NULL timeout that is not zero'd -- timeout on blocking 3. non-NULL but zero timeout -- no blocking at all (immediate poll) For cases 1 and 2, we want to block the thread. We have a timeout set only for case 2, though. Case 3 should not block the thread, and does not have a timeout set.
2019-05-18Kernel: Tidy up FileDescriptor members a bit.Andreas Kling
2019-05-18Kernel: Fix poll() with timeoutRobin Burchell
2019-05-18Kernel: select() was transferring the readfds into the exceptfds vector.Andreas Kling
Just a mistake I spotted while reading the code. We don't actually detect exceptional descriptor events yet.
2019-05-18Kernel: Pass ELF program header locations from multiboot to kernel.Andreas Kling
Patch contributed by "pd"
2019-05-18Kernel: Make sure to clear FD sets when preparing for a selectRobin Burchell
NULL sets can happen, and we don't want to incorrectly return FDs which aren't in the set too.
2019-05-18Kernel: Fix timeout support in selectRobin Burchell
The scheduler expects m_select_timeout to act as a deadline. That is, it should contain the time that a task should wake at -- but we were directly copying the time from userspace, which meant that it always returned virtually immediately. At the same time, fix CEventLoop to not rely on the broken select behavior by subtracting the current time from the time of the nearest timer.
2019-05-17Kernel: Make the times() syscall return something other than 0.Andreas Kling
Based on the description I read, this syscall doesn't seem completely reasonable, but let's at least return a number that is likely to change between invocations in case somebody depends on that happening.
2019-05-17Kernel/Process: Use auto to avoid incompatible types, causing a signedness ↵Robin Burchell
warning in the ASSERT
2019-05-17Kernel: Remove some unnecessary massaging of region base/size pairs.Andreas Kling
These will be appropriately rounded by the allocate_range(), so call sites can stop worrying about it.
2019-05-17Kernel: Factor out range allocation from Process::allocate_region*().Andreas Kling
These functions were doing exactly the same thing for range allocation, so share that code in an allocate_range() helper. Region allocation will now also fail if range allocation fails, which means that mmap() can actually fail without falling apart. Exciting times!
2019-05-17Kernel: Let Region keep a Range internally.Andreas Kling
2019-05-17Kernel: Remove Process::m_next_address.Andreas Kling
This isn't needed now that we have RangeAllocator. :^)
2019-05-17Kernel: Implement a simple virtual address range allocator.Andreas Kling
This replaces the previous virtual address allocator which was basically just "m_next_address += size;" With this in place, virtual addresses can get reused, which cuts down on the number of page tables created. When we implement ASLR some day, we'll probably have to do page table deallocation, but for now page tables are only deallocated once the process dies.
2019-05-16Kernel: Always dump_backtrace() on process crash.Andreas Kling
2019-05-16Kernel: Symbolicate userspace backtraces using ELFLoader.Andreas Kling
Stash away the ELFLoader used to load an executable in Process so we can use it for symbolicating userspace addresses later on. This will make debugging userspace programs a lot nicer. :^)
2019-05-16Kernel: Simplify dump_backtrace() API for clients.Andreas Kling
It makes no sense that clients had to worry about whether or not KSyms were loaded.
2019-05-14Kernel: Allocate kernel signal stacks using the region allocator as well.Andreas Kling
2019-05-14Kernel: Allocate kernel stacks for threads using the region allocator.Andreas Kling
This patch moves away from using kmalloc memory for thread kernel stacks. This reduces pressure on kmalloc (16 KB per thread adds up fast) and prevents kernel stack overflow from scribbling all over random unrelated kernel memory.
2019-05-10Kernel: Add a writev() syscall for writing multiple buffers in one go.Andreas Kling
We then use this immediately in the WindowServer/LibGUI communication in order to send both message + optional "extra data" with a single syscall.
2019-05-06Kernel: Dump backtrace on exit() syscall.Andreas Kling
This makes assertion failures a lot more pleasant to investigate.
2019-05-04IPv4: Save the source address/port together with incoming packet payloads.Andreas Kling
We need the address/port to fill in the out-params in recvfrom(). It should now be more or less possible to create a UDP server. :^)
2019-05-03Kernel+Userland: Implement mknod() syscall and add a /bin/mknod program.Andreas Kling