summaryrefslogtreecommitdiff
path: root/Kernel/Heap
AgeCommit message (Collapse)Author
2020-02-17Kernel: Replace "current" with Thread::current and Process::currentAndreas Kling
Suggested by Sergey. The currently running Thread and Process are now Thread::current and Process::current respectively. :^)
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-02-09Kernel: Apply changes to use LibBareMetal definitionsLiav A
2020-02-02Kernel: Remove unnecessary forward declaration in SlabAllocatorAndreas Kling
2020-02-01Kernel: Add memory scrubbing in slab_alloc() and slab_dealloc()Andreas Kling
These now scrub allocated and freed memory like kmalloc()/kfree() was already doing.
2020-02-01Kernel: Add crash logging heuristic for uninitialized kmalloc()/kfree()Andreas Kling
Since we scrub both kmalloc() and kfree() with predictable values, we can log a helpful message when hitting a crash that looks like it might be a dereference of such scrubbed data.
2020-01-27Kernel: Never validate access to the kmalloc memory rangeAndreas Kling
Memory validation is used to verify that user syscalls are allowed to access a given memory range. Ring 0 threads never make syscalls, and so will never end up in validation anyway. The reason we were allowing kmalloc memory accesses is because kernel thread stacks used to be allocated in kmalloc memory. Since that's no longer the case, we can stop making exceptions for kmalloc in the validation code.
2020-01-25Build: Remove -fno-sized-deallocation -Wno-sized-deallocationAndreas Kling
Add sized variants of the global operator delete functions so we don't have to use these GCC options anymore.
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-17Kernel: Move kernel above the 3GB virtual address markAndreas Kling
The kernel and its static data structures are no longer identity-mapped in the bottom 8MB of the address space, but instead move above 3GB. The first 8MB above 3GB are pseudo-identity-mapped to the bottom 8MB of the physical address space. But things don't have to stay this way! Thanks to Jesse who made an earlier attempt at this, it was really easy to get device drivers working once the page tables were in place! :^) Fixes #734.
2019-11-27Kernel: Demangle userspace ELF symbols in backtracesAndreas Kling
Turns out we can use abi::__cxa_demangle() for this, and all we need to provide is sprintf(), realloc() and free(), so this patch exposes them. We now have fully demangled C++ backtraces :^)
2019-11-23Revert "Kernel: Move Kernel mapping to 0xc0000000"Andreas Kling
This reverts commit bd33c6627394b2166e1419965dd3b2d2dc0c401f. This broke the network card drivers, since they depended on kmalloc addresses being identity-mapped.
2019-11-22Kernel: Move Kernel mapping to 0xc0000000Jesse Buhagiar
The kernel is now no longer identity mapped to the bottom 8MiB of memory, and is now mapped at the higher address of `0xc0000000`. The lower ~1MiB of memory (from GRUB's mmap), however is still identity mapped to provide an easy way for the kernel to get physical pages for things such as DMA etc. These could later be mapped to the higher address too, as I'm not too sure how to go about doing this elegantly without a lot of address subtractions.
2019-11-15Kernel: Unbreak SlabAllocator after startup-time constructorsAndreas Kling
Now that the kernel supports startup-time constructors, we were first doing slab_alloc_init(), and then the constructors ran later on, zeroing out the freelist pointers. This meant that all slab allocators thought they were completelty exhausted and forwarded all requests to kmalloc() instead.
2019-11-04Kernel: Reorganize memory layout a bitAndreas Kling
Move the kernel image to the 1 MB physical mark. This prevents it from colliding with stuff like the VGA memory. This was causing us to end up with the BIOS screen contents sneaking into kernel memory sometimes. This patch also bumps the kmalloc heap size from 1 MB to 3 MB. It's not the perfect permanent solution (obviously) but it should get the OOM monkey off our backs for a while.
2019-10-10Kernel: Make SlabAllocator fall back to kmalloc() when slabs run outAndreas Kling
This is obviously not ideal, and it would be better to teach it how to allocate more pages, etc. But since the physical page allocator itself currently uses SlabAllocator, it's a little bit tricky :^)
2019-10-02Kernel: Allocate more 8-byte slabs than anything elseAndreas Kling
We need these for PhysicalPage objects. Ultimately I'd like to get rid of these objects entirely, but while we still have to deal with them, let's at least handle large demand a bit better.
2019-09-27Kernel: Tweak SlabAllocator size classesAndreas Kling
Shrink the 52 class down to 48 since it was mostly made for Region, and Region just shrank to 48 :^)
2019-09-16Kernel: Add a simple slab allocator for small allocationsAndreas Kling
This is a freelist allocator with static size classes that works as a complement to the generic kmalloc(). It's a lot faster than kmalloc() since allocation just means popping from the freelist. It's also significantly more compact when there are a lot of objects smaller than the minimum kmalloc chunk size (32 bytes.) This patch enables it for the Region and PhysicalPage classes. In the PhysicalPage (8 bytes) case, it's a huge improvement since we no longer waste 75% of the storage allocated. There are also a number of ways this can be improved, so let's keep working on it going forward.
2019-09-16Kernel: Move kmalloc() into a Kernel/Heap/ directoryAndreas Kling