Commit Graph

328 Commits

Author SHA1 Message Date
Timon Kruiper
5fc66c6072 Kernel: Fix capitalization of MiniStdLib.cpp in CMakeLists.txt
Commit fd3e3d5e28 added this, however
misspelled MiniStdLib.cpp. CMake wasn't complaining about this, but the
flags were also not applied to the file.
2022-05-21 20:23:32 +01:00
Timon Kruiper
9f3303c869 Kernel: Add -mgeneral-regs-only flag to aarch64 Kernel build
With the update to GCC 12.1.0, the compiler now vectorizes code with
-O2. This causes vector ops to be emitted, which are not supported in
the Kernel. Add the -mgeneral-regs-only flag to force the compiler to
not emit floating-point and SIMD ops.
2022-05-21 20:23:32 +01:00
Timon Kruiper
cc7723b6c4 Meta: Add option to disable Kernel Address Sanitizer
By default we enable the Kernel Undefined Behavior Sanitizer, which
checks for undefined behavior at runtime. However, sometimes a developer
might want to turn that off, so now there is a easy way to do that.
2022-05-21 20:23:32 +01:00
Ariel Don
9a6bd85924 Kernel+LibC+VFS: Implement utimensat(3)
Create POSIX utimensat() library call and corresponding system call to
update file access and modification times.
2022-05-21 18:15:00 +02:00
Timon Kruiper
d451bdec6f Kernel: Remove PREKERNEL_SOURCES from aarch64 CMakeLists.txt 2022-05-12 23:14:05 +02:00
Timon Kruiper
4db44c09a4 Kernel: Use the Kernel UBSanitizer implementation in the aarch64 Kernel
Now we actually print useful information when an UBSAN fault is
detected. :^)
2022-05-12 23:14:05 +02:00
Timon Kruiper
c96a3f0c48 Kernel: Move the aarch64 boot.S out of the Prekernel directory 2022-05-12 23:14:05 +02:00
Timon Kruiper
e88cd338f1 Kernel: Move Prekernel{CPU, Exceptions}.cpp out of Prekernel directory
This lets us delete the Prekernel.h file, and gets us closer to deleting
the Prekernel from the aarch64 Kernel.
2022-05-12 23:14:05 +02:00
Timon Kruiper
e7c5fd978b Kernel: Move Prekernel assembly utils to aarch64/ASM_wrapper.h
By moving these functions to the ASM_wrapper.h file, we can get rid of
another Prekernel file.
2022-05-12 23:14:05 +02:00
Timon Kruiper
e80d8d697c Kernel: Replace Prekernel::halt with Processor::halt in aarch64 build
This allows us to get rid of one more Prekernel file.
2022-05-12 23:14:05 +02:00
Daniel Bertalan
fd3e3d5e28 LibC+Kernel: Prevent string functions from calling themselves
Most of the string.h and wchar.h functions are implemented quite naively
at the moment, and GCC's pattern recognition pass might realize what we
are trying to do, and transform them into libcalls. This is usually a
useful optimization, but not when we're implementing the functions
themselves :^)

Relevant discussion from the GCC Bugzilla:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725

This prevents the infamous recursive `strlen`.

A more proper fix would be writing these functions in assembly. That
would likely give a small performance boost as well ;)
2022-05-12 13:12:37 +02:00
Timon Kruiper
b8854549f2 Kernel: Sort aarch64 CMake sources alphabetically 2022-05-09 21:12:56 +02:00
Timon Kruiper
c515e1341a Kernel: Add initial implementation of Processor in aarch64
Instead of storing the current Processor into a core local register, we
currently just store it into a global, since we don't support SMP for
aarch64 anyway. This simplifies the initial implementation.
2022-05-09 21:12:56 +02:00
Timon Kruiper
2e49d6b001 Kernel: Separate kmalloc.cpp into a separate library similar to x86_64
This will allow the call the constructors of the kmalloc.cpp file
before calling the other constructors in the Kernel.
2022-05-09 21:12:56 +02:00
Liav A
340773ddb7 Kernel/Graphics: Implement basic support for VMWare SVGA adapter 2022-05-06 18:04:57 +02:00
Liav A
e301af8352 Everywhere: Purge all support and usage of framebuffer devices
Long live the DisplayConnector object!
2022-05-05 20:55:57 +02:00
Liav A
f15b93c9a1 Kernel/Graphics: Use DisplayConnector design with generic framebuffers 2022-05-05 20:55:57 +02:00
Liav A
c27c414ed1 Kernel/Graphics: Apply DisplayConnector design on the VirtIO driver 2022-05-05 20:55:57 +02:00
Liav A
728358c599 Kernel/Graphics: Migrate Intel driver to use the DisplayConnector design 2022-05-05 20:55:57 +02:00
Liav A
e9a74cbefb Kernel/Graphics: Use DisplayConnector design for the Bochs driver 2022-05-05 20:55:57 +02:00
Liav A
912b8ab965 Kernel/Graphics: Introduce the DisplayConnector class
The DisplayConnector class is meant to replace the FramebufferDevice
class. The advantage of this class over the FramebufferDevice class is:
1. It removes the mmap interface entirely. This interface is unsafe, as
multiple processes could try to use it, and when switching to and from
text console mode, there's no "good" way to revoke a memory mapping from
this interface, let alone when there are multiple processes that call
this interface. Therefore, in the DisplayConnector class there's no
implementation for this method at all.
2. The class uses a new real-world structure called ModeSetting, which
takes into account the fact that real hardware requires more than width,
height and pitch settings to mode-set the display resolution.
3. The class assumes all instances should supply some sort of EDID,
so it facilitates such mechanism to do so. Even if a given driver does
not know what is the actual EDID, it will ask to create default-generic
EDID blob.
3. This class shifts the responsibilies of switching between console
mode and graphical mode from a GraphicsAdapter to the DisplayConnector
class, so when doing the switch, the GraphicsManagement code actually
asks each DisplayConnector object to do the switch and doesn't rely on
the GraphicsAdapter objects at all.
2022-05-05 20:55:57 +02:00
Timon Kruiper
e81e1fa9c8 Kernel: Implement __panic() for the aarch64 Kernel
Now that dump_backtrace() works, we can actually print a helpful
backtrace when the Kernel panics.
2022-05-03 21:53:36 +02:00
Timon Kruiper
9abcb6700c Kernel: Move Arch/x86/Spinlock.h and add stubs for aarch64
The code in Spinlock.h has no architectural specific logic, thus can be
moved to the Arch directory. This contains no functional change.

