summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-08-31Kernel/VirtIO: Move everything into the VirtIO namespaceLiav A
Before of this change, many specific classes to VirtIO were in the Kernel namespace, which polluted it. Everything should be more organized now, but there's still room for improvement later.
2021-08-31Kernel/VirtIO: Remove the m_class_name memberLiav A
This class member was used only to determine the device type when printing messages to the debug log. Instead, remove this class member, and add a quick way to find the device type according to how the VirtIO specification says to do that. This simplifies construction of VirtIODevices a bit, because now the constructor doesn't need to ask for a String identified with the device type.
2021-08-31Kernel/PCI: Fix offset error of the PCI_SUBSYSTEM valuesLiav A
Apparently both PCI_SUBSYSTEM_ID and PCI_SUBSYSTEM_VENDOR_ID offsets should be swapped from one to another to be correct.
2021-08-31Kernel/VirtIO: Make RNG device to not be a CharacterDeviceLiav A
This class as a CharacterDevice really was not useful, because you couldn't even read from it. Also, the random number generator interface should be the /dev/random, so any other interface to get random numbers is generally not a good idea. Instead, let's keep this functionality as an entropy source for random numbers generation, but without exposing a device node.
2021-08-31Kernel: Ignore zero-sized PT_LOAD headers when loading ELF imagesAndreas Kling
2021-08-31Kernel/Userland: Expose usb device address and use it in `lsusb`Jesse Buhagiar
We now expose the `USBDevice`'s address in the SysFS object. This means that device addresses are no longer determined by the name of the file in the `/bus/usb/` directory. This was an incorrect way of determining device address, as a standard PC can have multiple USB controllers (and hence multiple buses) that can have overlapping device IDs.
2021-08-31Kernel: Don't VERIFY_NOT_REACHED in LocalSocket::has_attached_peer()Owen Smith
Invoking sendmsg on a listening socket triggers this assertion as sendto calls has_attached_peer before checking the result of send_buffer_for.
2021-08-30Kernel: Fix shift sometimes staying pressed after releasing the keyLepkoQQ
Previous implementation sometimes didn't release the key after pressing and holding shift due to repeating key updates when holding keys. This meant repeating updates would set/unset `m_both_shift_keys_pressed` repeatedly, sometimes resulting in shift still being considered pressed even after you released it. Simplify left and right shift key pressed logic by tracking both key states separately and always updating modifiers based on them.
2021-08-30Kernel: Fix Clang not initializing `s_bsp_processor` correctlyDaniel Bertalan
Initializing the variable this way fixes a kernel panic in Clang where the object was zero-initialized, so the `m_in_scheduler` contained the wrong value. GCC got it right, but we're better off making this change, as leaving uninitialized fields in constant-initialized objects can cause other weird situations like this. Also, initializing only a single field to a non-zero value isn't worth the cost of no longer fitting in `.bss`. Another two variables suffer from the same problem, even though their values are supposed to be zero. Removing these causes the `_GLOBAL_sub_I_` function to no longer be generated and the (not handled) `.init_array` section to be omitted.
2021-08-30Everywhere: Pass AK::Format TypeErasedFormatParams by referenceBrian Gianforcaro
This silences a overeager warning in sonar cloud, warning that slicing could occur with `VariadicFormatParams` which derives from `TypeErasedFormatParams`. Reference: https://sonarcloud.io/project/issues?id=SerenityOS_serenity&issues=AXuVPBO_k92xXUF3qWsm&open=AXuVPBO_k92xXUF3qWsm
2021-08-30Kernel: Unbreak the LOCK_DEBUG buildAndreas Kling
Regressed with 68bf6db673e3a0070b5c47d7ab997d82d31e1526
2021-08-29Kernel: Rename Spinlock::is_owned_by_current_thread()Andreas Kling
...to is_owned_by_current_processor(). As Tom pointed out, this is much more accurate. :^)
2021-08-29Kernel: Rename Socket::lock() => Socket::mutex()Andreas Kling
"lock" is ambiguous (verb vs noun) while "mutex" is not.
2021-08-29Kernel: {Mutex,Spinlock}::own_lock() => is_locked_by_current_thread()Andreas Kling
Rename these API's to make it more clear what they are checking.
2021-08-29Kernel: Move "in-scheduler" flag from SchedulerData to ProcessorAndreas Kling
This avoids a race between getting the processor-specific SchedulerData and accessing it. (Switching to a different CPU in that window means that we're operating on the wrong SchedulerData.) Co-authored-by: Tom <tomut@yahoo.com>
2021-08-29Kernel: Add read_gs_value() and write_gs_value()Andreas Kling
Co-authored-by: Tom <tomut@yahoo.com>
2021-08-29Kernel: Use StringView instead of C strings in MutexAndreas Kling
2021-08-29Kernel: Add Socket::set_role() and use it everywhereAndreas Kling
Instead of having Socket subclasses write their role into Socket::m_role directly, add a setter to do this.
2021-08-29Kernel: Store LocalSocket address as a KString internallyAndreas Kling
Just because we deal with sockaddr_un at the userspace API layer doesn't mean we have to store an awkward C type internally. :^)
2021-08-29Kernel: Rename LocalSocket::create_connected_pair() => try_*()Andreas Kling
2021-08-29Kernel: Encapsulate assignment of socket origin/acceptor credentialsAndreas Kling
2021-08-29Kernel: Rename LocalSocket factory to try_create() & tighten return typeAndreas Kling
Also tighten the return type to KResultOr<NonnullRefPtr<LocalSocket>> since it cannot return any other socket type.
2021-08-29Kernel/SysFS: Remove unnecessary mutex lockers in SysFS metadata gettersAndreas Kling
SysFS inodes have immutable metadata once created.
2021-08-29Kernel: Make all ProcFS and SysFS files zero-sizedAndreas Kling
There is no value in exposing particular sizes for these files.
2021-08-29Kernel: Remove unused members in BIOSSysFSDirectoryAndreas Kling
2021-08-29Kernel: Remove an obviously redundant check in FIFO::read()Andreas Kling
2021-08-29Kernel/Ext2FS: Avoid temporary String allocation during inode creationAndreas Kling
Make sure we pass the StringView we get all the way through so it never turns into a heap-allocated String. :^)
2021-08-29Kernel: Use ProcessID a bit more in SocketAndreas Kling
Store the origin and acceptor PID's as ProcessID.
2021-08-29Kernel: Strongly typed user & group ID'sAndreas Kling
Prior to this change, both uid_t and gid_t were typedef'ed to `u32`. This made it easy to use them interchangeably. Let's not allow that. This patch adds UserID and GroupID using the AK::DistinctNumeric mechanism we've already been employing for pid_t/ProcessID.
2021-08-29Kernel: Rename FileDescription::create() => try_create()Andreas Kling
2021-08-28Kernel: Omit all actual code from the kernel on aarch64 for nowNico Weber
2021-08-28Prekernel: Make build on aarch64Nico Weber
Add a dummy Arch/aarch64/boot.S that for now does nothing but let all processor cores sleep. For now, none of the actual Prekernel code is built for aarch64.
2021-08-28Prekernel: Move boot.S and multiboot.S into an Arch/x86 subfolderNico Weber
2021-08-28Kernel: Verify interrupts are disabled when interacting with MutexesAndrew Kaster
This should help prevent deadlocks where a thread blocks on a Mutex while interrupts are disabled, and makes it impossible for the holder of the Mutex to make forward progress because it cannot be scheduled in. Hide it behind a new debug macro LOCK_IN_CRITICAL_DEBUG for now, because Ext2FS takes a series of Mutexes from the page fault handler, which executes with interrupts disabled.
2021-08-28Kernel: Don't acquire Mutex for hostname() before scheduling is enabledAndrew Kaster
There's no reason to acquire the mutex for this resource before APs are booted, before scheduling is enabled, and before interrupts are enabled.
2021-08-28Kernel: Acquire reference to waitee before trying to block in sys$waitidAndrew Kaster
Previously, we would try to acquire a reference to the all processes lock or other contended resources while holding both the scheduler lock and the thread's blocker lock. This could lead to a deadlock if we actually have to block on those other resources.
2021-08-28Kernel: Guard the all processes list with a Spinlock rather than a MutexAndrew Kaster
There are callers of processes().with or processes().for_each that require interrupts to be disabled. Taking a Mutexe with interrupts disabled is a recipe for deadlock, so convert this to a Spinlock.
2021-08-28Kernel: Unlock ptrace lock before entering a critical section in execveAndrew Kaster
While it might not be as bad to release a mutex while interrupts are disabled as it is to acquire one, we don't want to mess with that.
2021-08-28Kernel: Don't disable interrupts in validate_inode_mmap_protAndrew Kaster
There's no need to disable interrupts when trying to access an inode's shared vmobject. Additionally, Inode::shared_vmobject() acquires a Mutex which is a recipe for deadlock if acquired with interrupts disabled.
2021-08-28CMake: Let `Meta/serenity.sh run aarch64` make it past cmakeNico Weber
This adds just enough scaffolding to make cmake succeed. The build falls over immediately.
2021-08-27Kernel: Implement ioctl for the SB16 to change sample ratekleines Filmröllchen
Two new ioctl requests are used to get and set the sample rate of the sound card. The SB16 device keeps track of the sample rate separately, because I don't want to figure out how to read the sample rate from the device; it's easier that way. The soundcard write doesn't set the sample rate to 44100 Hz every time anymore, as we want to change it externally.
2021-08-27Kernel: Modernize SB16.cppkleines Filmröllchen
This was some old code that could use mostly some east-const :^)
2021-08-25Kernel: Make VirtualAddress methods constexprBrian Gianforcaro
In order to use VirtualAddresses as compile time constants in the AddressSanitizer implementation, we need to be able to use these methods in constexpr functions / variable initializations.
2021-08-25CMake: Remove Prekernel incompatible options instead of overridingBrian Gianforcaro
The pattern of having Prekernel inherit all of the build flags of the Kernel, and then disabling some flags by adding `-fno-<flag>` options to then disable those options doesn't work in all scenarios. For example the ASAN flag `-fasan-shadow-offset=<offset>` has no option to disable it once it's been passed, so in a future change where this flag is added we need to be able to disable it cleanly. The cleaner way is to just allow the Prekernel CMake logic to filter out the COMPILE_OPTIONS specified for that specific target. This allows us to remove individual options without trashing all inherited options.
2021-08-25Kernel: Annotate Memory::Region APIs with [[nodiscard]]Brian Gianforcaro
This is an attempt to mitigate callers not observing the result of map or remap.
2021-08-25Kernel: Always observe the return value of Region::map and remapBrian Gianforcaro
We have seen cases where the map fails, but we return the region to the caller, causing them to page fault later on when they touch the region. The fix is to always observe the return code of map/remap.
2021-08-24Kernel: Remove confusing nested scope in Thread::block()Andreas Kling
There was a nested scope here that didn't actually scope anything meaningfully, so just get rid of it.
2021-08-24Kernel: Use TemporaryChange to update Thread::m_in_blockAndreas Kling
Let's use an RAII helper to avoid having to update this on every path out of block(). Note that this extends the time under `m_in_block == true` by a little but that should be harmless.
2021-08-24Kernel: Simplify Blockers so they don't need a "should block" flagAndreas Kling
The `m_should_block` member variable that many of the Thread::Blocker subclasses had was really only used to carry state from the constructor to the immediate-unblock-without-blocking escape hatch. This patch refactors the blockers so that we don't need to hold on to this flag after setup_blocker(), and instead the return value from setup_blocker() is the authority on whether the unblock conditions are already met.
2021-08-24Kernel: Remove unused BlockTimeout::m_should_blockAndreas Kling
This was assigned but never read.