Commit graph

106 commits

Author SHA1 Message Date
Linus Groh f52e468cd6 Kernel: Fix L1/L2/L3 cache conditionals in ProcFSCPUInformation 2022-07-24 23:01:59 +01:00
Liav A e4e5fa74d0 Kernel+Userland: Rename prefix of user_physical => physical
There's no such supervisor pages concept, so there's no need to call
physical pages with the "user_physical" prefix anymore.
2022-07-14 23:27:46 +02:00
Liav A 1c499e75bd Kernel+Userland: Remove supervisor pages concept
There's no real value in separating physical pages to supervisor and
user types, so let's remove the concept and just let everyone to use
"user" physical pages which can be allocated from any PhysicalRegion
we want to use. Later on, we will remove the "user" prefix as this
prefix is not needed anymore.
2022-07-14 23:27:46 +02:00
Daniel Bertalan e93d19bbb1 Kernel: Don't lock the scheduler in ProcFSOverallProcesses::try_generate
This used to be needed to protect accesses to Process::all_instances.
That list now has a more granular lock, so we don't need to take the
scheduler lock.

This fixes a crash when we try to access a locked Thread::m_fds in the
loop, which calls Thread::block, which then asserts that the scheduler
lock must not be locked by the current process.

Fixes #13617
2022-07-14 13:13:40 +02:00
sin-ack 3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Timon Kruiper f085903f62 Kernel: Move IRQController and InterruptManagement to Arch directory
These 2 classes currently contain much code that is x86(_64) specific.
Move them to the architecture specific directory. This also allows for a
simpler implementation for aarch64.
2022-06-02 13:14:12 +01:00
Timon Kruiper a4534678f9 Kernel: Implement InterruptDisabler using generic Processor functions
Now that the code does not use architectural specific code, it is moved
to the generic Arch directory and the paths are modified accordingly.
2022-06-02 13:14:12 +01:00
Linus Groh 20e2e39fcc Kernel: Expose size of L1 data/instruction, L2, and L3 CPU caches :^)
These are added as properties of the "caches" object to each processor,
if available.
2022-05-29 15:23:57 +02:00
brapru 7a4e41f8f8 Kernel: Add support for route flags
Previously the routing table did not store the route flags. This
adds basic support and exposes them in the /proc directory so that a
userspace caller can query the route and identify the type of each
route.
2022-05-26 16:33:10 +02:00
Maciej 66ab4d61a4 Kernel: Stop exposing gateway field
It doesn't make sense after introduction of routing table which allows
having multiple gateways for every interface, and isn't used by any of
the userspace programs now.
2022-05-01 13:34:27 +02:00
brapru 19912a0b32 Kernel+Utilities: Add the route utility
This exposes the global routing table in the /proc directory and adds
the userspace utility to query dynamically add from the table.
2022-04-28 08:41:11 -07:00
brapru 419cd479e2 Kernel: Use TRY to handle string copies in GlobalProcessExposed
Each of these string copies are already inside of an ErrorOr context so
any failed copy should propagate.
2022-04-28 08:41:11 -07: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 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
Idan Horowitz 086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
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
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
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
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
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
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
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 9277d2dce2 AK+Kernel: Return KString from MACAddress::to_string() in the Kernel
This lets us safely handle allocation failure.
2022-02-16 22:21:37 +01:00
Idan Horowitz 6098ffa120 AK+Kernel: Return KString from IPv4Address::to_string() in the Kernel
This lets us safely handle allocation failure.
2022-02-16 22:21:37 +01:00
Andreas Kling a81aebfd6e Kernel: Remove unnecessary mutex for ubsan-is-deadly ProcFS node 2022-02-03 16:11:26 +01:00
Andreas Kling 6fbb924bbf Kernel: Protect ARP table with spinlock instead of mutex 2022-02-03 16:11:26 +01:00
Andreas Kling 3845c90e08 Kernel: Remove unnecessary includes from Thread.h
...and deal with the fallout by adding missing includes everywhere.
2022-01-30 16:21:59 +01:00
Andreas Kling b56646e293 Kernel: Switch process file descriptor table from spinlock to mutex
There's no reason for this to use a spinlock. Instead, let's allow
threads to block if someone else is using the descriptor table.
2022-01-29 02:17:09 +01:00
Andreas Kling 8ebec2938c Kernel: Convert process file descriptor table to a SpinlockProtected
Instead of manually locking in the various member functions of
Process::OpenFileDescriptions, simply wrap it in a SpinlockProtected.
2022-01-29 02:17:06 +01:00
Idan Horowitz dab73d6d23 Kernel: Make pledge serialization in /proc/all generation OOM-fallible 2022-01-26 02:37:03 +02:00
Idan Horowitz bd603003b5 Kernel: Make AddressSpace::amount_clean_inode() OOM-fallible 2022-01-26 02:37:03 +02:00
Idan Horowitz 792b8ca13c Kernel: Use StringView::to_uint instead of String::to_uint in ProcFS 2022-01-13 00:20:08 -08:00
Idan Horowitz 119f900451 Kernel: Use StringView literals instead of empty Strings in ProcFS 2022-01-13 00:20:08 -08:00
Idan Horowitz eb5f6cd108 Kernel: Use try_serialize_absolute_path in ProcFSOverallProcesses 2022-01-12 16:09:09 +02:00
Idan Horowitz 4e7d307166 Kernel: Convert Mount::absolute_path to ErrorOr<NonnullOwnPtr<KString>> 2022-01-12 16:09:09 +02:00
Idan Horowitz f9528f1882 Kernel: Rename ProcessorInfo::{m_brandstr => m_brand}
There's no need to specify the type of the member in it's name,
especially not in shorthand format.
2022-01-12 16:09:09 +02:00
Brian Gianforcaro 9592ba3548 Kernel: Avoid potential allocation when enumerating cpu features
We can use `StringView::for_each_split_view` here to avoid the potential
allocation of `Vector<StringView>` elements we would get from the normal
Split view functions.
2022-01-12 13:03:44 +01:00
Brian Gianforcaro faf1fa0a84 Kernel: Convert Processor::features_string() API to KString 2022-01-12 13:03:44 +01:00
Hendiadyoin1 23037d619a Kernel: Simplify some if statements 2021-12-30 14:32:17 +01:00
Hendiadyoin1 04d75f4ff9 Kernel: Add some implied auto qualifiers 2021-12-30 14:32:17 +01:00
Daniel Bertalan 2175c689ef Kernel: Remove redundant (K)String::characters() calls 2021-12-30 14:16:03 +01:00
Daniel Bertalan 1d2f78682b Kernel+AK: Eliminate a couple of temporary String allocations 2021-12-30 14:16:03 +01:00
Idan Horowitz d7ec5d042f Kernel: Port Process to ListedRefCounted 2021-12-29 12:04:15 +01:00
Idan Horowitz 3d0b5efcfc Kernel: Remove Process::all_processes()
This was only used in ProcFS, which can use the `processes()` list just
as well, so let's remove it.
2021-12-29 12:04:15 +01:00
Andreas Kling ac7ce12123 Kernel: Remove the kmalloc_eternal heap :^)
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-28 21:02:38 +01:00
Andreas Kling 3399b6c57f Kernel: Remove old SlabAllocator :^)
This is no longer useful since kmalloc() does automatic slab allocation
without any of the limitations of the old SlabAllocator. :^)
2021-12-26 21:22:59 +01:00
Liav A 9eb08bdb0f Kernel: Make major and minor numbers to be DistinctNumerics
This helps avoid confusion in general, and make constructors, methods
and code patterns much more clean and understandable.
2021-12-23 23:02:39 +01:00
Brian Gianforcaro 74ee491b84 Kernel: Handle string format errors in SlabAllocator stats :^)
Switch to KString::formatted and fix API so we can propagate errors.
2021-11-30 11:16:35 +01:00
Andreas Kling e08d213830 Kernel: Use DistinctNumeric for filesystem ID's
This patch adds the FileSystemID type, which is a distinct u32.
This prevents accidental conversion from arbitrary integers.
2021-11-18 21:11:30 +01:00