Commit Graph

5997 Commits

Author SHA1 Message Date
Tim Schumacher
20986b7066 Prekernel: Force enable PAE on Intel Pentium M CPUs 2021-10-17 16:15:36 +01:00
Tim Schumacher
e8808b259a Prekernel: Split early boot printing into two subroutines 2021-10-17 16:15:36 +01:00
SeekingBlues
3d174e3ad2 Kernel/ProcFS: Provide a way to write to ProcFS inodes
ProcFSGlobalInode now calls `write_bytes()`, `truncate()` and
`set_mtime()` on its associated component. This allows us to write 0 or
1 to a ProcFSSystemBoolean component to toggle a boolean value.
2021-10-17 14:46:59 +02:00
Tim Schumacher
52621093c7 Kernel: Print CPU check errors by writing to VRAM 2021-10-17 12:25:50 +01:00
James Mintram
e35222a76e Kernel: Move ScopedCritical + SmapDisabler CPP files into x86 common 2021-10-16 15:43:41 -07:00
James Mintram
8e4d53f216 Kernel: Add MiniStdLib to the Aarch64 kernel 2021-10-16 23:31:52 +01:00
James Mintram
3a9c7ce9d4 Kernel: Add StdLib.cpp to aarch64 build and update stubs in dummy.cpp 2021-10-15 21:48:45 +01:00
James Mintram
e8f09279d3 Kernel: Move spinlock into Arch
Spinlocks are tied to the platform they are built for, this is why they
have been moved into the Arch folder. They are still available via
"Locking/Spinlock.h"

An Aarch64 stub has been created
2021-10-15 21:48:45 +01:00
James Mintram
dfe4810c3a Kernel: Add cross platform RegisterState header and Aarch64 version
A new RegisterState header includes the platform specific RegisterState
header based on the platform being compiled.

The Aarch64 RegisterState header contains stubs for Debug
2021-10-15 21:48:45 +01:00
James Mintram
0fbeac6011 Kernel: Split SmapDisabler so header is platform independent
A new header file has been created in the Arch/ folder while the
implementation has been moved into a CPP living in the X86 folder.
2021-10-15 21:48:45 +01:00
James Mintram
f4fb637914 Kernel: Split ScopedCritical so header is platform independent
A new header file has been created in the Arch/ folder while the
implementation has been moved into a CPP living in the X86 folder.
2021-10-15 21:48:45 +01:00
Nico Weber
b135efe870 Kernel: List AK_SOURCES only once 2021-10-15 17:49:54 +01:00
Marcin Undak
d14d7ee78b Kernel: Discover initial exception level when booting Aarch64
When booting on RPI3 firmware puts CPU in EL2 mode which is
different from QEMU's default EL3.

I've added logic to discover initial mode at boot
and then act accordingly. This results in Serenity corectly
switching to EL1 on target hardware now.
2021-10-15 17:47:39 +01:00
Marcin Undak
ebf810f9a6 Kernel: Make Aarch64 register variables bit more descriptive 2021-10-15 17:47:39 +01:00
Marcin Undak
2d9fa8146c Kernel: Switch processor to EL1 immediately after boot on Aarch64 2021-10-15 17:47:39 +01:00
Marcin Undak
d6021300d5 Kernel: Move wait_cycles() function to Aarch_asm_utils.S
Just a bit of housekeeping.
2021-10-15 17:47:39 +01:00
Marcin Undak
18eb4a59d6 Kernel: Print current CPU exception level after booting on Aarch64
This is a first step to switch to exception level 1.

This is also my first patch for SerenityOS :)
2021-10-15 17:47:39 +01:00
James Mintram
a48985422c Kernel: Add UBSanitizer.cpp to the Aarch64 kernel build 2021-10-14 10:20:03 +01:00
James Mintram
ceb3328877 Kernel: Fix all linker errors for Aarch64 build 2021-10-14 01:23:08 +01:00
James Mintram
ab70268d61 Kernel: Add the AK sources to the Aarch64 kernel build 2021-10-14 01:23:08 +01:00
James Mintram
545ce5b595 Kernel: Add per platform Processor.h headers
The platform independent Processor.h file includes the shared processor
code and includes the specific platform header file.

