Commit graph

324 commits

Author SHA1 Message Date
Jean-Baptiste Boric
4cc346fb19 Kernel: Add support for hypervisor CPUID feature 2021-07-14 13:52:34 +02:00
Daniel Bertalan
ef40de9c6c Kernel: Don't mix AT&T and Intel ASM syntax in boot.S
The rest of the file is in AT&T syntax, so for the time being, I'll
switch these instructions to AT&T too to make Clang shut up.
2021-07-14 13:12:25 +02:00
Hendiadyoin1
d761c5024b AK: Generalize ByteReader
Also use it instead of CPU.h's possibly_unaligned_data interface
2021-07-14 11:26:34 +04:30
Brian Gianforcaro
da665077ce Kernel: Remove unused header includes in Arch subtree 2021-07-11 21:37:38 +02:00
Andreas Kling
98080497d2 Kernel: Use Forward.h headers more 2021-07-11 14:14:51 +02:00
Andreas Kling
358a7cc448 Kernel: Rename SysFS related classes in BIOS code
Give them names that sound related to SysFS.
2021-07-11 01:38:01 +02:00
Andreas Kling
805319ed30 Kernel: Replace "Folder" => "Directory" everywhere
Folders are a GUI concept, file systems have directories. :^)
2021-07-11 01:33:40 +02:00
Andreas Kling
60a7a9d523 Kernel: Rename SystemExposedFolder => SysFSDirectory
"Folder" is a GUI concept, let's call this "Directory".
Also, "System" is completely generic, so let's be more specific and
call this "SysFS..."
2021-07-11 01:07:27 +02:00
Andreas Kling
517170a986 Kernel: Rename SystemExposedComponent => SysFSComponent 2021-07-11 01:06:27 +02:00
Andreas Kling
27244eb0ee Kernel: Rename SystemRegistrar => SysFSComponentRegistry 2021-07-11 01:05:26 +02:00
Luke
c94b0e80e7 Kernel: Stop booting and print if PAE is not supported by the processor
We currently require PAE and not having it causes us to crash.
This turns that crash into an error message.
2021-07-09 01:29:52 +02:00
Tom
87dc4c3d2c Kernel: Move PhysicalPage classes out of the heap into an array
By moving the PhysicalPage classes out of the kernel heap into a static
array, one for each physical page, we can avoid the added overhead and
easily find them by indexing into an array.

This also wraps the PhysicalPage into a PhysicalPageEntry, which allows
us to re-use each slot with information where to find the next free
page.
2021-07-08 11:43:34 +02:00
Tom
ad5d9d648b Kernel: Use PAE to allow accessing all physical memory beyond 4GB
We already use PAE for the NX bit, but this changes the PhysicalAddress
structure to be able to hold 64 bit physical addresses. This allows us
to use all the available physical memory.
2021-07-08 11:43:34 +02:00
Liav A
cc98871383 Kernel: Print if image has become too large again
Instead of just disabling interrupts and halting when entering the C++
section, just halt with a printed message indicating the error.
2021-07-07 22:18:36 +02:00
Liav A
8e8a5680d5 Kernel/x86_64: Print if machine doesn't support x86_64 mode
We drop to real mode and use two BIOS calls to do this.
2021-07-06 19:01:27 +02:00
Gunnar Beutner
8aafbd917a Kernel: Fix incorrect indentation
Looks like a tab and some other things snuck in. :)
2021-07-05 17:12:56 +02:00
Hendiadyoin1
9b7e48c6bd Kernel: Replace raw asm functions with naked ones 2021-07-05 16:40:00 +02:00
Gunnar Beutner
8c14488106 Kernel: Get rid of of some of the duplicate kernel base address macros 2021-07-05 12:28:45 +02:00
Gunnar Beutner
040fe0054b Kernel: Merge the x86 and x86_64 boot code into a single file
They're mostly the same apart from some x86_64-specific parts.
2021-07-05 12:28:45 +02:00
Tom
dce18958b6 Kernel: Fix safe_memset not setting the last few bytes in some cases
Because the remainder variable will always be 0 unless a fault happened
we should not use it to decide if we have nothing left to memset when
finishing the fast path. This caused not all bytes to be zeroed
if the size was not an exact multiple of sizeof(size_t).

Fixes #8352
2021-07-04 18:54:16 +02:00
Gunnar Beutner
c51b49a8cb Kernel: Implement TLS support for x86_64 2021-07-04 01:07:28 +02:00
Gunnar Beutner
04a912f68f Kernel: Hide the implementation detail that MSRs use two registers
When retrieving and setting x86 MSRs two registers are required. The
existing setter and getter for the MSR class made this implementation
detail visible to the caller. This changes the setter and getter to
use u64 instead.
2021-07-04 01:07:28 +02:00
Gunnar Beutner
5ca95b3957 Kernel: Replace some hard-coded memory addresses with macros 2021-07-04 01:07:28 +02:00
Liav A
458ac9bbba Kernel/x86_64: Halt if we happen to boot on non-x86_64 machine 2021-07-03 18:40:37 +02:00
Gunnar Beutner
52f9aaa823 Kernel: Use the GS segment for the per-CPU struct
Right now we're using the FS segment for our per-CPU struct. On x86_64
there's an instruction to switch between a kernel and usermode GS
segment (swapgs) which we could use.

