summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-06-21Kernel: Add more entries to the list of valid E1000E device idsstelar7
2021-06-21Kernel: Fix assertion failure on large TTY writesDaniel Bertalan
The `File::can_write` mechanism lets us check that writes won't block, meaning some bytes can be immediately written to the underlying device. This means calling `File::write` in a situation where no data could be written is a logic error, which we `VERIFY()` in `Process::do_write()`. TTY, in particular, processes the write in 256-byte buffered chunks. Previously, we would assert that none of these sub-writes returned zero. This was a logic error, as this rejected some successful writes. For example, if there was exactly enough free space in `SlavePty`'s internal buffer for the previous sub-write to complete fully. This made it impossible to perform writes larger than `SlavePty`'s internal buffer. Note that it's not an issue if `on_tty_write` returns zero, as partial writes are handled correctly by the `buffer.read_buffered` helper. We won't spin in a loop trying to write to a full buffer. Fixes #8090
2021-06-20Kernel: Allow VGA-capable graphics adapters to exist with legacy VGATom
If we have a VGA-capable graphics adapter that we support, we should prefer it over any legacy VGA because we wouldn't use it in legacy VGA mode in this case. This solves the problem where we would only use the legacy VGA card when both a legacy VGA card as well as a VGA-mode capable adapter is present.
2021-06-19Kernel: Make sure threads which don't do any syscalls are terminatedGunnar Beutner
Steps to reproduce: $ cat loop.c int main() { for (;;); } $ gcc -o loop loop.c $ ./loop Terminating this process wasn't previously possible because we only checked whether the thread should be terminated on syscall exit.
2021-06-19Kernel: Make sure the kernel's ELF PHDRs don't use rwxGunnar Beutner
This doesn't really matter in terms of writability for the kernel text because we set up proper page mappings anyway which prohibit writing to the text segment. However, this makes the profiler happy which previously died when validating the kernel's ELF program headers.
2021-06-19Kernel: Don't use naked new statements in init processLiav A
Instead, try to create the device objects in separate static methods, and if we fail for some odd reason to allocate memory for such devices, just panic with that reason.
2021-06-18Kernel: Make the "in early boot" flag read-only-after-initAndreas Kling
2021-06-18Kernel: Add /proc/bus/usb to store information about connected devicesJesse Buhagiar
2021-06-18USB: Store device descriptor on enumerationJesse Buhagiar
We now store the device descriptor obtained from the device during enumeration in the device's object in memory instead of exposing all of the different members contained within it.
2021-06-18USB: Store devices in globally accessible arrayJesse Buhagiar
USB Devices are now stored so that they may be later retrieved and operated on (i.e, fetching their assigned device address via ProcFS)
2021-06-18Kernel: Fix crash when changing screen resolutionGunnar Beutner
Steps to reproduce: 1. Change resolution to 640x480. 2. Change resolution to 1280x1024. 3. Observe the following kernel panic: Kernel::__panic(char const*, unsigned int, char const*) +0x55 Kernel::handle_crash(Kernel::RegisterState&, char const*, ...) +0x112 page_fault_handler +0x1130 page_fault_asm_entry +0x26 Kernel::VirtualConsole::refresh_after_resolution_change() +0x35e4 Kernel::ConsoleManagement::resolution_was_changed() +0x38b Kernel::Graphics::FramebufferConsole::set_resolution(...) +0x3e1 Kernel::BochsGraphicsAdapter::try_to_set_resolution(...) +0x319 .L4213 +0x40a Kernel::Process::sys$ioctl(int, unsigned int, unsigned int) +0x2fa Kernel::Syscall::handle(Kernel::RegisterState&, ...) +0xfdc syscall_handler +0x19c0 Kernel::syscall_asm_entry_dummy() +0x31
2021-06-18Kernel: Correctly decode proc_file_type from identifierTim Schumacher
inode identifiers in ProcFS are encoded in a way that the parent ID is shifted 12 bits to the left and the PID is shifted by 16 bits. This means that the rightmost 12 bits are reserved for the file type or the fd. Since the to_fd and to_proc_file_type decoders only decoded the rightmost 8 bits, decoded values would wrap around beyond values of 255, resulting in a different value compared to what was originally encoded.
2021-06-18Kernel: Fix CPUID usage inside cpu_detect()Jean-Baptiste Boric
Since no features inside the 0x80000001 leaf are required for SerenityOS to work, don't assert if it's unavailable.
2021-06-18Kernel: Use FXSR feature only if supported by CPUJean-Baptiste Boric
If FXSR is not present, fall back to fnsave and frstor instructions. These instructions aren't available on the canonical i686 CPU which is the Pentium Pro processor.
2021-06-18Kernel: Detect support for CPUID FXSRJean-Baptiste Boric
The fxsave and fxrstor instructions are available only if the FXSR feature is present.
2021-06-17Kernel: Update check in Inode::read_entireGunnar Beutner
The nread variable can't be less than zero anymore.
2021-06-17Kernel: Remove obsolete size_t castsGunnar Beutner
2021-06-17Kernel: Add a VERIFY() to make sure our DMA address is validGunnar Beutner
This checks whether the address we're trying to use for DMA is low enough so as not to overflow the I/O register.
2021-06-17Kernel: Move super_pages section into the bottom 16MBGunnar Beutner
This ensures that pages returned by MM.allocate_supervisor_physical_page() have a physical address that is in the bottom 16MB and can thus be used by the SB16 driver for DMA. Fixes #8092.
2021-06-17Kernel: Make sure the kernel is re-linked when the linker script changesGunnar Beutner
2021-06-17Kernel: Fix incorrect argument nameGunnar Beutner
2021-06-17Kernel/Interrupts: Return boolean on whether we handled the interruptLiav A
If we are in a shared interrupt handler, the called handlers might indicate it was not their interrupt, so we should not increment the call counter of these handlers.
2021-06-17Kernel/VirtIO: Indicate we handling unknown interrupt early when calledLiav A
2021-06-17Kernel/Interrupts: Add sensible purposes to VirtIO and USB devicesLiav A
When we enumerate the interrupt handlers, it's a good idea to show a meaningful name to the user instead of "IRQ Handler".
2021-06-17Kernel/Interrupts: Enumerate nested handlers in a shared handlerLiav A
When asked to enumerate all interrupt handlers, display all shared handlers within it instead of just returning the responsible handler of them.
2021-06-16Kernel: Remove various other uses of ssize_tGunnar Beutner
2021-06-16Kernel: Use KResultOr<size_t> for the DoubleBuffer classGunnar Beutner
2021-06-16Kernel: Use KResultOr<size_t> throughout the TTY subsystemGunnar Beutner
Previously the VirtualConsole::on_tty_write() method would return an incorrect value when an error had occurred. This prompted me to update the TTY subsystem to use KResultOr<size_t> everywhere.
2021-06-16Kernel: Replace TimerQueue InlinedLinkedList usage with IntrusiveListBrian Gianforcaro
Note that there are a few minor differences between the InlineLinekdList and IntrusiveList API, so this isn't just a pure data structure change. - first()/last() instead of head()/tail() - There is no need for a for_each(..) implementation, as it already exposes the ability to do range based for loops.
2021-06-16Kernel: Remove unused header includes from TimerQueue.cppBrian Gianforcaro
CLion found these, remove them.
2021-06-15Kernel/AHCI: Don't set the C command header attributeLuke
This has a quirk with the AMD Hudson-2 SATA controller. [1022:7801] Having this flag set makes the controller become stuck in a busy loop. I decided to remove the flag instead of making it a quirk as it still works with Qemu, VirtualBox, VMware Player and the Intel Wildcat Point-LP SATA Controller [8086:9c83] without it, thus making it simpler to just remove it. Partial fix for #7738 (as it still does not work in IDE mode)
2021-06-14Kernel: Verify Process coredump threads are emptyJelle Raaijmakers
2021-06-14Kernel: Only call `Process::die()` once on terminating signalJelle Raaijmakers
Previously, when e.g. the `SIGABRT` signal was sent to a process, `Thread::dispatch_signal()` would invoke `Process::terminate_due_to_signal()` which would then `::die()`. The result `DispatchSignalResult::Terminate` is then returned to `Thread::check_dispatch_pending_signal()` which proceeds to invoke `Process::die()` a second time. Change the behavior of `::check_dispatch_pending_signal()` to no longer call `Process::die()` if it receives `::Terminate` as a signal handling result, since that indicates that the process was already terminated. This fixes #7289.
2021-06-13Kernel: Pass absolute path to shebang interpreterJelle Raaijmakers
When you invoke a binary with a shebang line, the `execve` syscall makes sure to pass along command line arguments to the shebang interpreter including the path to the binary to execute. This does not work well when the binary lives in $PATH. For example, given this script living in `/usr/local/bin/my-script`: #!/bin/my-interpreter echo "well hello friends" When executing it as `my-script` from outside `/usr/local/bin/`, it is executed as `/bin/my-interpreter my-script`. To make sure that the interpreter can find the binary to execute, we need to replace the first argument with an absolute path to the binary, so that the resulting command is: /bin/my-interpreter /usr/local/bin/my-script
2021-06-13Kernel: Also `move()` the shebang path in execveJelle Raaijmakers
2021-06-12USB: Further Implement USB StructuresJesse Buhagiar
These are the actual structures that allow USB to work (i.e the ones actually defined in the specification). This should provide us enough of a baseline implementation that we can build on to support different types of USB device.
2021-06-12AK: Rename Vector::append(Vector) => Vector::extend(Vector)Andreas Kling
Let's make it a bit more clear when we're appending the elements from one vector to the end of another vector.
2021-06-11Kernel: Use m_inode to stat in FileDescription::stat() if availableMax Wipfli
This is necessary since the Device class does not hold a reference to its inode (because there could be multiple), and thus doesn't override File::stat(). For simplicity, we should just always stat via the inode if there is one, since that shouldn't ever be the wrong thing. This partially reverts #7867.
2021-06-11Kernel: Add missing BrightWhite color to VirtualConsoleDaniel Bertalan
Because of the 'default' label, the compiler did not warn about the missing field. The `VERIFY_NOT_REACHED` was moved out of the switch to fix this.
2021-06-11Kernel: Block writes while we're establishing the TCP connectionGunnar Beutner
Previously we would not block the caller until the connection was established and would instead return EPIPE for the first send() call which then likely caused the caller to abandon the socket. This was broken by 0625342.
2021-06-11Kernel: Print stack traces for crashes in release buildsGunnar Beutner
Previously we'd just reset the CPU and reboot.
2021-06-11Kernel: Enable VERIFY() checks even if the DEBUG macro is not definedGunnar Beutner
Fixes #7910.
2021-06-11Kernel: Increase m_bytes_out only once during transmissionIdan Horowitz
We were accidentally increasing m_bytes_out by the packet size and then immediately calling send_packet(), which did the same thing as well.
2021-06-10Kernel: Add support for the RTL8168E-VL variant to the RTL8168 driverLuke
Specifically chip version 17.
2021-06-10Kernel: Add driver for RTL8168 & RTL8111 NICsIdan Horowitz
These are pretty common on older LGA1366 & LGA1150 motherboards. NOTE: Since the registers datasheets for all versions of the chip besides versions 1 - 3 are still under NDAs i had to collect several "magical vendor constants" from the *BSD driver and the linux driver that i was not able to name verbosely, and as such these are labeled with the comment "vendor magic values".
2021-06-10Kernel: Re-render console after echoing charactersDaniel Bertalan
If we do not flush the dirty lines, characters typed in canonical mode only appear after the virtual console has been switched away from, or the application has been killed. Instead, we now immediately perform the flush.
2021-06-10Kernel+LibVT: Fix selection with scrollback wrap-aroundDaniel Bertalan
If lines are removed from the tail of the scrollback buffer, the previous line indices will refer to different lines; therefore we need to offset them.
2021-06-10Kernel+LibVT: Implement left-right scrollingDaniel Bertalan
This commit implements the left/right scrolling used in the `ICH`/`DCH` escape sequences for `VirtualConsole`. This brings us one step closer to VT420/xterm compatibility. We can now finally remove the last escape sequence related `ifdef`s.
2021-06-10Kernel+LibVT: Add function for deleting a range of charactersDaniel Bertalan
Previously, this was done by telling the client to put a space at each character in the range. This was inefficient, because a large number of function calls took place and incorrect, as the ANSI standard dictates that character attributes should be cleared as well. The newly added `clear_in_line` function solves this issue. It performs just one bounds check when it's called and can be implemented as a pretty tight loop.
2021-06-10LibVT+Kernel: Support clearing the scrollback bufferDaniel Bertalan
As per the `xterm ctlseqs` documentation, `\e3J` should clear the scrollback buffer, and leave the visible lines unchanged. This commit fixes a FIXME.