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
Gunnar Beutner
79ab9cce18
Kernel: Clear segment registers on x86_64
...
They're supposedly unused but iretq doesn't like ss being non-zero.
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
10ca7f18a7
Kernel: Fix declaration for struct TrapFrame
...
This is declared as a struct elsewhere.
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
9077c64d37
Kernel: Correct spelling mistake
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
4c555684b7
Kernel: Set an appropriate GDT for 64-bit mode
2021-06-25 15:19:09 +02:00
Gunnar Beutner
d84abe51f5
Kernel: Use PML4T for 64-bit mode
2021-06-25 15:19:09 +02:00
Gunnar Beutner
13e4093da4
Kernel: Move Multiboot header into a separate file
2021-06-25 15:19:09 +02:00
Gunnar Beutner
19c0498ccc
Kernel: Update the x86_64 boot code to match i386's code
2021-06-25 15:19:09 +02:00