All references to the Arch/x86/Processor.h file have been replaced with
a reference to Arch/Processor.h.
2021-10-14 01:23:08 +01:00
James Mintram
23676bee1f Kernel: Add -fsigned-char to ensure consistency across platforms 2021-10-14 01:23:08 +01:00
James Mintram
2a4969d281 Kernel: Move asserts inside platform #if clauses 2021-10-14 01:23:08 +01:00
James Mintram
580006d784 Kernel: Replace includes with a forward declaration 2021-10-14 01:23:08 +01:00
James Mintram
baa7925c0c Kernel: Remove unused includes 2021-10-14 01:23:08 +01:00
James Mintram
26d7c25076 Kernel: Add header includes closer to their use 2021-10-14 01:23:08 +01:00
James Mintram
d92967406a Kernel: Add post build step to generate kernel8.img
Add a postbuild step which creates a raw binary file called kernel8.img
from the Prekernel elf file.
2021-10-13 23:34:29 +01:00
Rodrigo Tobar
e1093c3403 Kernel: Implement pread syscall
The OpenFileDescription class already offers the necessary functionlity,
so implementing this was only a matter of following the structure for
`read` while handling the additional `offset` argument.
2021-10-13 16:10:50 +02:00
Rodrigo Tobar
8936b111a7 Kernel: Factor out common code from read/readv syscalls
Having these bits of code factored out not only prevents duplication
now, but will also allow us to implement pread without repeating
ourselves (too much).
2021-10-13 16:10:50 +02:00
James Mintram
a8e5130183 Kernel: Pass RegisterState by ref to event buffer 2021-10-12 10:49:56 -07:00
James Mintram
a4509ba633 Kernel: Accept RegisterState in append_with_ip_and_bp 2021-10-12 10:49:56 -07:00
Rodrigo Tobar
bf4e536f00 Kernel: Correctly interpret ioctl's FIONBIO user value
Values in `ioctl` are given through a pointer, but ioctl's FIONBIO
implementation was interpreting this pointer as an integer directly.
This meant that programs using `ioctl` to set a file descriptor in
blocking mode met with incorrect behavior: they passed a non-null
pointer pointing to a value of 0, but the kernel interpreted the pointer
as a non-zero integer, thus making the file non-blocking.

This commit fixes this behavior by reading the value from the userspace
pointer and using that to set the non-blocking flag on the file
descriptor.

This bug was found while trying to run the openssl tool on serenity,
which used `ioctl` to ensure newly-created sockets are in blocking mode.
2021-10-11 10:46:01 -07:00
Ben Wiederhake
fd8300e52d Kernel: Declare copy-ability of IOAddressGroup 2021-10-10 21:03:27 +01:00
Liav A
f8489da8ee Kernel/SysFS: Provide a way to "truncate" and "set" mtime on inodes
Normally, trying to truncate a SysFSInode should result in EPERM error.
However, as suggested by Ali (@alimpfard), we can allow the PowerState
node to be "truncated" so one can open that file with O_TRUNC option.
Likewise, we also need to provide a way to set modified time on SysFS
inodes. For most inodes, we should return ENOTIMPL error, but for the
power state switch, we ignore the modified time setting and just return
KSuccess.

These fixes allow to do "echo -n 1 > /sys/firmware/power_state" in Shell
after gaining root permissions, to switch the power state.
2021-10-09 12:07:56 +02:00
David Isaksson
b2e57f555b Kernel: Add ioctl request for getting a storage device's block size 2021-10-09 12:06:47 +02:00
David Isaksson
3b089032f4 Kernel: Add STORAGE_DEVICE_GET_SIZE ioctl request
This ioctl request makes it possible to get the size of a storage device
that has not yet been mounted.
2021-10-09 12:06:47 +02:00
Liav A
741c871bc1 Kernel/Storage: Unify all ATA devices
There's basically no real difference in software between a SATA harddisk
and IDE harddisk. The difference in the implementation is for the host
bus adapter protocol and registers layout.
Therefore, there's no point in putting a distinction in software to
these devices.

