summaryrefslogtreecommitdiff
path: root/Kernel/KSyms.cpp
AgeCommit message (Collapse)Author
2023-06-04Kernel: Move all tasks-related code to the Tasks subdirectoryLiav A
2023-02-08Kernel: Add optional userspace backtrace to Process::crashTimon Kruiper
This is very useful for debugging the initial userspace applications, as the CrashReporter is not yet running.
2023-02-08Kernel/aarch64: Set kernel_load_base and correctly calculate symbol addrTimon Kruiper
Setting the kernel_load_base variable caused backtracking to regress, so to have proper backtracing the calculation of the symbol address in KSyms.cpp needs to keep into account that the aarch64 kernel is linked at a high virtual memory address.
2022-10-01Kernel: Add ability to dump backtrace from provided frame pointerTimon Kruiper
When an exception happens it is sometimes hard to figure out where exactly the exception happened, so use the frame pointer of the trap frame to print a backtrace.
2022-05-03Kernel: Move Kernel/Arch/x86/SafeMem.h to Kernel/Arch/SafeMem.hTimon Kruiper
The file does not contain any specific architectural code, thus it can be moved to the Kernel/Arch directory.
2022-05-03Kernel: Fetch the frame pointer using __builtin_frame_address()Timon Kruiper
This compiler builtin abstracts away the specifics of fetching the frame pointer. This will allow the KSyms.cpp to be build for the aarch64 target. While we're here, lets also change the PerformanceEventBuffer.cpp to not rely on x86_64 specifics.
2022-04-10Kernel: Use kernel_mapping_base as the minimum kernel stack addressIdan Horowitz
Since KASLR was added kernel_load_base only signifies the address at which the kernel image start, not the start of kernel memory, meaning that a valid kernel stack can be allocated before it in memory. We use kernel_mapping_base, the lowest address covered by the kernel page directory, as the minimal address when performing safety checks during backtrace generation.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-01-30Kernel: Remove unnecessary includes from Thread.hAndreas Kling
...and deal with the fallout by adding missing includes everywhere.
2021-12-28Kernel: Remove the kmalloc_eternal heap :^)Andreas Kling
This was a premature optimization from the early days of SerenityOS. The eternal heap was a simple bump pointer allocator over a static byte array. My original idea was to avoid heap fragmentation and improve data locality, but both ideas were rooted in cargo culting, not data. We would reserve 4 MiB at boot and only ended up using ~256 KiB, wasting the rest. This patch replaces all kmalloc_eternal() usage by regular kmalloc().
2021-12-24Kernel: Mark PTYMultiplexer init & parse_hex_digit as UNMAP_AFTER_INITBrian Gianforcaro
Noticed these boot only functions are not currently UNMAP_AFTER_INIT. Lets fix that :^)
2021-12-18Kernel: Use ksyms in-place instead of duplicating them into eternal heapAndreas Kling
We can leave the .ksyms section mapped-but-read-only and then have the symbols index simply point into it. Note that we manually insert null-terminators into the symbols section while parsing it. This gets rid of ~950 KiB of kmalloc_eternal() at startup. :^)
2021-12-13Kernel: Fix backtrace dumping on x86_64Luke Wilde
- dump_backtrace was using ebp instead of rbp on x86_64, only using the lower 32-bits of rbp. - The symbol loader was only fetching half of the pointer from the symbol table. (8 chars instead of 16 chars)
2021-11-11Everywhere: Pass AK::ReadonlyBytes by valueAndreas Kling
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-10-15Kernel: Split SmapDisabler so header is platform independentJames Mintram
A new header file has been created in the Arch/ folder while the implementation has been moved into a CPP living in the X86 folder.
2021-10-08Kernel: Fix -Wunreachable-code warnings from clangNico Weber
2021-09-07Kernel: Rename FileDescription => OpenFileDescriptionAndreas Kling
Dr. POSIX really calls these "open file description", not just "file description", so let's call them exactly that. :^)
2021-08-04Kernel: Print panic backtrace to both the screen and serialLuke
Previously it would only print the backtrace to serial, which would be inaccessible if you don't have serial setup.
2021-07-28Kernel: Print relative symbol addresses in dump_backtrace_implGunnar Beutner
By subtracting the load base we get addresses which the user can paste into addr2line.
2021-07-27Kernel: Support loading the kernel at almost arbitrary virtual addressesGunnar Beutner
This enables further work on implementing KASLR by adding relocation support to the pre-kernel and updating the kernel to be less dependent on specific virtual memory layouts.
2021-07-22Everywhere: Prefer using {:#x} over 0x{:x}Gunnar Beutner
We have a dedicated format specifier which adds the "0x" prefix, so let's use that instead of adding it manually.
2021-07-18Kernel: Introduce basic pre-kernel environmentGunnar Beutner
This implements a simple bootloader that is capable of loading ELF64 kernel images. It does this by using QEMU/GRUB to load the kernel image from disk and pass it to our bootloader as a Multiboot module. The bootloader then parses the ELF image and sets it up appropriately. The kernel's entry point is a C++ function with architecture-native code. Co-authored-by: Liav A <liavalb@gmail.com>
2021-07-14Kernel: Make kernel symbols available much earlier in the boot processGunnar Beutner
This adds a new section .ksyms at the end of the linker map, reserves 5MiB for it (which are after end_of_kernel_image so they get re-used once MemoryManager is initialized) and then embeds the symbol map into the kernel binary with objcopy. This also shrinks the .ksyms section to the real size of the symbol file (around 900KiB at the moment). By doing this we can make the symbol map available much earlier in the boot process, i.e. even before VFS is available.
2021-07-11Kernel: Rename VFS => VirtualFileSystemAndreas Kling
2021-07-06Kernel+LibELF: Don't demangle symbols in the kernelGunnar Beutner
Instead we should just generate kernel.map in such a way that it already contains demangled symbols.
2021-07-06Kernel: Fix method name load_kernel_{sybols => symbols}_from_data()Ali Mohammad Pur
2021-06-28Kernel: Make and use KERNEL_BASEHendiadyoin1
This is to make the 0xc0000000 less a magic number, and will make it easier in the future to move the Kernel around
2021-06-24Kernel: Move special sections into Sections.hHendiadyoin1
This also removes a lot of CPU.h includes infavor for Sections.h
2021-04-28Kernel: Check kernel symbol's name length matches searched nameIdan Horowitz
The current implementation would only check the first name.length() characters match, which means any kernel symbol that the provided name is a prefix of would match, instead of the actual matching symbol. This commit fixes that by using StringView::operator==() for the comparison, which already checks the equality correctly.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-12Kernel: Convert klog() => AK::Format in a handful of placesAndreas Kling
2021-03-10Kernel: Turn a VLA into a statically-sized array in dump_backtrace()Andreas Kling
2021-02-25Kernel: Move SMAP disabler RAII helper to its own fileAndreas Kling
Added this in a new directory called Kernel/Arch/x86/ where stuff that applies to both i386 and x86_64 can live.
2021-02-25Kernel: Take some baby steps towards x86_64Andreas Kling
Make more of the kernel compile in 64-bit mode, and make some things pointer-size-agnostic (by using FlatPtr.) There's a lot of work to do here before the kernel will even compile.
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-19Kernel: Slap UNMAP_AFTER_INIT on a bunch more functionsAndreas Kling
We're now able to unmap 100 KiB of kernel text after init. :^)
2021-02-03Everywhere: Remove some bitrotted "#if 0" blocksAndreas Kling
2021-01-22Kernel: Do not assert if unable to load kernel symbolsJean-Baptiste Boric
2021-01-09Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
2021-01-02Kernel+LibELF: Use hex instead of decimal for stack offsets in back traces ↵Brian Gianforcaro
(#4728) Hex is the de facto format for representing memory addresses, make backtraces conform to that convention.
2020-12-25Kernel+LibELF: Stop doing ELF symbolication in the kernelAndreas Kling
Now that the CrashDaemon symbolicates crashes in userspace, let's take this one step further and stop trying to symbolicate userspace programs in the kernel at all.
2020-12-18Kernel: Move KBufferBuilder to the fallible KBuffer APIAndreas Kling
KBufferBuilder::build() now returns an OwnPtr<KBuffer> and can fail. Clients of the API have been updated to handle that situation.
2020-12-14Kernel: Generate a coredump file when a process crashesItamar
When a process crashes, we generate a coredump file and write it in /tmp/coredumps/. The coredump file is an ELF file of type ET_CORE. It contains a segment for every userspace memory region of the process, and an additional PT_NOTE segment that contains the registers state for each thread, and a additional data about memory regions (e.g their name).
2020-09-13Kernel: Make copy_to/from_user safe and remove unnecessary checksTom
Since the CPU already does almost all necessary validation steps for us, we don't really need to attempt to do this. Doing it ourselves doesn't really work very reliably, because we'd have to account for other processors modifying virtual memory, and we'd have to account for e.g. pages not being able to be allocated due to insufficient resources. So change the copy_to/from_user (and associated helper functions) to use the new safe_memcpy, which will return whether it succeeded or not. The only manual validation step needed (which the CPU can't perform for us) is making sure the pointers provided by user mode aren't pointing to kernel mappings. To make it easier to read/write from/to either kernel or user mode data add the UserOrKernelBuffer helper class, which will internally either use copy_from/to_user or directly memcpy, or pass the data through directly using a temporary buffer on the stack. Last but not least we need to keep syscall params trivial as we need to copy them from/to user mode using copy_from/to_user.
2020-08-12Kernel: Mark compilation-unit-only functions as staticBen Wiederhake
This enables a nice warning in case a function becomes dead code. Also, in case of signal_trampoline_dummy, marking it external (non-static) prevents it from being 'optimized away', which would lead to surprising and weird linker errors. I found these places by using -Wmissing-declarations. The Kernel still shows these issues, which I think are false-positives, but don't want to touch: - Kernel/Arch/i386/CPU.cpp:1081:17: void Kernel::enter_thread_context(Kernel::Thread*, Kernel::Thread*) - Kernel/Arch/i386/CPU.cpp:1170:17: void Kernel::context_first_init(Kernel::Thread*, Kernel::Thread*, Kernel::TrapFrame*) - Kernel/Arch/i386/CPU.cpp:1304:16: u32 Kernel::do_init_context(Kernel::Thread*, u32) - Kernel/Arch/i386/CPU.cpp:1347:17: void Kernel::pre_init_finished() - Kernel/Arch/i386/CPU.cpp:1360:17: void Kernel::post_init_finished() No idea, not gonna touch it. - Kernel/init.cpp:104:30: void Kernel::init() - Kernel/init.cpp:167:30: void Kernel::init_ap(u32, Kernel::Processor*) - Kernel/init.cpp:184:17: void Kernel::init_finished(u32) Called by boot.S. - Kernel/init.cpp:383:16: int Kernel::__cxa_atexit(void (*)(void*), void*, void*) - Kernel/StdLib.cpp:285:19: void __cxa_pure_virtual() - Kernel/StdLib.cpp:300:19: void __stack_chk_fail() - Kernel/StdLib.cpp:305:19: void __stack_chk_fail_local() Not sure how to tell the compiler that the compiler is already using them. Also, maybe __cxa_atexit should go into StdLib.cpp? - Kernel/Modules/TestModule.cpp:31:17: void module_init() - Kernel/Modules/TestModule.cpp:40:17: void module_fini() Could maybe go into a new header. This would also provide type-checking for new modules.
2020-08-11Kernel: Make Inode::read_entire() return a KBuffer (not ByteBuffer)Andreas Kling
ByteBuffer is backed by kmalloc heap memory which is a scarce resource. This fixes an OOM panic when traversing a large directory.
2020-07-06Kernel: Add SMP IPI supportTom
We can now properly initialize all processors without crashing by sending SMP IPI messages to synchronize memory between processors. We now initialize the APs once we have the scheduler running. This is so that we can process IPI messages from the other cores. Also rework interrupt handling a bit so that it's more of a 1:1 mapping. We need to allocate non-sharable interrupts for IPIs. This also fixes the occasional hang/crash because all CPUs now synchronize memory with each other.
2020-07-01Kernel: Turn Thread::current and Process::current into functionsTom
This allows us to query the current thread and process on a per processor basis
2020-05-26Kernel: Plumb KResult through FileDescription::read_entire_file() ↵Brian Gianforcaro
implementation. Allow file system implementation to return meaningful error codes to callers of the FileDescription::read_entire_file(). This allows both Process::sys$readlink() and Process::sys$module_load() to return more detailed errors to the user.