Commit graph

7073 commits

Author SHA1 Message Date
Andreas Kling db75bab493 Kernel: Actually fix accidental overlaps in allocate_range_specific()
Thanks to Idan for spotting this! :^)
2022-04-03 23:58:57 +02:00
James Mintram 2b442ae44f Kernel: Add kmalloc.cpp to aarch64 2022-04-03 23:21:04 +02:00
Linus Groh b0f701d053 Kernel: Convert ProcessorInfo::build_brand_string() to StringBuilder 2022-04-03 23:20:33 +02:00
Linus Groh 33004f9b9d Kernel: Add hypervisor_vendor_id entry to /proc/cpuinfo 2022-04-03 23:20:33 +02:00
Linus Groh 0f27432ec6 Kernel+SystemMonitor+lscpu: Rename 'CPUID' -> 'Vendor ID'
This is what the Intel manual, as well as Linux's cpuinfo calls it.
2022-04-03 23:20:33 +02:00
Linus Groh 3f9c2495e5 Kernel: Remove EBX, ECX, and EDX values from hypervisor dmesgln() 2022-04-03 23:20:33 +02:00
Linus Groh 8d96525b9d Kernel: Move hypervisor vendor ID string to ProcessorInfo
This will make it possible to expose it in /proc/cpuinfo. :^)
2022-04-03 23:20:33 +02:00
Linus Groh f6181cd47e Kernel: Make ProcessorInfo::build_foo_string() private 2022-04-03 23:20:33 +02:00
Linus Groh afce63fffc Kernel: Move feature string building to ProcessorInfo
Other than a dmesgln(), ProcessorInfo is the only user of this function
and is already responsible for building other CPUID-related strings.
2022-04-03 23:20:33 +02:00
Linus Groh 53a95a5347 Kernel: Rename some ProcessorInfo members to match Intel manual
Let's use terminology from the the Intel manual to avoid confusion.
Also add `_string` suffixes to better distinguish the numeric values
from the string values.
2022-04-03 23:20:33 +02:00
Linus Groh ebe2cf8995 Kernel: Move private ProcessorInfo members to the end 2022-04-03 23:20:33 +02:00
Andreas Kling 9765f9f67e Kernel: Fix accidental overlaps in RegionTree::allocate_range_specific()
Thanks to Idan for spotting this! :^)
2022-04-03 23:07:29 +02:00
Andreas Kling 36d829b97c Kernel: Mark sys$listen() as not needing the big lock
This syscall already performs the necessary locking and so doesn't
need to rely on the process big lock.
2022-04-03 22:22:22 +02:00
Andreas Kling e103c5fe2d Kernel: Don't hog file descriptor table lock in sys$bind()
We don't need to hold the lock across the entire syscall. Once we've
fetched the open file description we're interested in, we can let go.
2022-04-03 22:20:34 +02:00
Andreas Kling 85ceab1fec Kernel: Don't hog file descriptor table lock in sys$listen()
We don't need to hold the lock across the entire syscall. Once we've
fetched the open file description we're interested in, we can let go.
2022-04-03 22:18:57 +02:00
Andreas Kling bc4282c773 Kernel: Mark sys$sendfd() and sys$recvfd() as not needing the big lock
These syscalls already perform the necessary locking and don't rely on
the process big lock.
2022-04-03 22:06:03 +02:00
Andreas Kling 92dfcdb6b1 Kenrel: Update a dmesgln() to say "RegionTree" instead of old class name 2022-04-03 22:00:19 +02:00
Andreas Kling 9e1da1f4f5 Kernel: Add a little explainer comment above RegionTree 2022-04-03 21:59:48 +02:00
Andreas Kling 8b01789ec4 Kernel: Improve RegionTree's internal helper function names
It's a bit nicer if functions that allocate ranges have some kind of
name that includes both "allocate" and "range". :^)
2022-04-03 21:56:16 +02:00
Andreas Kling 32dea6bde5 Kernel: Add missing include to PageDirectory.h 2022-04-03 21:51:58 +02:00
Andreas Kling 858b196c59 Kernel: Unbreak ASLR in the new RegionTree world
Functions that allocate and/or place a Region now take a parameter
that tells it whether to randomize unspecified addresses.
2022-04-03 21:51:58 +02:00
Andreas Kling e89c9ed2ca Kernel: Stop exposing RegionTree API for VM range allocation
...and remove the last remaining client of the API. It's no longer
possible to ask the RegionTree for a VM range. You can only ask it to
place your Region somewhere in available space.
2022-04-03 21:51:58 +02:00
Andreas Kling 07f3d09c55 Kernel: Make VM allocation atomic for userspace regions
This patch move AddressSpace (the per-process memory manager) to using
the new atomic "place" APIs in RegionTree as well, just like we did for
MemoryManager in the previous commit.

This required updating quite a few places where VM allocation and
actually committing a Region object to the AddressSpace were separated
by other code.

All you have to do now is call into AddressSpace once and it'll take
care of everything for you.
2022-04-03 21:51:58 +02:00
Andreas Kling e852a69a06 LibWeb: Make VM allocation atomic for kernel regions
Instead of first allocating the VM range, and then inserting a region
with that range into the MM region tree, we now do both things in a
single atomic operation:

    - RegionTree::place_anywhere(Region&, size, alignment)
    - RegionTree::place_specifically(Region&, address, size)

To reduce the number of things we do while locking the region tree,
we also require callers to provide a constructed Region object.
2022-04-03 21:51:58 +02:00
Andreas Kling cbf52d474c Kernel: Remove now-unused VirtualRangeAllocator
This has been replaced with the allocation-free RegionTree. :^)
2022-04-03 21:51:58 +02:00
Andreas Kling e8f543c390 Kernel: Use intrusive RegionTree solution for kernel regions as well
This patch ports MemoryManager to RegionTree as well. The biggest
difference between this and the userspace code is that kernel regions
are owned by extant OwnPtr<Region> objects spread around the kernel,
while userspace regions are owned by the AddressSpace itself.

For kernelspace, there are a couple of situations where we need to make
large VM reservations that never get backed by regular VMObjects
(for example the kernel image reservation, or the big kmalloc range.)
Since we can't make a VM reservation without a Region object anymore,
this patch adds a way to create unbacked Region objects that can be
used for this exact purpose. They have no internal VMObject.)
2022-04-03 21:51:58 +02:00
Andreas Kling ffe2e77eba Kernel: Add Memory::RegionTree to share code between AddressSpace and MM
RegionTree holds an IntrusiveRedBlackTree of Region objects and vends a
set of APIs for allocating memory ranges.