Also add the Spinlock.cpp file for aarch64 which contains stubs for the
lock and unlock functions.
2022-05-03 21:53:36 +02:00
Timon Kruiper
9f76b16124 Kernel: Implement safe_memcpy for the aarch64 build
The implementation just calls the regular memcpy, and is not safe yet.
This can be done later.
2022-05-03 21:53:36 +02:00
Timon Kruiper
267febae55 Kernel: Add KSyms.cpp to the aarch64 build
This is the first step in making dump_backtrace() work.
2022-05-03 21:53:36 +02:00
Timon Kruiper
4a2dcea685 Kernel: Remove aarch64/Utils.{cpp, h} since they are not used anymore 2022-05-03 00:59:35 +02:00
Timon Kruiper
b9944ca905 Kernel: Add aarch64 version of kprintf.cpp
This allows us to use the AK formatting functions in the aarch64 Kernel.
Also add FIXME to make sure that this file will be removed when the
proper abstractions are in place in the normal Kernel/kprintf.cpp.
2022-05-03 00:59:35 +02:00
Timon Kruiper
b3346aa08d Kernel: Fix aarch64 build by adding -Wno-nonnull flag
The compiler figured out that the MemoryManager is not initialised, and
thus MemoryManager::the() cannot return a valid reference. Once the
necesarry code is in place, this compiler flag can be removed.
2022-05-03 00:59:35 +02:00
Andrew Kaster
f08e91f67e Kernel: Don't check pledges or veil against code coverage data files
Coverage tools like LLVM's source-based coverage or GNU's --coverage
need to be able to write out coverage files from any binary, regardless
of its security posture. Not ignoring these pledges and veils means we
can't get our coverage data out without playing some serious tricks.

However this is pretty terrible for normal exeuction, so only skip these
checks when we explicitly configured userspace for coverage.
2022-05-02 01:46:18 +02:00
Jesse Buhagiar
300dcb6f5e Kernel/USB: Get all interface descriptors on enumeration
This creates all interfaces when the device is enumerated, with a link
to the configuration that it is a part of. As such, a new class,
`USBInterface` has been introduced to express this state.
2022-04-22 15:16:56 +02:00
Liav A
02566d8091 Kernel: Move VMWareBackdoor to new directory in the Firmware directory 2022-04-20 19:21:32 +02:00
Tiaan Louw
678555af97 Kernel: Adjust includes after file reorganization 2022-04-08 15:06:33 +01:00
James Mintram
d94c7fa417 Kernel: Improve the aarch64 kernel source files disk layout 2022-04-06 08:56:20 +01:00
Brian Gianforcaro
8b750998d2 Kernel: Fix aarch64 kernel build on case sensitive file systems
The dummy file has the wrong case, so it would fail to be found on case
sensitive file systems.
2022-04-03 15:18:36 -07:00
James Mintram
f943e97b76 Kernel: Add RegionTree and remove VirtualRangeAllocator from aarch64 2022-04-04 00:14:20 +02:00
James Mintram
2b442ae44f Kernel: Add kmalloc.cpp to aarch64 2022-04-03 23:21:04 +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
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
031b0c76b5 Kernel: Re-add dummy.cpp and remove duplicate definitions 2022-04-02 19:34:20 -07: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
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
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
Liav A
462618b68c Kernel/Storage: Move Ramdisk code into a separate subdirectory 2022-03-19 13:41:06 +00: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
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
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