summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2023-02-04Kernel+SystemServer+Base: Introduce the RAMFS filesystemLiav A
This filesystem is based on the code of the long-lived TmpFS. It differs from that filesystem in one keypoint - its root inode doesn't have a sticky bit on it. Therefore, we mount it on /dev, to ensure only root can modify files on that directory. In addition to that, /tmp is mounted directly in the SystemServer main (start) code, so it's no longer specified in the fstab file. We ensure that /tmp has a sticky bit and has the value 0777 for root directory permissions, which is certainly a special case when using RAM-backed (and in general other) filesystems. Because of these 2 changes, it's no longer needed to maintain the TmpFS filesystem, hence it's removed (renamed to RAMFS), because the RAMFS represents the purpose of this filesystem in a much better way - it relies on being backed by RAM "storage", and therefore it's easy to conclude it's temporary and volatile, so its content is gone on either system shutdown or unmounting of the filesystem.
2023-02-03Kernel/aarch64: Include Error.h to fix aarch64 missing ErrorOrSteffen Rusitschka
2023-02-03Kernel: Fix usermode verification in ptrace with PT_SETREGSItamar
When doing PT_SETREGS, we want to verify that the debugged thread is executing in usermode. b2f7ccf refactored things and flipped the relevant check around, which broke things that use PT_SETREGS (for example, stepping over breakpoints with sdb).
2023-02-02Kernel/Graphics: Export DDC I2C address definition to global header fileLiav A
2023-02-02Kernel: Split I2C functionality from IntelNativeDisplayConnector codeLiav A
Splitting the I2C-related code lets the DisplayConnector code to utilize I2C operations without caring about the specific details of the hardware and allow future expansion of the driver to other newer generations sharing the same GMBus code. We should require a timeout for GMBus operations always, because faulty hardware could let us just spin forever. Also, if nothing is listening to the bus (which should result in a NAK), we could also spin forever.
2023-02-02Kernel: Fix a long-standing problem with GMBus in Intel Grahpics codeLiav A
Thanks to Andrew Kaster, which gave a review back in October, about a big PR I opened (#15502), I managed to figure out why we always had a problem with the first byte being read into the EDID buffer with the GMBus code. It turns out that this simple invalid cast was making the entire problem and using the correct AK::Array::data() method fixed this notorious long standing problem for good.
2023-02-02Kernel: Remove trap based syscall handlingAgustin Gianni
This patch removes the x86 mechanism for calling syscalls, favoring the more modern syscall instruction. It also moves architecture dependent code from functions that are meant to be architecture agnostic therefore paving the way for adding more architectures.
2023-02-02Kernel: Change the way we call a syscall in signal_trampoline_dummyAgustin Gianni
The function signal_trampoline_dummy was using int 0x82 to call SC_sigreturn. Since x86 is no longer supported, the correct way to call a syscall is using the syscall instruction. This paves the way to remove the syscall trap handling mechanism.
2023-01-29AK: Deprecate the old `AK::Stream`Tim Schumacher
This also removes a few cases where the respective header wasn't actually required to be included.
2023-01-29Kernel/FileSystem: Simplify the ProcFS inode codeLiav A
This is done by merging all scattered pieces of derived classes from the ProcFSInode class into that one class, so we don't use inheritance but rather simplistic checks to determine the proper code for each ProcFS inode with its specific characteristics.
2023-01-28AK: Remove `try_` prefix from FixedArray creation functionsLinus Groh
2023-01-27Kernel/PCI: Pass DeviceIdentifier to get_BAR2 in BochsGraphicsAdapterTimon Kruiper
This change was forgotten in 1f9d3a3523d066a2bc80dd60e472f191492df2dd and broke the aarch64 build.
2023-01-27Kernel: Add Syscall.cpp to aarch64 buildTimon Kruiper
2023-01-27Kernel: Add Syscalls/execve.cpp to aarch64 buildTimon Kruiper
2023-01-27Kernel: Add ThreadRegisters::set_exec_state and use it in execve.cppTimon Kruiper
Using this abstraction it is possible to compile this file for aarch64.
2023-01-27Kernel/aarch64: Implement Processor::platform_string()Timon Kruiper
2023-01-27Kernel: Use InterruptsState abstraction in execve.cppTimon Kruiper
This was using the x86_64 specific cpu_flags abstraction, which is not compatible with aarch64.
2023-01-27Kernel: Add Syscalls/fork.cpp to aarch64 buildTimon Kruiper
2023-01-27Kernel: Add Syscalls/sigaction.cpp to aarch64 buildTimon Kruiper
2023-01-27Kernel: Add Syscalls/mmap.cpp to aarch64 buildTimon Kruiper
2023-01-27Kernel: Make Syscalls/ptrace.cpp buildable for aarch64Timon Kruiper
2023-01-27Kernel/aarch64: Implement set_return_reg and capture_syscall_paramsTimon Kruiper
2023-01-27Kernel/aarch64: Add stub for copy_ptrace_registers_into_kernel_registersTimon Kruiper
2023-01-27Kernel: Remove declarations for non-existent methodsSam Atkins
2023-01-27Kernel/aarch64: Set Access Permission (writable bit) on PageTableEntryTimon Kruiper
This will cause page faults to be generated. Since the previous commits introduced the handling of page faults, we can now actually correctly handle page faults.
2023-01-27Kernel/aarch64: Implement switching page directoriesTimon Kruiper
The code in PageDirectory.cpp now keeps track of the registered page directories, and actually sets the TTBR0_EL1 to the page table base of the currently executing thread. When context switching, we now also change the TTBR0_EL1 to the page table base of the thread that we context switch into.
2023-01-27Kernel/aarch64: Store and initialize TTBR0_EL1 in ThreadRegistersTimon Kruiper
2023-01-27Kernel/aarch64: Add helper to get the current TTBR0_EL1Timon Kruiper
2023-01-27Kernel/aarch64: Keep track of root page table and kernel directory tableTimon Kruiper
2023-01-27Kernel: Move Memory/PageDirectory.{cpp,h} to arch-specific directoryTimon Kruiper
The handling of page tables is very architecture specific, so belongs in the Arch directory. Some parts were already architecture-specific, however this commit moves the rest of the PageDirectory class into the Arch directory. While we're here the aarch64/PageDirectory.{h,cpp} files are updated to be aarch64 specific, by renaming some members and removing x86_64 specific code.
2023-01-27Kernel/aarch64: Implement initial page fault handlingTimon Kruiper
The shared code is moved to a common PageFault.cpp file.
2023-01-27Kernel/aarch64: Add stub for handle_safe_access_faultTimon Kruiper
2023-01-27Kernel: Refactor PageFault for use in the aarch64 portTimon Kruiper
The class used to look at the x86_64 specific exception code to figure out what kind of page fault happend, however this refactor allows aarch64 to use the same class.
2023-01-27Kernel: Factor our PreviousMode into RegisterState::previous_modeTimon Kruiper
Various places in the kernel were manually checking the cs register for x86_64, however to share this with aarch64 a function in RegisterState is added, and the call-sites are updated. While we're here the PreviousMode enum is renamed to ExecutionMode.
2023-01-27Kernel/aarch64: Execute kernel with SP_EL1 instead of SP_EL0Timon Kruiper
Until now the kernel was always executing with SP_EL0, as this made the initial dropping to EL1 a bit easier. This commit changes this behaviour to use the corresponding SP_ELx for each exception level. To make sure that the execution of the C++ code can continue, the current stack pointer is copied into the corresponding SP_ELx just before dropping an exception level.
2023-01-27Kernel/aarch64: Move exception handler to Interrupts.cppTimon Kruiper
Also dump the registers in a nicer format.
2023-01-26Kernel/PCI: Expose PCI option ROM data from the sysfs interfaceLiav A
For each exposed PCI device in sysfs, there's a new node called "rom" and by reading it, it exposes the raw data of a PCI option ROM blob to a user for examining the blob.
2023-01-26Kernel/PCI: Hold a reference to DeviceIdentifier in the Device classLiav A
There are now 2 separate classes for almost the same object type: - EnumerableDeviceIdentifier, which is used in the enumeration code for all PCI host controller classes. This is allowed to be moved and copied, as it doesn't support ref-counting. - DeviceIdentifier, which inherits from EnumerableDeviceIdentifier. This class uses ref-counting, and is not allowed to be copied. It has a spinlock member in its structure to allow safely executing complicated IO sequences on a PCI device and its space configuration. There's a static method that allows a quick conversion from EnumerableDeviceIdentifier to DeviceIdentifier while creating a NonnullRefPtr out of it. The reason for doing this is for the sake of integrity and reliablity of the system in 2 places: - Ensure that "complicated" tasks that rely on manipulating PCI device registers are done in a safe manner. For example, determining a PCI BAR space size requires multiple read and writes to the same register, and if another CPU tries to do something else with our selected register, then the result will be a catastrophe. - Allow the PCI API to have a united form around a shared object which actually holds much more data than the PCI::Address structure. This is fundamental if we want to do certain types of optimizations, and be able to support more features of the PCI bus in the foreseeable future. This patch already has several implications: - All PCI::Device(s) hold a reference to a DeviceIdentifier structure being given originally from the PCI::Access singleton. This means that all instances of DeviceIdentifier structures are located in one place, and all references are pointing to that location. This ensures that locking the operation spinlock will take effect in all the appropriate places. - We no longer support adding PCI host controllers and then immediately allow for enumerating it with a lambda function. It was found that this method is extremely broken and too much complicated to work reliably with the new paradigm being introduced in this patch. This means that for Volume Management Devices (Intel VMD devices), we simply first enumerate the PCI bus for such devices in the storage code, and if we find a device, we attach it in the PCI::Access method which will scan for devices behind that bridge and will add new DeviceIdentifier(s) objects to its internal Vector. Afterwards, we just continue as usual with scanning for actual storage controllers, so we will find a corresponding NVMe controllers if there were any behind that VMD bridge.
2023-01-25Kernel: Move Aarch64 MMU debug message into memory manager initializerkonrad
Doing so unifies startup debug messages visually.
2023-01-25Kernel: Use RDSEED assembly snippet to seed RNG on Aarch64konrad
There’s similar RDRAND register (encoded as ‘s3_3_c2_c4_0ʼ) to be added if needed. RNG CPU feature on Aarch64 guarantees existence of both RDSEED and RDRAND registers simultaneously—in contrast to x86-64, where respective instructions are independent of each other.
2023-01-25Kernel: Unify x86-64 assembly snippets naming for RDSEED & RDRANDkonrad
2023-01-25Kernel: Use existing assembly snippets for x86-64 RDSEED & RDRAND callskonrad
2023-01-24Kernel: Allow to remove files from sticky directory if user owns itKarol Kosek
It's what the Linux chmod(1) manpage says (in the 'Restricted Deletion Flag or Sticky Bit' section), and it just makes sense to me. :^)
2023-01-24Kernel/aarch64: Change base address of the kernel to 0x2000000000Timon Kruiper
This is the same address that the x86_64 kernel runs at, and allows us to run the kernel at a high virtual memory address. Since we now run completely in high virtual memory, we can also unmap the identity mapping. Additionally some changes in MMU.cpp are required to successfully boot.
2023-01-24Kernel/aarch64: Ensure global variable accesses work without MMU enabledTimon Kruiper
Since we link the kernel at a high virtual memory address, the addresses of global variables are also at virtual addresses. To be able to access them without the MMU enabled, we have to subtract the KERNEL_MAPPING_BASE.
2023-01-24Kernel/aarch64: Disable stack protector + sanitizers for MMU-less filesTimon Kruiper
Compile source files that run early in the boot process without the MMU enabled, without stack protector and sanitizers. Enabling them will cause the compiler to insert accesses to global variables, such as __stack_chk_guard, which cause the CPU to crash, because these variables are linked at high virtual addresses, which the CPU cannot access without the MMU enabled.
2023-01-24Kernel/aarch64: Add pre_init function for that sets up the CPU and MMUTimon Kruiper
This is a separate file that behaves similar to the Prekernel for x86_64, and makes sure the CPU is dropped to EL1, the MMU is enabled, and makes sure the CPU is running in high virtual memory. This code then jumps to the usual init function of the kernel.
2023-01-24Kernel/aarch64: Change MMU::kernel_virtual_range to high virtual memoryTimon Kruiper
This was previously hardcoded this to be the physical memory range, since we identity mapped the memory, however we now run the kernel at a high virtual memory address. Also changes PageDirectory.h to store up-to 512 pages, as the code now needs access to more than 4 pages.
2023-01-24Kernel/aarch64: Access MMIO using mapping in high virtual memoryTimon Kruiper
This ensures that we can unmap the identity mapping of the kernel in physical memory.
2023-01-24Kernel/aarch64: Use relative addressing in boot.STimon Kruiper
As the kernel is now linked at high address in virtual memory, we cannot use absolute addresses as they refer to high addresses in virtual memory. At this point in the boot process we are still running with the MMU off, so we have to make sure the accesses are using physical memory addresses.