It's used by AddressSpace at the moment, and will be used by MM soon.
2022-04-03 21:51:58 +02:00
Andreas Kling 02a95a196f Kernel: Use AddressSpace region tree for range allocation
This patch stops using VirtualRangeAllocator in AddressSpace and instead
looks for holes in the region tree when allocating VM space.

There are many benefits:

- VirtualRangeAllocator is non-intrusive and would call kmalloc/kfree
  when used. This new solution is allocation-free. This was a source
  of unpleasant MM/kmalloc deadlocks.

- We consolidate authority on what the address space looks like in a
  single place. Previously, we had both the range allocator *and* the
  region tree both being used to determine if an address was valid.
  Now there is only the region tree.

- Deallocation of VM when splitting regions is no longer complicated,
  as we don't need to keep two separate trees in sync.
2022-04-03 21:51:58 +02:00
Andreas Kling 2617adac52 Kernel: Store AddressSpace memory regions in an IntrusiveRedBlackTree
This means we never need to allocate when inserting/removing regions
from the address space.
2022-04-03 21:51:58 +02:00
Tim Schumacher 4ba39c8d63 Kernel: Implement f_basetype in statvfs 2022-04-03 19:15:14 +02:00
James Mintram 9186ed3101 Kernel: Add all memory files to aarch64 and fix resulting linker errors 2022-04-02 19:34:20 -07:00
James Mintram 2e63215346 Kernel: Re-add AK files to aarch64 2022-04-02 19:34:20 -07:00
James Mintram d79c772c87 Kernel: Make MemoryManager compile on aarch64 2022-04-02 19:34:20 -07:00
James Mintram 6299a69253 Kernel: Make handle_crash available to aarch64 2022-04-02 19:34:20 -07:00
James Mintram d3b6201b40 Kernel: Make PageDirectory.cpp compile on aarch64 2022-04-02 19:34:20 -07:00
James Mintram 783a44b18e Kernel: Make PhysicalRegion.cpp compile on aarch64 2022-04-02 19:34:20 -07:00
James Mintram 0d7eee625f Kernel: Make AddressSpace.cpp compile on aarch64 2022-04-02 19:34:20 -07:00
James Mintram 627fd231d5 Kernel: Make Region.cpp compile on aarch64 2022-04-02 19:34:20 -07:00
James Mintram a883079b29 Kernel: Add missing new/delete and kcalloc to dummy.cpp 2022-04-02 19:34:20 -07:00
James Mintram 031b0c76b5 Kernel: Re-add dummy.cpp and remove duplicate definitions 2022-04-02 19:34:20 -07:00
James Mintram d50e237281 Kernel: Add idle_thread() to aarch64 Processor.h 2022-04-02 19:34:20 -07:00
James Mintram 026efae8a8 Kernel: Add PAGE_MASK to an aarch64 CPU header 2022-04-02 19:34:20 -07:00
Idan Horowitz 086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Liav A db8942178a Kernel: Stop debug spam when using read on /dev/mem device
This is not really useful and quite annoying so let's disable it by
default.
2022-04-01 19:59:45 +02:00
Liav A d0abae8907 Kernel: Stop debug spam when using mmap on /dev/mem device
This is not really useful and quite annoying so let's disable it by
default.
2022-04-01 19:59:45 +02:00
Liav A 231b9f256b Kernel: Declare Device major and minor data member numbers as const
This is just another "safety guard" to ensure these numbers don't ever
change after being set for a certain Device at construction time.
2022-04-01 12:56:04 +01:00
Liav A ae2ec45e78 Kernel: Allow SysFS components to have non-zero size
This is important for dmidecode because it does an fstat on the DMI
blobs, trying to figure out their size. Because we already know the size
of the blobs when creating the SysFS components, there's no performance
penalty whatsoever, and this allows dmidecode to not use the /dev/mem
device as a fallback.
2022-04-01 11:27:19 +02:00
Liav A 66ff60db07 Kernel: Declare DMI SysFS BIOS classes as final 2022-04-01 11:27:19 +02:00
Liav A 338b4b27eb Kernel: Declare blob sizes of SysFS BIOS classes as const 2022-04-01 11:27:19 +02:00
Liav A 96aae59e9c Kernel: Initialize primitive data members of SysFS BIOS classes 2022-04-01 11:27:19 +02:00
Pankaj Raghav 36363b1a37 Kernel: Fix storage device read/write for request length < block size
The current implementation of read/write will fail in StorageDevice
when the request length is less than the block size of the underlying
device. Fix it by calculating the offset within a block for such cases
and using it for copying data from the bounce buffer.
2022-03-30 19:31:12 +03:00
Ali Mohammad Pur d6ce3e63e2 Kernel: Disallow elevating pledge promises with no_error set
8233da3398 introduced a not-so-subtle bug
where an application with an existing pledge set containing `no_error`
could elevate its pledge set by pledging _anything_, this commit makes
sure that no new promise is accepted.
2022-03-29 12:11:56 +02:00
Lorenz Steinert 78f8821152 Kernel: Propagate HIDManagement initialisation error to init
Initialisation errors for HIDManagement are now returned to the init. In
the init we assert by MUST if we get an error.
2022-03-28 11:36:17 +02:00
Lorenz Steinert d3ce97e8b2 Kernel/Devices/HID: Propagate errors of HIDDevices properly
Some error indication was done by returning bool. This was changed to
propagate the error by ErrorOr from the underlying functions. The
returntype of the underlying functions was also changed to propagate the
error.
2022-03-28 11:36:17 +02:00
Linus Groh 1e82c2708d Kernel: Support all AMD-defined CPUID feature flags for EAX=80000001h
We're now able to detect all the AMD-defined CPUID feature flags from
ECX/EDX for EAX=80000001h :^)
2022-03-27 18:54:56 +02:00
Linus Groh 96e6420d8d Kernel: Support all Intel-defined extended CPUID feature flags for EAX=7
We're now able to detect all the extended CPUID feature flags from
EBX/ECX/EDX for EAX=7 :^)
2022-03-27 18:54:56 +02:00
Linus Groh 6ca03b915e Kernel: Support all Intel-defined CPUID feature flags for EAX=1
We're now able to detect all the regular CPUID feature flags from
ECX/EDX for EAX=1 :^)

