summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2019-08-07Kernel: Remove unused MemoryManager::remove_identity_mapping()Andreas Kling
This was not actually used and just sitting there being confusing.
2019-08-07Kernel: Always give back VM to the RangeAllocator when unmapping RegionAndreas Kling
We were only doing this in Process::deallocate_region(), which meant that kernel-only Regions never gave back their VM. With this patch, we can start reusing freed-up address space! :^)
2019-08-07Kernel: Use KBufferBuilder to build ProcFS files and backtracesAndreas Kling
This is not perfect as it uses a lot of VM, but since the buffers are supposed to be temporary it's not super terrible. This could be improved by giving back the unused VM to the kernel's RangeAllocator after finishing the buffer building.
2019-08-07JSON: Templatize the JSON serialization codeAndreas Kling
This makes it possible to use something other than a StringBuilder for serialization (and to produce something other than a String.) :^)
2019-08-07Kernel: Don't create Function objects in the scheduling codeAndreas Kling
Each Function is a heap allocation, so let's make an effort to avoid doing that during scheduling. Because of header dependencies, I had to put the runnables iteration helpers in Thread.h, which is a bit meh but at least this cuts out all the kmalloc() traffic in pick_next().
2019-08-07Kernel: Disable kmalloc backtraces during backtrace generationAndreas Kling
If kmalloc backtraces are enabled during backtracing, things don't go super well when the backtrace code calls kmalloc().. With this fixed, it's basically possible to get all kmalloc backtraces on the debugger by running (as root): sysctl kmalloc_stacks=1
2019-08-07Kernel: Use a FixedArray for VMObject::m_physical_pagesAndreas Kling
This makes VMObject 8 bytes smaller since we can use the array size as the page count. The size() is now also computed from the page count instead of being a separate value. This makes sizes always be a multiple of PAGE_SIZE, which is sane.
2019-08-07Kernel: Split VMObject into two classes: Anonymous- and InodeVMObjectAndreas Kling
InodeVMObject is a VMObject with an underlying Inode in the filesystem. AnonymousVMObject has no Inode. I'm happy that InodeVMObject::inode() can now return Inode& instead of VMObject::inode() return Inode*. :^)
2019-08-07Kernel: Remove "allow CPU caching" flag on VMObjectAndreas Kling
This wasn't really thought-through, I was just trying anything to see if it would make WindowServer faster. This doesn't seem to make much of a difference either way, so let's just not do it for now. It's easy to bring back if we think we need it in the future.
2019-08-07Kernel: Remove VMObject namesAndreas Kling
The VMObject name was always either the owning region's name, or the absolute path of the underlying inode. We can reconstitute this information if wanted, no need to keep copies of these strings around.
2019-08-07DiskDevice: Add missing override and remove unnecessary class_name()Andreas Kling
This class needs to be fixed up to not hide the read()/write() virtuals at some point.
2019-08-06Meta: Make Serenity run on Bochs once againAndreas Kling
It's now possible to run Serenity inside Bochs by executing "./run b" Note that it only works with a GRUB image (i.e ./build-image-grub.sh)
2019-08-06Kernel: Add KBufferBuilder, similar to StringBuilder but for KBufferAndreas Kling
This class works by eagerly allocating 1MB of virtual memory but only adding physical pages on demand. In other words, when you append to it, its memory usage will increase by 1 page whenever you append across a page boundary (4KB.)
2019-08-06Kernel: For signal-killed threads, dump backtrace from finalizer threadAndreas Kling
Instead of dumping the dying thread's backtrace in the signal handling code, wait until we're finalizing the thread. Since signalling happens during scheduling, the less work we do there the better. Basically the less that happens during a scheduler pass the better. :^)
2019-08-06Kernel: Refactor TCP/IP stackConrad Pankoff
This has several significant changes to the networking stack. * Significant refactoring of the TCP state machine. Right now it's probably more fragile than it used to be, but handles quite a lot more of the handshake process. * `TCPSocket` holds a `NetworkAdapter*`, assigned during `connect()` or `bind()`, whichever comes first. * `listen()` is now virtual in `Socket` and intended to be implemented in its child classes * `listen()` no longer works without `bind()` - this is a bit of a regression, but listening sockets didn't work at all before, so it's not possible to observe the regression. * A file is exposed at `/proc/net_tcp`, which is a JSON document listing the current TCP sockets with a bit of metadata. * There's an `ETHERNET_VERY_DEBUG` flag for dumping packet's content out to `kprintf`. It is, indeed, _very debug_.
2019-08-06Kernel: Make KBuffer lazily populatedAndreas Kling
KBuffers are now zero-filled on demand instead of up front. This means that you can create a huge KBuffer and it will only take up VM, not physical pages (until you access them.)
2019-08-06Kernel: Allow zero-fill page faults on kernel-only pagesAndreas Kling
We were short-circuiting the page fault handler a little too eagerly for page-not-present faults in kernel memory. If the current page directory already has up-to-date mapps for kernel memory, allow it to progress to checking for zero-fill conditions. This will enable us to have lazily populated kernel regions.
2019-08-06Kernel: Add mapping from page directory base (PDB) to PageDirectoryAndreas Kling
This allows the page fault code to find the owning PageDirectory and corresponding process for faulting regions. The mapping is implemented as a global hash map right now, which is definitely not optimal. We can come up with something better when it becomes necessary.
2019-08-06Kernel: Break region_from_vaddr() into {user,kernel}_region_from_vaddrAndreas Kling
Sometimes you're only interested in either user OR kernel regions but not both. Let's break this into two functions so the caller can choose what he's interested in.
2019-08-06Kernel: Add LogStream operator<< for VirtualAddressAndreas Kling
2019-08-06Kernel: Don't treat read faults like CoW exceptionsAndreas Kling
I'm not sure why we would have a non-readable CoW region, but I suppose we could, so let's not Copy-on-Read in those cases.
2019-08-06Kernel: Clean up the page fault handling code a bitAndreas Kling
Not using "else" after "return" unnests the code and makes it easier to follow. Also use an enum for the two different page fault types.
2019-08-06KBuffer: Add set_size() and LogStream operator<<Andreas Kling
It will be useful to be able to set the "public" size of a KBuffer. It can still have a different amount of memory allocated internally.
2019-08-06Kernel: On kernel NP fault, always copy into *active* page directoryAndreas Kling
If we were using a ProcessPagingScope to temporarily go into another process's page tables, things would fall apart when hitting a kernel NP fault, since we'd clone the kernel page directory entry into the *currently active process's* page directory rather than cloning it into the *currently active* page directory.
2019-08-05SynthFS: Remove unused create_text_file() featureAndreas Kling
We don't need to support static text files in SynthFS, it's better to always use generators for everything.
2019-08-05Kernel+LibC: Support passing O_CLOEXEC to pipe()Sergey Bugaev
In the userspace, this mimics the Linux pipe2() syscall; in the kernel, the Process::sys$pipe() now always accepts a flags argument, the no-argument pipe() syscall is now a userspace wrapper over pipe2().
2019-08-05SynthFS: Oops, fix build.Andreas Kling
2019-08-05Kernel: Use KBuffers for ProcFS and SynthFSAndreas Kling
Instead of generating ByteBuffers and keeping those lying around, have these filesystems generate KBuffers instead. These are way less spooky to leave around for a while. Since FileDescription will keep a generated file buffer around until userspace has read the whole thing, this prevents trivially exhausting the kmalloc heap by opening many files in /proc for example. The code responsible for generating each /proc file is not perfectly efficient and many of them still use ByteBuffers internally but they at least go away when we return now. :^)
2019-08-05Kernel: Add a little comment header about KBufferAndreas Kling
2019-08-05Kernel: Make KBuffer a value-type wrapper around a KBufferImplAndreas Kling
A KBuffer always contains a valid KBufferImpl. If you need a "null" state buffer, use Optional<KBuffer>. This makes KBuffer very easy to work with and pass around, just like ByteBuffer before it.
2019-08-05IPv4: Remove an unnecessary copy of each outgoing IPv4 payloadAndreas Kling
There's no need for send_ipv4() to take a ByteBuffer&&, the data is immediately cooked into a packet and transmitted. Instead, just pass it the address+length of whatever buffer we've been using locally. The more we can reduce the pressure on kmalloc the better. :^)
2019-08-05Net: Let Socket have read/write wrappers around sendto/recvfromAndreas Kling
The situations in IPv4Socket and LocalSocket were mirrors of each other where one had implemented read/write as wrappers and the other had sendto/recvfrom as wrappers. Instead of this silliness, move read and write up to the Socket base. Then mark them final, so subclasses have no choice but to implement sendto and recvfrom.
2019-08-04Net: Use KBuffers for network adapter packet queuesAndreas Kling
This further reduces pressure on the kmalloc heap. :^)
2019-08-04Kernel: Flush the TLB (page only) when copying in a new kernel mappingAndreas Kling
Not flushing the TLB here puts us in an infinite page fault loop.
2019-08-04IPv4: Use KBuffer instead of ByteBuffer for socket receive queuesAndreas Kling
This drastically reduces the pressure on the kernel heap when receiving data from IPv4 sockets.
2019-08-04Kernel: Add KBuffer, a simple byte buffer backed by kernel-only memoryAndreas Kling
This memory is not accessible to userspace and comes from the kernel page allocator, not from the kmalloc heap. This makes it ideal for larger allocations.
2019-08-04Kernel: Remove more unused members of IPv4Socket.Andreas Kling
I thought I had included these in the previous commit, but it turns out I hadn't, duh.
2019-08-04Kernel: Remove a bunch of unused members in IPv4Socket.Andreas Kling
2019-08-04ChanViewer: Start working on a simple read-only 4Chan viewerAndreas Kling
Since they are nice enough to provide a JSON API over HTTP, this makes for a perfect way to exercise our networking code a bit. :^)
2019-08-04Kernel: Put IPv4 and TCP related debug spam behind flagsAndreas Kling
...and turn those flags off for now, to make it possible to write some networking code without being spammed to death.
2019-08-03AudioServer: Port to the new generated IPC mechanismAndreas Kling
Fork the IPC Connection classes into Server:: and Client::ConnectionNG. The new IPC messages are serialized very snugly instead of using the same generic data structure for all messages. Remove ASAPI.h since we now generate all of it from AudioServer.ipc :^)
2019-08-03LibIPC: Start fleshing out a separate IPC libraryAndreas Kling
This will be a place to put object serialization/deserialization logic, message parsing, endpoint management, etc.
2019-08-03IPCCompiler: Start working on a simple IPC definition languageAndreas Kling
Instead of doing everything manually in C++, let's do some codegen. This patch adds a crude but effective IPC definition parser, along with two initial definition files for the AudioServer's client and server endpoints.
2019-08-03Kernel+ProcessManager: Add some more info to /proc/PID/fdsAndreas Kling
- "seekable": whether the fd is seekable or sequential. - "class": which kernel C++ class implements this File. - "offset": the current implicit POSIX API file offset.
2019-08-02Kernel: mount() should fail if the provided device is not a disk deviceAndreas Kling
In the future, we should allow mounting any block device. At the moment there is too much filesystem code that depends on the underlying device being a DiskDevice.
2019-08-02Kernel: Generalize VFS metadata lookup and use it in mount() and stat()Andreas Kling
Refactored VFS::stat() into VFS::lookup_metadata(), which can now be used for general VFS metadata lookup by path.
2019-08-02Kernel: Align the KResult value storage appropriately.Andreas Kling
We should figure out how to convert this code to using AK::Result.
2019-08-02Kernel: Some improvements to the mount syscallAndreas Kling
- You must now have superuser privileges to use mount(). - We now verify that the mount point is a valid path first, before trying to find a filesystem on the specified device. - Convert some dbgprintf() to dbg().
2019-08-02Build: Add /dev/{hda,hdb,hdc,hdd} filesAndreas Kling
Now that we can mount additional hard drives, let's actually have some more device files in /dev so you can use them. :^)
2019-08-02Kernel: mount system call (#396)Jesse
It is now possible to mount ext2 `DiskDevice` devices under Serenity on any folder in the root filesystem. Currently any user can do this with any permissions. There's a fair amount of assumptions made here too, that might not be too good, but can be worked on in the future. This is a good start to allow more dynamic operation under the OS itself. It is also currently impossible to unmount and such, and devices will fail to mount in Linux as the FS 'needs to be cleaned'. I'll work on getting `umount` done ASAP to rectify this (as well as working on less assumption-making in the mount syscall. We don't want to just be able to mount DiskDevices!). This could probably be fixed with some `-t` flag or something similar.