summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/amd64
AgeCommit message (Collapse)Author
2 dayskernel/amd64: Ensure CR4.UMIP is set by defaultIan Moffett
To prevent user programs from performing any operations related to system memory structures (such as the GDT, TSS, etc), we will always set CR4.UMIP if possible to improve the security of Hyra. Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel/amd64: tsc: Bail if the TSC isn't supportedIan Moffett
Some older CPUs may not even support the TSC so it would be a good idea to check before we start assuming its existence. Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel/amd64: conf: Add boolean USER_TSC optionIan Moffett
Introduce the USER_TSC kernel config option to control whether or not the 'rdtsc' instruction should be accessible in a user context. Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel/amd64: cpu: Report CPU vendor typeIan Moffett
This commit introduces a vendor field within the 'cpu_info' structure. This allows kernel code to detect the CPU vendor by comparing it with the CPU_VENDOR_* defines that have also been added. Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel: proc: Improve handling of 'nswitch'Ian Moffett
- Extend 'nswitch' to 64-bits as it increments fast - Ensure writes to 'nswitch' are atomic Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel/amd64: Add basic timestamp counter supportIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
4 dayskernel: timer: Add flags field + TIMER_MONOTONICIan Moffett
Sometimes we may rely on a specific kind of timer. While we are able to grab scheduler specific timers, general purpose timers, etc. One might need to for example, check whether their general purpose timer timer is monotonic or not. Signed-off-by: Ian Moffett <ian@osmora.org>
5 dayskernel/amd64: Introduce flexible IPI managementIan Moffett
This commit greatly improves the handling of how inter-processor interrupts are allocated and managed. Previously Hyra used handlers at fixed interrupt vectors for IPIs, however, that is very rigid and not very scalable at all. With the new IPI framework, one may allocate IPIs by calling 'md_ipi_alloc()' and initializing the handler field. To send an IPI to a specific processor, one can use cpu_ipi_send() and pass the specific CPU structure as well as the IPI identifier. Signed-off-by: Ian Moffett <ian@osmora.org>
8 dayskernel: sysctl: Report 'hw.*' variablesIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
9 dayskernel/amd64: Limit frame depth in backtraceIan Moffett
A backtrace usually occurs during critcal system events like panics. When the system in a error state, we cannot trust the correctness of the stack. This commit aims to improve checks done in a731d4e by adding a max frame depth that limits how many frames can be walked. Signed-off-by: Ian Moffett <ian@osmora.org>
9 dayskernel/amd64: Add better checks on 'rbp' and 'rip'Ian Moffett
Improve handling within the stacktrace logic used during system panics and critical events. - Perform checks on 'rbp' *before* logging - Ensure RBP is 8-byte aligned Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-25kernel/amd64: Keep track of which cores are onlineIan Moffett
Give each core a bit that indicates whether the core is online or halted. We also provide a cpu_halt() which marks the core as offline. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-17kernel/amd64: mp: Pin one idle thread to each coreIan Moffett
Each core on the CPU gets one idle thread so that it is always up to something. To ensure these threads are not bouncing wildly between cores and are always ready for their respective processor to take when they have no threads to grab. We must call proc_pin() on each for every processor. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-17kernel/amd64: Set up seperate syscall stackIan Moffett
It is a good idea to have a completely different stack during syscalls. This commit implements a TSS IST entry for syscalls. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-16kernel: accnt: Keep track of per-cpu statsIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-16kernel: Sort out switch MI/MD switch logicIan Moffett
Certain operations dealing with context switches are better off being implemented as machine dependent routines which allows us to be flexible with what we can do, as well as the extra benefit of requiring less workarounds to keep things MI. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel/amd64: Track interrupt countIan Moffett
Keep track of how many times an interrupt fires, this can be used for interrupt statistics later on. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel/amd64: Get CPU family + modelIan Moffett
The CPU family ID and model number are sometimes useful in order to detect the presence of certain CPU features as well as detecting CPU specific quirks. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel/amd64: cpu_check_feat() -> cpu_get_info()Ian Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel/amd64: Return NULL if IA32_GS_BASE is unsetIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel: Avoid using kprintf() during panicIan Moffett
Avoid using kprintf() during a system panic event as it relies on internal locking that may hang the system preventing diagnostics from being logged Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-05kernel/amd64: Add support for coredumpsIan Moffett
To make debugging userland program crashes easier, this commit introduces coredumps that store the last known process state into a temporary /tmp/core.X file (where X is the PID of the faulting process). Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-05kernel/amd64: conf: Add CPU_SMEP optionIan Moffett
Allow the user to configure if SMEP would be enabled for their build of the Hyra AMD64 port Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-05kernel/amd64: cpu: Support SMEPIan Moffett
Some CPUs support Supervisor Memory Execution Protection that prevent ring 3 code from being executed in a ring 0 context. Enable this on CPUs that support it. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-05kernel/amd64: Add 'feat' field in cpu_infoIan Moffett
Keep track of per-cpu features by using a 'feat' field which contains the results of various CPUIDs. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-29kernel/amd64: trap: Wrap regdump into a panic()Ian Moffett
- Rename regdump() to trap_fatal() - Use panic() rather than kprintf() Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-29kernel/amd64: trap: Restore IPL during user trapsIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-27kernel/amd64: mp: Give each core an idle threadIan Moffett
Having the same amount of idle threads per core allow the CPU to always have a thread assigned to one of its cores even when there are currently no other threads for it to take. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-25kernel/amd64: Throw away any pre-kernel huge pagesIan Moffett
Before the Hyra kernel starts up, the Limine bootloader creates a mapping of the first 4 GiB of memory (identity mapped for base revisions of zero and mapped to the HDDM on higher base revisions). However, it usually will create a huge mapping over this which would be problematic during remaps of device MMIO base addresses as they typically reside at the 4 GiB region of RAM and as of this commit, huge pages are not a supported feature of the Hyra AMD64 pmap layer. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-25kernel/amd64: Only use USER_DS in md_td_kick()Ian Moffett
The function md_td_kick() is only used for user threads and there is no need reference any kernel segments. Furthermore, the previous code would introduce a bug where rpl would always be 0. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-22kernel/amd64: Only print SIMD logs on BSP initIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-22kernel/amd64: Add SIMD (SSE + AVX) supportIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-20kernel/amd64: intr: Add driver specific intr dataIan Moffett
Allow the intr_hand structure to carry driver specific and interrupt related data so that it can be passed to an interrupt handler when it is invoked. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-20kernel/amd64: intr: Ensure intr_hand.name has '\0'Ian Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-19kernel: pmap: Add arch-shared pmap_init() routineIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-13kernel/amd64: Return stack top after stack initIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-09kernel/amd64: Flush TLB per cache attr updateIan Moffett
- Use pmap_update_tbl() to ensure that the TLB is flushed when caching attributes are updated. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-09kernel/amd64: Add `alloc` to pmap_update_tbl()Ian Moffett
Add an `alloc' paramater to pmap_update_tbl() to ensure that functions like pmap_map() and pmap_unmap() have control over, whether or not to allocate new page table entries. This is useful as unmapping memory does not require new page table entries to be allocated and doing so anyways may result in undefined behaviour such as hangs. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-08kernel/amd64: proc: Cleanup user stack vm_map()Ian Moffett
- Add prot var to keep track of flags to map with - OR prot flags with PROT_USER if rpl is 3 Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-07kernel/amd64: Save %RCX before calling handlerIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-01kernel/amd64: pmap: Add PTE dirty bit handlingIan Moffett
Add support for managing the page table entry dirty bit. This will allow vm(9) to know when to page-out data to backing store, among other things. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-01kernel/amd64: Add support for TLB shootdownsIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-01kernel/amd64: Only use HALT_VECTORIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-01kernel/amd64: Reserve IDT vec 0x22 for TLB IPIsIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-01kernel/amd64: mp: Add BSP to `ci_list'Ian Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-01kernel/amd64: mp: Keep track of CPUs by indexIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-05-31kernel/amd64: proc: Support kicking kernel threadsIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-05-29kernel/amd64: hpet: Add hpet_time_nsec()Ian Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-05-28kernel: proc: Store kernel thread flag in `proc'Ian Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-05-28kernel/amd64: trap: Log page fault flagsIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>