None of the new ones are being used for anything yet, but they will show
up in /proc/cpuinfo and subsequently lscpu and SystemMonitor.

Note that I replaced the periods from the SSE 4.1 and 4.2 instructions
with underscores, which matches the internal enum names, Linux's
/proc/cpuinfo and the general pattern of replacing special characters
with underscores to limit feature names to [a-z0-9_].

The enum member stringification has been moved to a new function for
better re-usability and to avoid cluttering up Processor.cpp.
2022-03-27 18:54:56 +02:00
Linus Groh bc7ec02a82 Kernel: Implement CPUFeature as an ArbitrarySizedEnum
This will make it possible to add many, many more CPU features - more
than the current limit 32 and later limit of 64 if we stick with an enum
class to be specific :^)
2022-03-27 18:54:56 +02:00
Linus Groh e284ee7dcf Kernel: Fix whack formatting of the CPUID constructor 2022-03-27 18:54:56 +02:00
Linus Groh c895780829 Kernel: Reorder code in Processor::cpu_detect() for readability
Checks of ECX go before EDX, and the bit indices are now ordered
properly. Additionally, handling of the EDX[11] bit has been moved into
a lambda function to keep the series of if statements neatly together.
All of this makes it *a lot* easier to follow along and compare the
implementation to the tables in the Intel manual, e.g. to find missing
checks.
2022-03-27 18:54:56 +02:00
Tom c2f6152db8 Kernel: Change the BSP Processor instance to not have a constructor
This solves a problem where any non-trivial member in the global BSP
Processor instance would get re-initialized (improperly), losing data
that was already initialized earlier.
2022-03-27 18:54:56 +02:00
Pankaj Raghav e40d4b2677 Kernel: Remove hardcoded values for block size in IDEChannel 2022-03-27 08:54:32 -07:00
Pankaj Raghav 6d3a7fabeb Kernel: Remove hardcoded values for block size in Ramdisk
Instead of using the hardcoded 512 in Ramdisk, retrieve the block size
value from the AsyncBlockDeviceRequest struct.
2022-03-27 08:54:32 -07:00
Pankaj Raghav 2786a71bc0 Kernel: Expose block size in AsyncBlockDeviceRequest struct
Expose the block size variable via a member function in the
AsyncBlockDeviceRequest so that the driver doesn't need to assume any
value such as 512 bytes.
2022-03-27 08:54:32 -07:00
Pankaj Raghav 4b2094506b Kernel: Use buffer_size from AsyncBlockDevice struct
The underlying driver does not need to recalculate the buffer size as
it is passed in the AsyncBlockDevice struct anyway. This also helps in
removing any assumptions of the underlying block size of the device.
2022-03-27 08:54:32 -07:00
Ali Mohammad Pur 8233da3398 Kernel: Add a 'no_error' pledge promise
This makes pledge() ignore promises that would otherwise cause it to
fail with EPERM, which is very useful for allowing programs to run under
a "jail" so to speak, without having them termiate early due to a
failing pledge() call.
2022-03-26 21:34:56 +04:30
Liav A 7053d7ece3 Kernel: Add a way to print the pseudo name of attached TTY of a process
Contrary to the past, we don't attempt to assume the real name of a TTY
device, but instead, we generate a pseudo name only when needed to do so
which is still OK because we don't break abstraction layer rules and we
still can provide userspace with the required information.
2022-03-26 11:01:49 +01:00
Idan Horowitz f9c6f37bac Kernel: Add a 'disable_kaslr' kernel command line parameter
This parameter can be used to disable the KASLR mechanism.
2022-03-24 23:36:56 +00:00
Idan Horowitz 54a12d34eb Kernel: Move {strnlen, strcmp, memcmp, strncmp, strstr} to MiniStdLib
This lets the Prekernel also use these simple (and standalone)
C functions.
2022-03-24 23:36:56 +00:00
Idan Horowitz f0166efe8c Kernel: Use the whole kernel PD range when randomizing the KASLR offset
Now that we reclaim the memory range that is created by KASLR before
the start of the kernel image, there's no need to be conservative with
the KASLR offset.
2022-03-23 19:49:49 +02:00
Liav A b5ef900ccd Kernel: Don't assume paths of TTYs and pseudo terminals anymore
The obsolete ttyname and ptsname syscalls are removed.
LibC doesn't rely on these anymore, and it helps simplifying the Kernel
in many places, so it's an overall an improvement.

