Jean-Baptiste Boric
528574d958
Kernel: Detect and display CPUID Hyper-V data
2021-07-14 13:52:34 +02:00
Jean-Baptiste Boric
b22357b17b
Kernel: Detect and display CPUID hypervisor signature
2021-07-14 13:52:34 +02:00
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
Brian Gianforcaro
da665077ce
Kernel: Remove unused header includes in Arch subtree
2021-07-11 21:37:38 +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
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
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
Gunnar Beutner
5666809889
Kernel: Fix building the kernel with LTO
...
Fixes #8383 .
2021-07-02 17:51:26 +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
0b82c583e0
Kernel: Implement capturing stack traces 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
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
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
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
Gunnar Beutner
9d9f20391d
Kernel: Use macros for GDT indices instead of hardcoding the values
2021-06-27 15:46:42 +02:00
Gunnar Beutner
065c6c307d
Kernel: Add support for interrupts on x86_64
2021-06-27 15:46:42 +02:00
Gunnar Beutner
233ef26e4d
Kernel+Userland: Add x86_64 registers to RegisterState/PtraceRegisters
2021-06-27 15:46:42 +02:00
Gunnar Beutner
324f72d02b
Kernel: Fix incorrect flags for the GDT entries
...
The Sz (protected mode) bit should not be set for 64-bit GDT entries.
2021-06-27 15:46:42 +02:00
Gunnar Beutner
389bf82889
Kernel: Add CPUID flag for long mode
...
This isn't particularly useful because by the time we've entered
init() the CPU had better support x86_64 anyway. However this shows the
CPU flag in System Monitor - even in 32-bit mode.
2021-06-26 11:08:52 +02:00
Gunnar Beutner
e52051903b
Kernel: Fix off-by-one error in Processor::write_raw_gdt_entry
2021-06-26 11:08:52 +02:00
Gunnar Beutner
f630299d49
Kernel: Add support for setting up a x86_64 GDT once in C++ land
2021-06-26 11:08:52 +02:00
Gunnar Beutner
29d9666e02
Kernel: Fix GDT limits
...
The GDT limits are inclusive, so for correctness we should subtract
one from the structs' size.
2021-06-26 11:08:52 +02:00
Gunnar Beutner
13e4093da4
Kernel: Move Multiboot header into a separate file
2021-06-25 15:19:09 +02:00
Daniel Bertalan
74535628a8
Kernel: Use proper Atomic<T>
types in CPU
...
This is needed because Clang's intrinsic atomic functions behave weirdly
if only one of their pointer arguments is volatile.
2021-06-24 17:35:49 +04:30
Gunnar Beutner
38fca26f54
Kernel: Add stubs for missing x86_64 functionality
...
This adds just enough stubs to make the kernel compile on x86_64. Obviously
it won't do anything useful - in fact it won't even attempt to boot because
Multiboot doesn't support ELF64 binaries - but it gets those compiler errors
out of the way so more progress can be made getting all the missing
functionality in place.
2021-06-24 09:27:13 +02:00
Hendiadyoin1
62f9377656
Kernel: Move special sections into Sections.h
...
This also removes a lot of CPU.h includes infavor for Sections.h
2021-06-24 00:38:23 +02:00
Hendiadyoin1
7ca3d413f7
Kernel: Pull apart CPU.h
...
This does not add any functional changes
2021-06-24 00:38:23 +02:00