This patch doesn't update the rest of the code to use swapgs but it
prepares for that by using the GS segment instead of the FS segment.
2021-07-02 23:33:17 +02:00
Daniel Bertalan
45a82b2a5b Kernel: Fix struct forward declared as class 2021-07-03 01:56:31 +04:30
Gunnar Beutner
5666809889 Kernel: Fix building the kernel with LTO
Fixes #8383.
2021-07-02 17:51:26 +02:00
Gunnar Beutner
db334b50d0 Kernel: Don't byteswap the ISR number on interrupt entry
Let's just add the padding before we jump to interrupt_common_asm_entry.
2021-07-01 23:36:17 +02:00
Hendiadyoin1
5f6c513610 Kernel: Add support for 64-bit unaligned Mem-ops
Also let the compiler enforce the size and type restrictions
2021-07-01 17:32:34 +02:00
Hendiadyoin1
6b9cf8376e Kernel: Remove not needed comment in Processor.h 2021-07-01 17:32:34 +02:00
Hendiadyoin1
90cd11fa8c Kernel: Support starting up secondary processors on x86_64 2021-07-01 10:50:00 +02:00
Gunnar Beutner
e37576440d Kernel: Fix stack alignment on x86_64
These were already properly aligned (as far as I can tell).
2021-06-30 15:13:30 +02:00
Gunnar Beutner
50839bd1f1 Kernel: Properly initialize r8-r15 for new threads on x86_64 2021-06-30 15:13:30 +02:00
Liav A
92c0dab5ab Kernel: Introduce the new SysFS
The intention is to add dynamic mechanism for notifying the userspace
about hotplug events. Currently, the DMI (SMBIOS) blobs and ACPI tables
are exposed in the new filesystem.
2021-06-29 20:53:59 +02:00
Gunnar Beutner
0b82c583e0 Kernel: Implement capturing stack traces on x86_64 2021-06-29 20:03:36 +02:00
Gunnar Beutner
36ce2a2b76 Kernel: Fix struct layout for interrupt entries on x86_64 2021-06-29 20:03:36 +02:00
Gunnar Beutner
df9e73de25 Kernel: Add x86_64 support for fork() 2021-06-29 20:03:36 +02:00
Gunnar Beutner
732dc72c58 Kernel: Fix the limit for the IDT table 2021-06-28 22:29:28 +02:00
Gunnar Beutner
e979a88af4 Kernel: Implement do_assume_context for execve() on x86_64 2021-06-28 22:29:28 +02:00
Gunnar Beutner
a8587fbfb9 Kernel: Use FlatPtr for register-sized values 2021-06-28 22:29:28 +02:00
Gunnar Beutner
b5aad1c81d Kernel: Fix GDT and segment selectors to make userland work on x86_64
Userland faulted on the very first instruction before because the
PML4T/PDPT/etc. weren't marked as user-accessible. For some reason
x86 doesn't care about that.

Also, we need to provide an appropriate userspace stack segment
selector to iretq.
2021-06-28 22:29:28 +02:00
rileylyman
640db93bdd Kernel: Fix small typo in inline comment 2021-06-28 16:39:25 +02:00
Gunnar Beutner
e56a0d6af7 Kernel: Fix memset() on x86_64
Previously memset() only set half of the bytes to the requested value.
2021-06-28 15:55:00 +02:00
Gunnar Beutner
32840dfa17 Kernel: Implement more x86_64 context switching functionality 2021-06-28 15:55:00 +02:00
Gunnar Beutner
076692b1ef Kernel: Implement entry code for x86_64 interrupts
With this fixed we can now properly handle interrupts (e.g. timer
interrupts) on x86_64.
2021-06-28 15:55:00 +02:00
Gunnar Beutner
328d44e227 Kernel: Fix stack for new threads on x86_64
Unlike on x86 iretq always pops rsp and ss.
2021-06-28 15:55:00 +02:00
Gunnar Beutner
9ed051fe25 Kernel: Implement initializing threads on x86_64 2021-06-27 15:46:42 +02:00
Gunnar Beutner
f285241cb8 Kernel: Rename Thread::tss to Thread::regs and add x86_64 support
We're using software context switches so calling this struct tss is
somewhat misleading.
2021-06-27 15:46:42 +02:00
Gunnar Beutner
eba33f82b8 Kernel: Reorder code a bit to clarify which #if block it belongs to 2021-06-27 15:46:42 +02:00
Gunnar Beutner
df530941cc Kernel: Implement safe_* memory access functions for x86_64 2021-06-27 15:46:42 +02:00