In addition to that, /proc/PID/tty node is removed too as it is not
needed anymore by userspace to get the attached TTY of a process, as
/dev/tty (which is already a character device) represents that as well.
2022-03-22 20:26:05 +01:00
Liav A 5ffe2f117c Kernel/TTY: Implement TIOCGPTN ioctl for MasterPTY
This ioctl operation will allow userspace to determine the index number
of a MasterPTY after opening /dev/ptmx and actually getting an internal
file descriptor of MasterPTY.
2022-03-22 20:26:05 +01:00
Liav A 12867d60ad Kernel: Create SelfTTYDevice class to help replace /dev/tty symlink
This will replace the /dev/tty symlink created by SystemServer, so
instead of a symlink, a character device will be created. When doing
read(2), write(2) and ioctl(2) on this device, it will "redirect" these
operations to the attached TTY of the current process.
2022-03-22 20:26:05 +01:00
Hendiadyoin1 150e6a59c0 Kernel: Add and use bitwise operators to CPUFeature 2022-03-22 18:20:01 +00:00
Idan Horowitz e18632660f Kernel: Use the pre-image kernel memory range introduced by KASLR
This ensures we don't just waste the memory range between the default
base load address and the actual load address that was shifted by the
KASLR offset.
2022-03-22 16:46:51 +01:00
Idan Horowitz d850e483f7 Kernel: Keep kernel base load address 2 MiB aligned
This requirement comes from the fact the Prekernel mapping logic only
uses 2 MiB pages.
This unfortunately reduces the bits of entropy in kernel addresses from
16 bits to 7, but it could be further improved in the future by making
the Prekernel mapping logic a bit more dynamic.
2022-03-22 16:46:51 +01:00
Linus Groh bd110be367 Kernel: Fix typo in a comment 2022-03-22 11:26:29 +00:00
int16 256744ebdf Kernel: Make mmap validation functions return ErrorOr<void> 2022-03-22 12:20:19 +01:00
int16 4b96d9c813 Kernel: Move mmap validation functions to Process 2022-03-22 12:20:19 +01:00
int16 479929b06c Kernel: Check wxallowed mount flag when validating mmap call 2022-03-22 12:20:19 +01:00
int16 4307c4480e Kernel: Define MS_WXALLOWED mount option 2022-03-22 12:20:19 +01:00
Andreas Kling b6e767f953 Kernel: Disable KASLR on i686
The 32-bit CI runners don't seem to happy with KASLR, so let's make it
x86-64 only for now.
2022-03-22 02:47:27 +01:00
Idan Horowitz 1ad0e05ea1 Kernel: Add an extremely primitive version of KASLR
This initial (and very basic) implementation of KASLR simply randomizes
the kernel base VA in the 256 MiB range following the default load base.
2022-03-21 23:33:42 +01:00
Idan Horowitz a9764dabee Kernel: Add helpers for rdrand and rdseed 2022-03-21 23:33:42 +01:00
Liav A 7ff6d4d72b Kernel: Increase i8042 timeout when writing and reading from device
This proved to be crucial on my ICH7 test machine because it takes a bit
more time to do IO on its i8042 controller.
2022-03-19 15:37:03 +00:00
Liav A 462618b68c Kernel/Storage: Move Ramdisk code into a separate subdirectory 2022-03-19 13:41:06 +00:00
Liav A f5acef0b81 Kernel: Use original Console m_x and m_y in Text based implementations 2022-03-19 13:39:59 +00:00
Andreas Kling 6625edb5d2 Kernel: When receiving unexpected TCP flags, print the flags
It'll be easier to understand what might be happening if we know which
unexpected flags are actually showing up. :^)
2022-03-18 15:18:48 +01:00
Andreas Kling f0dde1cee1 Kernel: Rename TCPFlags::PUSH => PSH
Let's use the proper name of this TCP flag.
2022-03-18 15:18:48 +01:00
Brian Gianforcaro f47c92bd2e Kernel: Mark serenity_dev_ functions as static
This avoids multiple definition errors when linking software which
may utilize these functions from different compilation units.
2022-03-18 11:59:35 +00:00
Liav A d56544aca0 Kernel/Graphics: Don't declare VGA changing-state methods as const 2022-03-18 03:46:23 -07:00
Brian Gianforcaro 913374163c LibVT/Kernel: Make VT::Attribute::Flags enum class, use AK EnumBits
Noticed the TODO in `Attribute.h` and realized we have as solution
to this problem already. :^)
2022-03-18 11:29:43 +01:00
Sahan Fernando 8601f74d5f Kernel: Fix crash when opening GPU3DDevice without creating a context 2022-03-18 12:56:35 +03:30
Liav A 3bbb5734af Kernel: Don't initialize early framebuffer console if address is invalid
To do so, we now check that the framebuffer type is RGB so we know that
the Multiboot bootloader actually provided a valid framebuffer to work
with.

This fixes a problem I observed on my ICH7 test machine that apparently
the multiboot_framebuffer_addr was not null but there was no framebuffer
that was set up for RGB colors, and by initializing that console, there
was a memory curroption caused somewhere in the EBDA area to probably
cause a complete system lockup.
2022-03-18 09:22:10 +00:00
Liav A eca8f292a5 Kernel: Allow to disable early boot console
This aid debugging on bare metal when we suspect that the boot console
does something wrong that interferes with other kernel components.
2022-03-18 09:22:10 +00:00
Liav A 0ef1137e88 Kernel/Graphics: Move all VGA related methods to GraphicsManagement
This helps solving an issue when we boot with text mode screen so the
Kernel initializes an early text mode console, but even after disabling
it, that console can still access VGA ports. This wouldn't be a problem
for emulated hardware but bare metal hardware might have a "conflict",
especially if the native driver explicitly request to disable the VGA
emulation.
2022-03-18 09:22:10 +00:00
Brian Gianforcaro ddd75db007 Kernel: Zero initialize DoubleBuffer::InnerBuffer::size
Found by PVS-Studio.
2022-03-18 00:51:16 -07:00
Brian Gianforcaro 8a8c51c39a Kernel: Default initialize AC97::m_codec_revision
Found by PVS-Studio.
2022-03-18 00:51:16 -07:00
Brian Gianforcaro 160c9b7631 Kernel: Zero initialize USBDevice::m_device_descriptor
Found by PVS-Studio.
2022-03-18 00:51:16 -07:00
Brian Gianforcaro 02f684079c Kernel: Rename locker variables in BMIDEChannel so they aren't shadowed
This class already has variables named m_lock, and it's also strange
that locals are named with the `m_` prefix. So lets fix that to make
the code more readable.

Found by PVS-Studio.
2022-03-18 00:51:16 -07:00
Brian Gianforcaro 47cdcc9f67 Kernel: Zero initialize all members in NVMeController
Found by PVS-Studio.
2022-03-18 00:51:16 -07:00
Lenny Maiorani 2844f7c333 Everywhere: Switch from EnableIf to requires
C++20 provides the `requires` clause which simplifies the ability to
limit overload resolution. Prefer it over `EnableIf`

With all uses of `EnableIf` being removed, also remove the
implementation so future devs are not tempted.
2022-03-17 22:15:42 -07:00
Lenny Maiorani 2548ee4149 Kernel: Make number of RTL8168 rx/tx descriptors constexpr 2022-03-17 13:36:17 -07:00
Lenny Maiorani 190cf1507b Kernel: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-17 00:51:36 -07:00
Linus Groh 9882848e0b Kernel: Define IF_NAMESIZE in net/if.h
This makes the _socket module from the Python port build. :^)
2022-03-16 18:03:25 +00:00
Daniel Bertalan e3eb68dd58 AK+Kernel: Avoid double memory clearing of HashTable buckets
Since the allocated memory is going to be zeroed immediately anyway,
let's avoid redundantly scrubbing it with MALLOC_SCRUB_BYTE just before
that.

The latest versions of gcc and Clang can automatically do this malloc +
memset -> calloc optimization, but I've seen a couple of places where it
failed to be done.