This change also greatly simplifies and removes stale APIs and removes
unnecessary parameters in constructor calls, which tighten things
further everywhere.
2021-10-09 01:39:55 +02:00
Nico Weber
1cdb12e920 Kernel: Fix -Wunreachable-code warnings from clang 2021-10-08 23:33:46 +02:00
Idan Horowitz
4174fe0156 Kernel: Use find_largest_not_above in VirtualRangeAllocator
Instead of iterating over the regions in the tree which is O(n), we can
just use RedBlackTree's find_largest_not_above method, which is O(logn)
2021-10-07 22:10:45 +02:00
Luke Wilde
49259777ef Kernel: Note if the page fault address is a destroyed smart pointer
While I was working on LibWeb, I got a page fault at 0xe0e0e0e4.
This indicates a destroyed RefPtr if compiled with SANITIZE_PTRS
defined. However, the page fault handler didn't print out this
indication.

This makes the page fault handler print out a note if the faulting
address looks like a recently destroyed RefPtr, OwnPtr, NonnullRefPtr,
NonnullOwnPtr, ThreadSafeRefPtr or ThreadSafeNonnullRefPtr. It will
only do this if SANITIZE_PTRS is defined, as smart pointers don't get
scrubbed without it being defined.
2021-10-07 21:30:13 +02:00
Idan Horowitz
399b5ffb64 Kernel: Add the /proc/stat ProcFS component
This exposes a small subset of the information exposed by the Linux
equivalent, and will be used to optimize applications that would like
to know the current CPU usage statistics, but don't want to read all of
the unrelated information in /proc/all
2021-10-07 21:09:38 +02:00
Idan Horowitz
900fac27c6 Kernel: Add Processor::time_spent_idle() 2021-10-07 21:09:38 +02:00
Andreas Kling
5b1f697460 AK+Kernel: Make automatically locking RefPtr & co a kernel-only thing
Some time ago, automatic locking was added to the AK smart pointers to
paper over various race conditions in the kernel. Until we've actually
solved the issues in the kernel, we're stuck with the locking.

However, we don't need to punish single-threaded userspace programs with
the high cost of locking. This patch moves the thread-safe variants of
RefPtr, NonnullRefPtr, WeakPtr and RefCounted into Kernel/Library/.
2021-10-07 19:27:30 +02:00
Tim Schumacher
228a32effc Kernel: Don't retrieve possibly nonexistent APIC table 2021-10-06 17:11:02 +02:00
Peter Elliott
669b23ac0a Kernel: Handle backspace for tab character in TTY cooked mode
Before, serenity would only backspace one character for a tab.
This is the only feature that my OS has and serenity doesn't.
2021-10-06 12:31:13 +02:00
Idan Horowitz
ce334ee1bc Kernel: Validate x86_64 address canonicality before SafeMem operations
This ensures we don't GP on x86_64 when a non-canonical address is fed
to a safe_foo() operation.
2021-10-05 02:07:43 +02:00
Idan Horowitz
cd975668d6 Kernel: Detect and store the virtual address bit width during CPU init 2021-10-05 02:07:43 +02:00
Brian Gianforcaro
9d17070047 Kernel: Fix copy paste in VirtIO::RNG::class_name()
Ben noticed this copy paste error during code review.

Co-authored-by: Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
2021-10-03 13:36:10 +02:00
Brian Gianforcaro
40a58f1fd4 Kernel: Remove unused partition name API
I was about to convert this to use KString, but then I realized it
wasn't actually used at all, so lets remove it until the day it is
needed.
2021-10-03 13:36:10 +02:00
Brian Gianforcaro
54a2aaaa6f Kernel: Remove now unused StorageDevice constructor 2021-10-03 13:36:10 +02:00