This commit also adds a naive kcalloc function to the kernel that
doesn't (yet) eliminate the redundancy like the userland does.
2022-03-15 11:56:46 +01:00
Hendiadyoin1 1a739b5d6e Kernel: Try to reuse empty slabheaps before expanding the kmalloc-heap 2022-03-14 23:30:08 +01:00
Hendiadyoin1 05381753c2 Kernel: Bail out earlier from Process::lookup_stacks_directory 2022-03-14 23:28:35 +01:00
Liav A 428d4ae337 Kernel/PCI: Break early of controller iteration over devices in OOM case
This is mainly useful when adding an HostController but due to OOM
condition, we abort temporary Vector insertion of a DeviceIdentifier
and then exit the iteration loop to report back the error if occured.
2022-03-14 22:39:09 +01:00
Liav A 3fb289e27d Kernel/PCI: Don't hold spinlocks when doing fast device enumeration
Instead, hold the lock while we copy the contents to a stack-based
Vector then iterate on it without any locking.

Because we rely on heap allocations, we need to propagate errors back
in case of OOM condition, therefore, both PCI::enumerate API function
and PCI::Access::add_host_controller_and_enumerate_attached_devices use
now a ErrorOr<void> return value to propagate errors. OOM Error can only
occur when enumerating the m_device_identifiers vector under a spinlock
and trying to expand the temporary Vector which will be used locklessly
to actually iterate over the PCI::DeviceIdentifiers objects.
2022-03-14 22:39:09 +01:00
Brian Gianforcaro c0ed656c94 Kernel: Fix buffer overflow in VirtIOGPU create_3d_resource(..)
This code attempts to copy the `Protocol::Resource3DSpecification`
struct into request, starting at `Protocol::ResourceCreate3D::target`
member of the `Protocol::ResourceCreate3D` struct.

The problem is that the `Protocol::Resource3DSpecification` struct
does not having the trailing `u32 padding` that the `ResourceCreate3D`
struct has. Leading to memcopy overrunning the struct and corrupting
32 bits of data trailing the struct.

Found by SonarCloud:
 - Memory copy function overflows the destination buffer.
2022-03-14 22:30:22 +01:00
Sahan Fernando 683de841e5 Kernel: Sandbox each GPU3DDevice file description into own host context 2022-03-14 17:38:18 +03:30
Brian Gianforcaro 03342876b8 Revert "Kernel: Use an ArmedScopeGuard to revert changes after failed mmap"
This reverts commit 790d620b39.
2022-03-12 21:45:57 -08:00
Brian Gianforcaro 3b39e16e8f Revert "Kernel: Don't override FramebufferDevice's memory regions on mmap"
This reverts commit 85ba70d86f.
2022-03-12 21:45:57 -08:00
Jakub V. Flasar 6d2c298b66 Kernel: Move aarch64 Prekernel into Kernel
As there is no need for a Prekernel on aarch64, the Prekernel code was
moved into Kernel itself. The functionality remains the same.

SERENITY_KERNEL_AND_INITRD in run.sh specifies a kernel and an inital
ramdisk to be used by the emulator. This is needed because aarch64
does not need a Prekernel and the other ones do.
2022-03-12 14:54:12 -08:00
Jakub V. Flasar f94293f121 Kernel: Create a stub mcontext for aarch64
The struct only has a stub integer so that the size is the same for C
and C++. Something caught by CLion.

This commit was made with mrkct's help!
2022-03-12 14:54:12 -08:00
Andreas Kling 7b3642d08c Kernel: Mark sys$lseek() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling 09e644f0ba Kernel: Mark sys$emuctl() as not needing the big lock
This syscall doesn't do anything at all, and definitely doesn't need the
big lock. :^)
2022-03-09 16:43:00 +01:00
Andreas Kling b4fefedd1d Kernel: Mark sys$chmod() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling aa381c4a67 Kernel: Mark sys$fchmod() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling d074aae422 Kernel: Mark sys$dup2() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling 8aad9e7448 Kernel: Mark sys$ftruncate() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Andreas Kling 69a6a4d927 Kernel: Mark sys$fstatvfs() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-09 16:43:00 +01:00
Sahan Fernando a2887dc157 Kernel: Disable GPU fencing for VirtIOGPU operations
These fences should not be needed, since we force the use of
synchronous operations through synchronous_virtio_gpu_command. The use
of these fences also causes severe lag when SERENITY_GL is enabled.
2022-03-09 14:58:48 +03:30
Sahan Fernando fd6a536c60 Kernel: Implement basic VirGL device
This commit flips VirtIOGPU back to using a Mutex for its operation
lock (instead of a spinlock). This is necessary for avoiding a few
system hangs when queuing actions on the driver from multiple
processes, which becomes much more of an issue when using VirGL from
multiple userspace process.

This does result in a few code paths where we inevitably have to grab
a mutex from inside a spinlock, the only way to fix both issues is to
move to issuing asynchronous virtio gpu commands.
2022-03-09 14:58:48 +03:30
Sahan Fernando 966989afe8 Kernel: Use AK::to_underlying instead of static_cast in VirtIOGPU 2022-03-09 14:58:48 +03:30
Sahan Fernando 0e57f80460 LibC: Add ioctls for VirGL 2022-03-09 14:58:48 +03:30
Tim Schumacher 5200cdac43 Kernel: Remove an unused fd_set.h import
The project appears to build just fine without it, and the explicit use
of `LibC` causes it to conflict with the system-wide `fd_set.h` when
building inside of Serenity.
2022-03-08 16:18:48 -08:00
Hendiadyoin1 85ba70d86f Kernel: Don't override FramebufferDevice's memory regions on mmap
This additionally refactors FramebufferDevice::try_to_initialize to not
leave the FramebufferDevice in an invalid state on errors.
This also unifies the logic between FramebufferDevice::mmap and
FramebufferDevice::try_to_initialize.
This comes with the drawback of removing the UNMAP_AFTER_INIT attribute
from this function, which wasn't honoured by IntelNativeGraphicsAdapter
anyway.
2022-03-08 15:58:51 -08:00
Hendiadyoin1 790d620b39 Kernel: Use an ArmedScopeGuard to revert changes after failed mmap 2022-03-08 15:58:51 -08:00
Daniel Bertalan 70ccdb300b Kernel: Panic if the init process dies
If init crashes, all other userspace processes exit too, thus rendering
the system unusable. Previously, the kernel would still keep running
even without a userland, showing just a black screen without any
indication of the issue.

We now panic the kernel, which shows a message on the console. In the
case of the CI runners, it shuts down the virtual machine, so we don't
have to wait for the 1 hour timeout if an issue arises with
SystemServer.
2022-03-08 23:30:47 +01:00
Liav A ed5623f40f Kernel/Graphics: Override first byte of the EDID in Intel Native driver 2022-03-08 21:56:14 +01:00
Liav A 7aa63ddd00 Kernel/Graphics: Print contents of offending EDID in Intel Native driver 2022-03-08 21:56:14 +01:00
Liav A f8df21c7e7 Kernel: Expose PCI BAR addresses in sysfs
Regardless of whether we use those BARs or not, expose them so userland
can use these values for its usage.
2022-03-08 21:52:10 +01:00
Andreas Kling 6354a9a030 Kernel: Mark sys$fsync() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling ef45ff4703 Kernel: Mark sys$readlink() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 2688ee28ff Kernel: Mark sys$stat() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling be7ec52ed0 Kernel: Mark sys$fstat() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 23822febd2 Kernel: Mark sys$fchdir() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 156ab0c47d Kernel: Mark sys$chdir() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 7597bef771 Kernel: Mark sys$getcwd() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling f630d0f095 Kernel: Mark sys$realpath() as not needing the big lock
This syscall doesn't access any data that was implicitly protected by
the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 580d89f093 Kernel: Put Process unveil state in a SpinlockProtected container
This makes path resolution safe to perform without holding the big lock.
2022-03-08 00:19:49 +01:00
Andreas Kling 24f02bd421 Kernel: Put Process's current directory in a SpinlockProtected
Also let's call it "current_directory" instead of "cwd" everywhere.
2022-03-08 00:19:49 +01:00
Andreas Kling 71792e4b3f Kernel: Make SpinlockProtected constructor forward all arguments
This allows you to instantiate SpinlockProtected<T> where T requires
constructor arguments.
2022-03-08 00:19:49 +01:00
Andreas Kling 7543c34d07 Kernel: Mark sys$anon_create() as not needing the big lock
This syscall is already safe for no-big-lock since it doesn't access any
unprotected data.
2022-03-08 00:19:49 +01:00
Idan Horowitz 29eee390ec Kernel: Implement kmalloc_good_size for the new kmalloc
This lets kmalloc-aware data structures like Vector and HashTable use
up the extra wasted space we allocate in the slab heaps & heap chunks.
2022-03-08 00:46:25 +02:00
Andreas Kling baa6ff5649 Kernel: Wrap HIDManagement keymap data in SpinlockProtected
This serializes access to the current keymap data everywhere in the
kernel, allowing to mark sys$setkeymap() as not needing the big lock.
2022-03-07 16:35:23 +01:00
Ali Mohammad Pur 6608812e4b Kernel: Over-align the FPUState on the stack in sigreturn
The stack is misaligned at this point for some reason, this is a hack
that makes the resulting object "correctly" aligned, thus avoiding a
KUBSAN error.
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur 23f6a00162 Kernel: Fix silly unintentional use of operator,
Everyone's favourite activity, copy pasta, has produced yet another
confusing use of operator,; fix this and make it less confusing.
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur 88d7bf7362 Kernel: Save and restore FPU state on signal dispatch on i386/x86_64 2022-03-04 20:07:05 +01:00
Ali Mohammad Pur e14e919b78 Kernel: Fill some siginfo and ucontext fields on SA_SIGINFO
There's no reason to fill in any of these fields if SA_SIGINFO is not
given, as the signal handler won't be reading from them at all.
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur 4bd01b7fe9 Kernel: Add support for SA_SIGINFO
We currently don't really populate most of the fields, but that can
wait :^)
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur 585054d68b Kernel: Comment the living daylights out of signal trampoline/sigreturn
Mere mortals like myself cannot understand more than two lines of
assembly without a million comments explaining what's happening, so do
that and make sure no one has to go on a wild stack state chase when
hacking on these.
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur 7238c946f0 Kernel: Make the signal trampoline stack alignment a bit more readable
The comments were confusing, and had a mathematical error, stop trying
to be clever and just let the computer do the math.
Also assert that we're pushing exactly as many stack elements as we're
using for the alignment calculations.
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur 848eaf2220 Kernel: Reject sigaction() with SA_SIGINFO
We can't handle this, so let sigaction() fail instead of PANIC()'ing
later when we try to dispatch a signal with SA_SIGINFO set.
2022-03-04 20:07:05 +01:00
Ali Mohammad Pur cf63447044 Kernel: Move signal handlers from being thread state to process state
POSIX requires that sigaction() and friends set a _process-wide_ signal
handler, so move signal handlers and flags inside Process.
This also fixes a "pid/tid confusion" FIXME, as we can now send the
signal to the process and let that decide which thread should get the
signal (which is the thread with tid==pid, but that's now the Process's
problem).
Note that each thread still retains its signal mask, as that is local to
each thread.
2022-03-04 20:07:05 +01:00
Jelle Raaijmakers 4f91616759 Kernel: Report AC'97 vendor and device ID 2022-03-04 11:07:25 +01:00
Jakub Berkop d01d754b83 Kernel: Fixed behavior of repeated calls to register_string
Previously register_string would return incorrect values when
called multiple times with the same input. This patch makes this
function return the same index, identical strings. This change was
required, as this functionality is now being used with read syscall
profiling, (#12465), which uses 'register_string' to registers file
path on every read syscall.
2022-03-03 14:53:35 -08:00
Liav A 30eeba1981 Kernel/Storage: Don't try to enumerate PCI adapters if PCI is disabled
If there's no PCI bus, then it's safe to assume that we run on a x86
machine that has an ISA IDE controller in the system. In such case, we
just instantiate a ISAIDEController object that assumes fixed locations
of IDE IO ports.
2022-03-02 18:41:54 +01:00
Liav A fafa339264 Kernel/Graphics: Don't try to enumerate PCI adapters if PCI is disabled
If there's no PCI bus, then it's safe to assume that the x86 machine we
run on supports VGA text mode console output with an ISA VGA adapter.
If this is the case, we just instantiate a ISAVGAAdapter object that
assumes this situation and allows us to boot into VGA text mode console.
2022-03-02 18:41:54 +01:00
Liav A 15315be55c Kernel/Audio: Don't try to enumerate PCI adapters if PCI is disabled 2022-03-02 18:41:54 +01:00
Liav A 71de4f7114 Kernel/Net: Don't try to enumerate PCI adapters if PCI is disabled 2022-03-02 18:41:54 +01:00
Liav A b849e4f907 Kernel/PCI: Don't create /proc/pci if PCI is disabled
Reading from /proc/pci assumes we have PCI enabled and also enumerated.
However, if PCI is disabled for some reason, we can't allow the user to
read from it as there's no valuable data we can supply.
2022-03-02 18:41:54 +01:00
Liav A 2272d93215 Kernel/PCI: Unify disable checks under PCI::Access::is_disabled method
To declare that we don't have a PCI bus in the system we do two things:
1. Probe IO ports before enabling access -
In case we are using the QEMU ISA-PC machine type, IO probing results in
floating bus condition (returning 0xFF values), thus, we know we don't
have PCI bus on the system.
2. Allow the user to specify to not use the PCI bus at all in the kernel
commandline.
2022-03-02 18:41:54 +01:00
Liav A f6e635938f Kernel: Change PCI access commandline option to also represent no access
This change allow the user to request the kernel to not use any PCI
resources/devices at all.

Also, don't try to initialize devices that rely on PCI if disabled.
2022-03-02 18:41:54 +01:00
Andreas Kling 884ebc42b1 Kernel: Respect actual framebuffer pitch
Instead of winging it with "width * 4", use the actual pitch since it
may be different.

This makes the kernel text console show up in native 1368x768 on my
ThinkPad X250. :^)
2022-03-01 19:01:19 +01:00
Lucas CHOLLET 839d3d9f74 Kernel: Add getrusage() syscall
Only the two timeval fields are maintained, as required by the POSIX
standard.
2022-02-28 20:09:37 +01:00
Jelle Raaijmakers c3c683c9e1 Kernel: Whitespace and Error cleanup in AC97
No functional changes.
2022-02-27 20:38:34 +01:00
Jelle Raaijmakers 0e78e6b1e8 Kernel: Do not reset AC'97 PCM out on buffer completion
We now only reset the PCM out channel during initialization, and handle
the case where the channel's current index has passed the last valid
index properly.

This fixes issues with stuttering audio between multiple subsequent
`aplay` invocations, for example.
2022-02-27 20:38:34 +01:00
Jelle Raaijmakers 694ff12272 Kernel: Read and report AC'97 codec revision
This might help with debugging on bare metal. Since the minimum version
that can be specified is revision 2.1, and we do not use any feature
from revision 2.2 or newer, this is merely future-proofing ourselves
for new features yet to be built. Additionally, removing the `VERIFY()`
ensures we will not crash on cards that only support earlier revisions.
2022-02-27 20:38:34 +01:00
Jelle Raaijmakers 9a46573ffc Kernel: Make AC'97 initialization fallible
Let's not crash in `AudioManagement` if we run into trouble.
2022-02-27 20:38:34 +01:00
Idan Horowitz feb00b7105 Everywhere: Make JSON serialization fallible
This allows us to eliminate a major source of infallible allocation in
the Kernel, as well as lay down the groundwork for OOM fallibility in
userland.
2022-02-27 20:37:57 +01:00
Idan Horowitz 6682afb5d4 Kernel: Add UDPSocket::try_for_each() for fallible iteration
This API will allow users to short circuit iteration and properly
propagate errors.
2022-02-27 20:37:57 +01:00
Idan Horowitz aabc8d348b Kernel: Add TCPSocket::try_for_each() for fallible iteration
This API will allow users to short circuit iteration and properly
propagate errors.
2022-02-27 20:37:57 +01:00
Idan Horowitz 24be52b3f5 Kernel: Add LocalSocket::try_for_each() for fallible iteration
This API will allow users to short circuit iteration and properly
propagate errors.
2022-02-27 20:37:57 +01:00
Idan Horowitz 74ab8ccde0 Kernel: Add NetworkingManagement::try_for_each() for fallible iteration
This API will allow users to short circuit iteration and properly
propagate errors.
2022-02-27 20:37:57 +01:00
Idan Horowitz da5d678f2a Kernel: Add DeviceManagement::try_for_each() for fallible iteration
This API will allow users to short circuit iteration and properly
propagate errors.
2022-02-27 20:37:57 +01:00
Idan Horowitz 064b93c2ad Kernel: Add OpenFileDescriptions::try_enumerate for fallible iteration
This API will allow users to short circuit iteration and properly
propagate errors.
2022-02-27 20:37:57 +01:00
Idan Horowitz aca6c0c031 Kernel: Add Process::try_for_each_thread() for fallible iteration
This API will allow users to short circuit iteration and properly
propagate errors.
2022-02-27 20:37:57 +01:00
Idan Horowitz f4875b9967 Kernel: Add Processor::try_for_each() for fallible iteration
This API will allow users to short circuit iteration and properly
propagate errors.
2022-02-27 20:37:57 +01:00
Idan Horowitz 853f7092f8 Kernel: Defer signal handling without a register capture earlier
We were deferring the signal handling after already marking the signal
as handling, which led to some failures in the Shell tests.
2022-02-27 00:38:00 +02:00
Idan Horowitz 011bd06053 Kernel: Set CS selector when initializing thread context on x86_64
These are not technically required, since the Thread constructor
already sets these, but they are set on i686, so let's try and keep
consistent behaviour between the different archs.
2022-02-27 00:38:00 +02:00
Jelle Raaijmakers 8bf0e04c16 Kernel: Allow setting AC'97 sample rate during playback
The Qemu AC'97 device stops its PCM channel's DMA engine when it is
running and the sample rate is changed. We now make sure the DMA engine
is restarted after changing the sample rate, allowing you to e.g. run
`asctl set r 22050` during `aplay` playback.
2022-02-26 20:23:15 +01:00
Jelle Raaijmakers e2891e9aa4 Kernel: Clean up AC'97 driver code style
* Remove braces from single-line conditionals
* Use aggregate initialization style for member variables
2022-02-26 20:23:15 +01:00
Peter Ross 9d94c85b6a Kernel: Use IO init method for Bochs emulated VGA adapter
In short: QEMU supports both Memory-Mapped-IO and classic IO methods
for controlling the emulated VGA device. Bochs and VirtualBox only
support the classic IO method. An excellent write up on the history of
these interfaces can be found here:
https://www.kraxel.org/blog/2018/10/qemu-vga-emulation-and-bochs-display

The IO method was how things were done originally in SerenityOS. Commit
6a728e2d76 introduced the MMIO method for
all devices, breaking Bochs and VirtualBox compatibility. Later in
commit 6a9dc5562d the classic IO method
was restored for VirtualBox graphics adapters.

QEMU and Bochs use the same PCI VID/DID (0x1234/0x1111) for the emulated
VGA adapter. To distinguish betwen QEMU and Bochs we use the PCI
revision ID field (0=Bochs, 2=QEMU).
2022-02-24 09:08:04 +02:00
Liav A a38a637f5c Kernel/Audio: Remove the SB16 driver
This driver is not tested and probably not used on any modern hardware
machine, because it is plugged into the ISA bus and not the PCI bus.
Also, the run script doesn't utilize this device anymore, making it more
hard to test this driver and to ensure it doesn't rot.
2022-02-24 07:26:45 +01:00
Brian Gianforcaro d05fa14e52 Kernel: Use TRY() when validating clock_id in TimeManagement
Gets rid of a bit of code duplication, and makes the API more consistent
with the style we are moving towards.
2022-02-21 15:47:51 -08:00
Tom a5ce5564a9 Kernel: Fix allocating identity-mapped APIC memory on x86_64
We were not allocating enough memory due to using u32 instead of
FlatPtr for each AP's stack pointer.
2022-02-21 20:44:09 +02:00
Idan Horowitz 5fa75dbcda Kernel: Try to dispatch pending signals on context switch
This ensures that processes that don't perform any syscalls will also
eventually receive signals.
2022-02-21 19:42:16 +01:00
Idan Horowitz 0911112286 Kernel: VERIFY that signals are not sent to Kernel processes
Kernel processes can't handle signals, nor should they ever receive any
2022-02-21 19:42:16 +01:00
Idan Horowitz 2c996cbbee Kernel: Stop sending SIGCHLD to kernel parent processes
Kernel processes cannot handle signals.
2022-02-21 19:42:16 +01:00
Tom 6448964485 Kernel: Implement booting all CPU cores on x86_64
The AP boot code was partially adapted to build on x86_64 but didn't
properly jump into 64 bit mode. Furthermore, the APIC code was still
using 32 bit pointers.

Fixes #12662
2022-02-21 17:46:02 +01:00
Sviatoslav Peleshko 073f472c51 Kernel: Init receive buffer for dynamically created VirtIO console port
We already init receive buffer if we have singleport console, but if
we have multiport console that dynamically allocates ports we never
initted their receive buffers.
2022-02-20 20:32:22 -08:00
Liav A 53b65ddc41 Kernel: Make i8042 existence check more robust against faulty hardware
Some hardware controllers might reset when trying to do self-test, so
keep the configuration byte to restore it later on.
To ensure we are not missing the response from the i8042 controller,
bump the attempts count to 20 times after initiating self-test check.

Also, try to drain the i8042 controller output buffer as it might be a
early good indication on whether i8042 is present or not.
To ensure we drain all the output buffer, we attempt to read from the
buffer 50 times and not 20 times.
2022-02-20 19:48:46 +00:00
Brian Gianforcaro 70f3fa2dd2 Kernel: Set new process name in do_exec before waiting for the tracer
While investigating why gdb is failing when it calls `PT_CONTINUE`
against Serenity I noticed that the names of the programs in the
System Monitor didn't make sense. They were seemingly stale.

After inspecting the kernel code, it became apparent that the sequence
occurs as follows:

    1. Debugger calls `fork()`
    2. The forked child calls `PT_TRACE_ME`
    3. The `PT_TRACE_ME` instructs the forked process to block in the
       kernel waiting for a signal from the tracer on the next call
       to `execve(..)`.
    4. Debugger waits for forked child to spawn and stop, and then it
       calls `PT_ATTACH` followed by `PT_CONTINUE` on the child.
    5. Currently the `PT_CONTINUE` fails because of some other yet to
       be found bug.
    6. The process name is set immediately AFTER we are woken up by
       the `PT_CONTINUE` which never happens in the case I'm debugging.

This chain of events leaves the process suspended, with the name  of
the original (forked) process instead of the name we inherit from
the `execve(..)` call.

To avoid such confusion in the future, we set the new name before we
block waiting for the tracer.
2022-02-19 18:04:32 -08:00
Linus Groh eca8208a34 Kernel: Increase i8042 IO attempt counts, again
This is very similar to the change that was done in 32053e8, except it
turned out that the new limit of 50 iterations was not enough when
testing on bare metal - most IO operations would succeed in the first or
second iteration, but two of them took 140 and 150 iterations
respectively.
Increase the limit from 50 to 250 to account for this, and have some
additional headroom.
2022-02-19 13:37:51 +00:00
Linus Groh 37a04b739a Kernel: Only do i8042 existence check via probing as a fallback
This caused an initialization failure of the i8042 when I tested on
bare metal. We cannot entirely get rid of this method as QEMU for
example doesn't indicate the existence of an i8042 via ACPI, but we can
get away with only doing the manual probing if ACPI is disabled or we
didn't get a 'yes' from it.
Increasing the number of maximum loops did eventually lead to a
successful return from the function, but would later fail the actual
self test.
2022-02-19 13:37:51 +00:00
Jakub Berkop 895a050e04 Kernel: Fixed argument passing for profiling_enable syscall
Arguments larger than 32bit need to be passed as a pointer on a 32bit
architectures. sys$profiling_enable has u64 event_mask argument,
which means that it needs to be passed as an pointer. Previously upper
32bits were filled by garbage.
2022-02-19 11:37:02 +01:00
Tom 413bc9976c Kernel: Don't enable write-combine for the Bochs framebuffer device
While write-combine greatly improves performance on bare metal, QEMU
appears to perform significantly worse when enabling it.
2022-02-18 10:30:42 +01:00